From b18912cda823452bc139fe1cb524a08fc12df1f1 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 30 Dec 2019 15:33:51 -0800 Subject: [PATCH] SCP: Silence GCC optimizer warnings about unused function results --- scp.c | 2 +- sim_console.c | 2 +- sim_ether.c | 14 +++++++------- sim_frontpanel.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scp.c b/scp.c index 3cc41f41..77e03a32 100644 --- a/scp.c +++ b/scp.c @@ -13618,7 +13618,7 @@ rewind (tmp); /* Discard leading blank lines/redundant titles */ for (i =0; i < skiplines; i++) - fgets (tbuf, sizeof (tbuf), tmp); + if (fgets (tbuf, sizeof (tbuf), tmp)) {}; while (fgets (tbuf, sizeof (tbuf), tmp)) { if (tbuf[0] != '\n') diff --git a/sim_console.c b/sim_console.c index 2eb20859..b084e6c2 100644 --- a/sim_console.c +++ b/sim_console.c @@ -4219,7 +4219,7 @@ static t_stat sim_os_putchar (int32 out) char c; c = out; -(void)write (1, &c, 1); +if (write (1, &c, 1)) {}; return SCPE_OK; } diff --git a/sim_ether.c b/sim_ether.c index f242e909..fd02d25d 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -417,7 +417,7 @@ t_stat eth_mac_scan_ex (ETH_MAC* mac, const char* strmac, UNIT *uptr) memset (&state, 0, sizeof(state)); _eth_get_system_id (state.system_id, sizeof(state.system_id)); strlcpy (state.sim, sim_name, sizeof(state.sim)); - getcwd (state.cwd, sizeof(state.cwd)); + if (getcwd (state.cwd, sizeof(state.cwd))) {}; if (uptr) strlcpy (state.uname, sim_uname (uptr), sizeof(state.uname)); cptr = strchr (strmac, '>'); @@ -426,7 +426,7 @@ t_stat eth_mac_scan_ex (ETH_MAC* mac, const char* strmac, UNIT *uptr) strlcpy (state.file, cptr + 1, sizeof(state.file)); if ((f = fopen (state.file, "r"))) { filebuf[sizeof(filebuf)-1] = '\0'; - fgets (filebuf, sizeof(filebuf)-1, f); + if (fgets (filebuf, sizeof(filebuf)-1, f)) {}; strmac = filebuf; fclose (f); strcpy (state.file, ""); /* avoid saving */ @@ -1573,10 +1573,10 @@ static void eth_get_nic_hw_addr(ETH_DEV* dev, const char *devname) memset(command, 0, sizeof(command)); /* try to force an otherwise unused interface to be turned on */ snprintf(command, sizeof(command)-1, "ifconfig %.*s up", (int)(sizeof(command) - 14), devname); - (void)system(command); + if (system(command)) {}; for (i=0; patterns[i] && (0 == dev->have_host_nic_phy_addr); ++i) { snprintf(command, sizeof(command)-1, "ifconfig %.*s | %s >NIC.hwaddr", (int)(sizeof(command) - (26 + strlen(patterns[i]))), devname, patterns[i]); - (void)system(command); + if (system(command)) {}; if (NULL != (f = fopen("NIC.hwaddr", "r"))) { while (0 == dev->have_host_nic_phy_addr) { if (fgets(command, sizeof(command)-1, f)) { @@ -1662,12 +1662,12 @@ FILE *f; memset (buf, 0, buf_size); if ((f = fopen ("/etc/machine-id", "r"))) { - fread (buf, 1, buf_size, f); + if (fread (buf, 1, buf_size - 1, f)) {}; fclose (f); } else { if ((f = popen ("hostname", "r"))) { - fread (buf, 1, buf_size, f); + if (fread (buf, 1, buf_size - 1, f)) {}; pclose (f); } } @@ -2165,7 +2165,7 @@ else { /* !tap: */ /* try to force an otherwise unused interface to be turned on */ memset(command, 0, sizeof(command)); snprintf(command, sizeof(command)-1, "ifconfig %s up", savname); - (void)system(command); + if (system(command)) {}; errbuf[0] = '\0'; *handle = (void*) pcap_open_live(savname, bufsz, ETH_PROMISC, PCAP_READ_TIMEOUT, errbuf); } diff --git a/sim_frontpanel.c b/sim_frontpanel.c index 2ad2a2c4..32b2b0fd 100644 --- a/sim_frontpanel.c +++ b/sim_frontpanel.c @@ -867,7 +867,7 @@ if (!simulator_panel) { p->pidProcess = fork(); if (p->pidProcess == 0) { close (0); close (1); close (2); /* make sure not to pass the open standard handles */ - dup (dup (open ("/dev/null", O_RDWR))); /* open standard handles to /dev/null */ + if (dup (dup (open ("/dev/null", O_RDWR)))) {}; /* open standard handles to /dev/null */ if (execlp (sim_path, sim_path, p->temp_config, NULL, NULL)) { perror ("execl"); exit(errno);