gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH 1/3] Explicit marking of ignoring fprintf() result


From: Robert Norris
Subject: [gpsd-dev] [PATCH 1/3] Explicit marking of ignoring fprintf() result
Date: Mon, 20 Feb 2017 01:44:44 +0000

Ensure consistent marking of '(void)' for most normal usage of fprintf()

TESTED:
'scons build-all check' passes
---
 cgps.c            |  2 +-
 driver_nmea2000.c | 14 +++++++-------
 gps2udp.c         | 10 +++++-----
 gpsctl.c          |  2 +-
 gpspipe.c         | 14 +++++++-------
 gpxlogger.c       | 14 +++++++-------
 lcdgps.c          |  2 +-
 libgps_core.c     |  2 +-
 ntpshmmon.c       | 14 +++++++-------
 ppscheck.c        |  6 +++---
 test_geoid.c      | 10 +++++-----
 11 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/cgps.c b/cgps.c
index 56f90736..db67a487 100644
--- a/cgps.c
+++ b/cgps.c
@@ -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. */
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index 47b051b2..ee85ce17 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -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;
diff --git a/gps2udp.c b/gps2udp.c
index c02d8929..eb01eb90 100644
--- a/gps2udp.c
+++ b/gps2udp.c
@@ -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];
@@ -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);
        }
 
@@ -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
@@ -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);
 }
 
diff --git a/gpsctl.c b/gpsctl.c
index d0b75401..69d5e932 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -328,7 +328,7 @@ int main(int argc, char **argv)
            exit(EXIT_SUCCESS);
        case 'h':
        default:
-           fprintf(stderr, USAGE);
+           (void)fprintf(stderr, USAGE);
            break;
        }
     }
diff --git a/gpspipe.c b/gpspipe.c
index 680f0625..4a74b0a9 100644
--- a/gpspipe.c
+++ b/gpspipe.c
@@ -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);
     }
 
@@ -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;
diff --git a/gpxlogger.c b/gpxlogger.c
index 0448554a..e8e37169 100644
--- a/gpxlogger.c
+++ b/gpxlogger.c
@@ -185,11 +185,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);
 }
 
@@ -271,8 +271,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);
diff --git a/lcdgps.c b/lcdgps.c
index eb95f498..26ff8c90 100644
--- a/lcdgps.c
+++ b/lcdgps.c
@@ -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);
diff --git a/libgps_core.c b/libgps_core.c
index 644b96d4..54eb8c78 100644
--- a/libgps_core.c
+++ b/libgps_core.c
@@ -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
 
diff --git a/ntpshmmon.c b/ntpshmmon.c
index f8768a35..04cd8c6e 100644
--- a/ntpshmmon.c
+++ b/ntpshmmon.c
@@ -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"
@@ -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) {
@@ -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
@@ -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;
            }
        }
diff --git a/ppscheck.c b/ppscheck.c
index 21ccac08..1a6a9acc 100644
--- a/ppscheck.c
+++ b/ppscheck.c
@@ -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);
 }
 
diff --git a/test_geoid.c b/test_geoid.c
index 8f0480af..eeed567d 100644
--- a/test_geoid.c
+++ b/test_geoid.c
@@ -15,7 +15,7 @@ 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;
     }
 
@@ -23,17 +23,17 @@ int main(int argc, char **argv)
     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;
 }
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]