Skip to content

Commit

Permalink
Explicit marking of ignoring fprintf() result
Browse files Browse the repository at this point in the history
Ensure consistent marking of '(void)' for most normal usage of fprintf()

TESTED:
'scons build-all check' passes

Signed-off-by: Fred Wright <[email protected]>
  • Loading branch information
rnorris authored and fhgwright committed Feb 20, 2017
1 parent 9d126a4 commit e2695bd
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cgps.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ int main(int argc, char *argv[])
wait_clicks = 0;
errno = 0;
if (gps_read(&gpsdata) == -1) {
fprintf(stderr, "cgps: socket error 4\n");
(void)fprintf(stderr, "cgps: socket error 4\n");
die(errno == 0 ? GPS_GONE : GPS_ERROR);
} else {
/* Here's where updates go now that things are established. */
Expand Down
14 changes: 7 additions & 7 deletions driver_nmea2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,18 +1370,18 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session)
struct timespec msgTime;

clock_gettime(CLOCK_REALTIME, &msgTime);
fprintf(logFile,
"(%010d.%06d) can0 %08x#",
(unsigned int)msgTime.tv_sec,
(unsigned int)msgTime.tv_nsec/1000,
frame->can_id & 0x1ffffff);
(void)fprintf(logFile,
"(%010d.%06d) can0 %08x#",
(unsigned int)msgTime.tv_sec,
(unsigned int)msgTime.tv_nsec/1000,
frame->can_id & 0x1ffffff);
if ((frame->can_dlc & 0x0f) > 0) {
int l1;
for(l1=0;l1<(frame->can_dlc & 0x0f);l1++) {
fprintf(logFile, "%02x", frame->data[l1]);
(void)fprintf(logFile, "%02x", frame->data[l1]);
}
}
fprintf(logFile, "\n");
(void)fprintf(logFile, "\n");
}
#endif /* of if LOG_FILE */
session->driver.nmea2000.can_msgcnt += 1;
Expand Down
10 changes: 5 additions & 5 deletions gps2udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static int send_udp (char *nmeastring, size_t ind)
/* compute message size and add 0x0a 0x0d */
for (ind=0; nmeastring [ind] != '\0'; ind ++) {
if (ind >= sizeof(message) - 3) {
fprintf(stderr, "gps2udp: too big [%s] \n", nmeastring);
(void)fprintf(stderr, "gps2udp: too big [%s] \n", nmeastring);
return -1;
}
message[ind] = nmeastring[ind];
Expand Down Expand Up @@ -157,14 +157,14 @@ static int open_udp(char **hostport)

sock[channel]= socket(AF_INET, SOCK_DGRAM, 0);
if (sock[channel] < 0) {
fprintf(stderr, "gps2udp: error creating UDP socket\n");
(void)fprintf(stderr, "gps2udp: error creating UDP socket\n");
return (-1);
}

remote[channel].sin_family = (sa_family_t)AF_INET;
hp = gethostbyname(hostname);
if (hp==NULL) {
fprintf(stderr, "gps2udp: syntax is [-u hostname:port] [%s] is not a valid hostname\n",hostname);
(void)fprintf(stderr, "gps2udp: syntax is [-u hostname:port] [%s] is not a valid hostname\n",hostname);
return (-1);
}

Expand Down Expand Up @@ -476,7 +476,7 @@ int main(int argc, char **argv)
(void)fprintf(stdout," MMSI=%9u", mmsi);

}
fprintf(stdout,"\n");
(void)fprintf(stdout,"\n");
}

// send to all UDP destinations
Expand All @@ -496,7 +496,7 @@ int main(int argc, char **argv)
} // end for (;;)

// This is an infinite loop, should never be here
fprintf (stderr, "gpsd2udp ERROR abnormal exit\n");
(void)fprintf (stderr, "gpsd2udp ERROR abnormal exit\n");
exit (-1);
}

Expand Down
2 changes: 1 addition & 1 deletion gpsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS);
case 'h':
default:
fprintf(stderr, USAGE);
(void)fprintf(stderr, USAGE);
break;
}
}
Expand Down
14 changes: 7 additions & 7 deletions gpspipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ static void open_serial(char *device)
* tty.
*/
if ((fd_out = open(device, O_RDWR | O_NOCTTY)) == -1) {
fprintf(stderr, "gpspipe: error opening serial port\n");
(void)fprintf(stderr, "gpspipe: error opening serial port\n");
exit(EXIT_FAILURE);
}

/* Save current serial port settings for later */
if (tcgetattr(fd_out, &oldtio) != 0) {
fprintf(stderr, "gpspipe: error reading serial port settings\n");
(void)fprintf(stderr, "gpspipe: error reading serial port settings\n");
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -362,17 +362,17 @@ int main(int argc, char **argv)
}
}
if (fputc(c, fp) == EOF) {
fprintf(stderr, "gpspipe: write error, %s(%d)\n",
strerror(errno), errno);
(void)fprintf(stderr, "gpspipe: write error, %s(%d)\n",
strerror(errno), errno);
exit(EXIT_FAILURE);
}

