gpsd-dev
[Top][All Lists]
Advanced

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

[gpsd-dev] [PATCH] Fix compiler warnings with clang 4.2 on OS X 10.7.5


From: Beat Bolli
Subject: [gpsd-dev] [PATCH] Fix compiler warnings with clang 4.2 on OS X 10.7.5
Date: Sun, 3 Nov 2013 15:01:46 +0100

On OS X, /usr/include/sys/termios.h typedefs speed_t as unsigned long.
On Linux, it is an unsigned int. This causes printf() format string warnings.
Fix this by down-casting to an unsigned int and using "%u" as format.

Also discard a close() result.

Signed-off-by: Beat Bolli <address@hidden>
---
 driver_evermore.c | 2 +-
 driver_garmin.c   | 2 +-
 driver_sirf.c     | 6 +++---
 gpsd.c            | 4 ++--
 libgpsd_core.c    | 4 ++--
 net_ntrip.c       | 2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/driver_evermore.c b/driver_evermore.c
index 092da3a..238a82f 100644
--- a/driver_evermore.c
+++ b/driver_evermore.c
@@ -550,7 +550,7 @@ static bool evermore_speed(struct gps_device_t *session,
 {
     /*@ -type @*/
     gpsd_report(session->context->debug, LOG_PROG,
-               "evermore_speed(%u%c%d)\n", speed, parity,
+               "evermore_speed(%u%c%d)\n", (unsigned int)speed, parity,
                stopbits);
     /* parity and stopbit switching aren't available on this chip */
     if (parity != session->gpsdata.dev.parity
diff --git a/driver_garmin.c b/driver_garmin.c
index ea33320..aa5a160 100644
--- a/driver_garmin.c
+++ b/driver_garmin.c
@@ -925,7 +925,7 @@ static bool is_usb_device(const char *path UNUSED, int 
vendor, int product,
  * return 1 is device found
  * return 0 if not
  */
-static bool garmin_usb_detect(struct gps_device_t *session)
+static bool garmin_usb_detect(struct gps_device_t *session UNUSED)
 {
 #if defined(__linux__) || defined(S_SPLINT_S)
     /*
diff --git a/driver_sirf.c b/driver_sirf.c
index 646ae94..235b962 100644
--- a/driver_sirf.c
+++ b/driver_sirf.c
@@ -283,8 +283,8 @@ static bool sirfbin_speed(struct gps_device_t *session, 
speed_t speed, char pari
     };
     /*@ -charint @*/
     gpsd_report(session->context->debug, LOG_PROG,
-               "SiRF: sirf_speed(%d,%c,%d)\n",
-               speed, parity, stopbits);
+               "SiRF: sirf_speed(%u,%c,%d)\n",
+               (unsigned int)speed, parity, stopbits);
     if (9600 >= speed) {
        gpsd_report(session->context->debug, LOG_WARN,
                    "SiRF may lag at 9600bps or less.\n");
@@ -339,7 +339,7 @@ static bool sirf_to_nmea(struct gps_device_t *session, 
speed_t speed)
     if (speed >= 0xffff) {
        gpsd_report(session->context->debug, LOG_ERROR,
                    "SiRF: can't switch from SiRF to NMEA because current speed 
%u is big.",
-                    speed);
+                    (unsigned int)speed);
        return false;
     }
 
diff --git a/gpsd.c b/gpsd.c
index c657326..aa5bb97 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -993,9 +993,9 @@ static void set_serial(struct gps_device_t *device,
     }
 
     gpsd_report(context.debug, LOG_PROG,
-               "set_serial(%s,%d,%s) %c%d\n",
+               "set_serial(%s,%u,%s) %c%d\n",
                device->gpsdata.dev.path,
-               speed, modestring, parity, stopbits);
+               (unsigned int)speed, modestring, parity, stopbits);
     /* no support for other word sizes yet */
     /* *INDENT-OFF* */
     if (wordsize == (int)(9 - stopbits)
diff --git a/libgpsd_core.c b/libgpsd_core.c
index d76de68..b1f8457 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -1255,11 +1255,11 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
            /address@hidden@*/
            /* coverity[var_deref_op] */
            gpsd_report(session->context->debug, LOG_INF,
-                       "%s identified as type %s, %f sec @ %dbps\n",
+                       "%s identified as type %s, %f sec @ %ubps\n",
                        session->gpsdata.dev.path,
                        session->device_type->type_name,
                        timestamp() - session->opentime,
-                       speed);
+                       (unsigned int)speed);
            /address@hidden@*/
            /* fire the identified hook */
            if (session->device_type != NULL
diff --git a/net_ntrip.c b/net_ntrip.c
index 858a187..cd1078b 100644
--- a/net_ntrip.c
+++ b/net_ntrip.c
@@ -330,7 +330,7 @@ static int ntrip_stream_req_probe(const struct 
ntrip_stream_t *stream,
        gpsd_report(debug, LOG_ERROR, 
                    "ntrip stream write error %d on fd %d during probe request 
%zd\n",
                    errno, dsock, r);
-       (int)close(dsock);
+       (void)close(dsock);
        return -1;
     }
     /* coverity[leaked_handle] This is an intentional allocation */
-- 
1.8.4.rc3




reply via email to

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