if (c == '\n') {
if (serialport != NULL) {
if (write(fd_out, serbuf, (size_t) j) == -1) {
fprintf(stderr,
"gpspipe: serial port write error, %s(%d)\n",
strerror(errno), errno);
(void)fprintf(stderr,
"gpspipe: serial port write error, %s(%d)\n",
strerror(errno), errno);
exit(EXIT_FAILURE);
}
j = 0;
Expand Down
14 changes: 7 additions & 7 deletions gpxlogger.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ static void quit_handler(int signum)

static void usage(void)
{
fprintf(stderr,
"Usage: %s [-V] [-h] [-d] [-i timeout] [-f filename] [-m minmove]\n"
"\t[-r] [-e exportmethod] [server[:port:[device]]]\n\n"
"defaults to '%s -i 5 -e %s localhost:2947'\n",
progname, progname, export_default()->name);
(void)fprintf(stderr,
"Usage: %s [-V] [-h] [-d] [-i timeout] [-f filename] [-m minmove]\n"
"\t[-r] [-e exportmethod] [server[:port:[device]]]\n\n"
"defaults to '%s -i 5 -e %s localhost:2947'\n",
progname, progname, export_default()->name);
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -263,8 +263,8 @@ int main(int argc, char **argv)
if (timeout < 1)
timeout = 1;
if (timeout >= 3600)
fprintf(stderr,
"WARNING: track timeout is an hour or more!\n");
(void)fprintf(stderr,
"WARNING: track timeout is an hour or more!\n");
break;
case 'l':
export_list(stderr);
Expand Down
2 changes: 1 addition & 1 deletion lcdgps.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ int main(int argc, char *argv[])

for (;;) { /* heart of the client */
if (!gps_waiting(&gpsdata, 50000000)) {
fprintf( stderr, "lcdgps: error while waiting\n");
(void)fprintf( stderr, "lcdgps: error while waiting\n");
exit(EXIT_FAILURE);
} else {
(void)gps_read(&gpsdata);
Expand Down
2 changes: 1 addition & 1 deletion libgps_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int gps_open(const char *host,
#endif /* SOCKET_EXPORT_ENABLE */

#ifndef USES_HOST
fprintf(stderr, "No methods available for connnecting to %s!\n", host);
(void)fprintf(stderr, "No methods available for connnecting to %s!\n", host);
#endif /* USES_HOST */
#undef USES_HOST

Expand Down
14 changes: 7 additions & 7 deletions ntpshmmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char **argv)
argv[0], VERSION, REVISION);
exit(EXIT_SUCCESS);
case 'h':
fprintf(stderr,
(void)fprintf(stderr,
"usage: ntpshmmon [-s] [-n max] [-t timeout] [-v] [-h] [-V]\n"
" -h print this help\n"
" -n nsamples exit after nsamples\n"
Expand All @@ -77,7 +77,7 @@ int main(int argc, char **argv)
for (i = 0; i < NTPSEGMENTS; i++) {
segments[i] = shm_get(i, false, true);
if (verbose && segments[i] != NULL)
fprintf(stderr, "unit %d opened\n", i);
(void)fprintf(stderr, "unit %d opened\n", i);
}

if (killall) {
Expand Down Expand Up @@ -108,7 +108,7 @@ int main(int argc, char **argv)
long long diff; /* 32 bit long is too short for a timespec */
enum segstat_t status = ntp_read(segments[i], &shm_stat, false);
if (verbose)
fprintf(stderr, "unit %d status %d\n", i, status);
(void)fprintf(stderr, "unit %d status %d\n", i, status);
switch(status) {
case OK:
/* ntpd can slew the clock at 120% real time
Expand Down Expand Up @@ -144,15 +144,15 @@ int main(int argc, char **argv)
/* do nothing, data not ready, wait another cycle */
break;
case BAD_MODE:
fprintf(stderr, "ntpshmmon: unknown mode %d on segment %s\n",
shm_stat.status, ntp_name(i));
(void)fprintf(stderr, "ntpshmmon: unknown mode %d on segment %s\n",
shm_stat.status, ntp_name(i));
break;
case CLASH:
/* do nothing, data is corrupt, wait another cycle */
break;
default:
fprintf(stderr, "ntpshmmon: unknown status %d on segment %s\n",
status, ntp_name(i));
(void)fprintf(stderr, "ntpshmmon: unknown status %d on segment %s\n",
status, ntp_name(i));
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions ppscheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ static const struct assoc hlines[] = {

static void usage(void)
{
fprintf(stderr, "usage: ppscheck [-h] [ -V] <device>\n");
fprintf(stderr, " -h print usage\n");
fprintf(stderr, " -V print cwVersion\n");
(void)fprintf(stderr, "usage: ppscheck [-h] [ -V] <device>\n");
(void)fprintf(stderr, " -h print usage\n");
(void)fprintf(stderr, " -V print cwVersion\n");
exit(1);
}

Expand Down
10 changes: 5 additions & 5 deletions test_geoid.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ int main(int argc, char **argv)
double lat, lon;

if (argc != 3) {
fprintf(stderr, "Usage: %s lat lon\n", argv[0]);
(void)fprintf(stderr, "Usage: %s lat lon\n", argv[0]);
return 1;
}

lat = atof(argv[1]);
lon = atof(argv[2]);

if (lon > 180.0 || lat < -180.0) {
fprintf(stderr, " -180 <= lon=%s(%.f) <= 180 ?\n", argv[2], lon);
(void)fprintf(stderr, " -180 <= lon=%s(%.f) <= 180 ?\n", argv[2], lon);
return 1;
}

if (lat > 90.0 || lat < -90.0) {
fprintf(stderr, " -90 <= lat=%s(%.f) <= 90 ?\n", argv[1], lat);
(void)fprintf(stderr, " -90 <= lat=%s(%.f) <= 90 ?\n", argv[1], lat);
return 1;
}

printf(" lat= %f lon= %f geoid correction= %f\n",
lat, lon, wgs84_separation(lat, lon));
(void)printf(" lat= %f lon= %f geoid correction= %f\n",
lat, lon, wgs84_separation(lat, lon));

return 0;
}

0 comments on commit e2695bd

Please sign in to comment.