summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Chyla <zbigniew.chyla@nsn.com>2015-02-16 01:30:08 +0100
committerEric S. Raymond <esr@thyrsus.com>2015-02-15 22:04:33 -0500
commit49fe1997713deac3440fbb2c960305762eb500f6 (patch)
treef78e265809be7e52b6f82893e830c76af46700f8
parent68eaa6fc71f4d03b8d6fc3361569ba0906ee394d (diff)
downloadgpsd-49fe1997713deac3440fbb2c960305762eb500f6.tar.gz
Remove unused and incorrect retval from timespec_str
All callers ignore value returned by timespec_str. Additionally, the function returns simply the result of snprintf(), which is not necessarily the number of chars written to the buffer (if the buffer provided by the caller was too small).
-rw-r--r--gpsd.h-tail2
-rw-r--r--gpsd_json.c2
-rw-r--r--gpsutils.c8
-rw-r--r--monitor_nmea.c2
-rw-r--r--monitor_sirf.c2
-rw-r--r--monitor_ubx.c2
-rw-r--r--ntpshm.c8
-rw-r--r--ppsthread.c14
8 files changed, 18 insertions, 22 deletions
diff --git a/gpsd.h-tail b/gpsd.h-tail
index 4f6ea32e..99624789 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -958,7 +958,7 @@ extern void pps_early_init(struct gps_context_t *);
TS_NORM( r ); \
} while (0)
-extern int timespec_str(const struct timespec *, /*@out@*/char *, int);
+extern void timespec_str(const struct timespec *, /*@out@*/char *, int);
#define TIMESPEC_LEN 22 /* required length of a timespec buffer */
extern void pps_thread_stash_fixtime(struct gps_device_t *,
diff --git a/gpsd_json.c b/gpsd_json.c
index 3db846f5..db478dbf 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -191,7 +191,7 @@ void json_tpv_dump(const struct gps_device_t *session,
/* you can not use a double here as you will lose 11 bits
* of precision */
struct timespec clock_tmp = session->ppslast.clock;
- (void)timespec_str( &clock_tmp, ts_str, sizeof(ts_str) );
+ timespec_str( &clock_tmp, ts_str, sizeof(ts_str) );
str_appendf(reply, replylen, "\"pps\":%s,", ts_str);
}
/*@+type +formattype@*/
diff --git a/gpsutils.c b/gpsutils.c
index d4002bdd..fa15bc49 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -487,8 +487,6 @@ double earth_distance(double lat1, double lon1, double lat2, double lon2)
/* Convert a normailized timespec to a nice string
* put in it *buf, buf should be at least 22 bytes
- * return negative for error
- * otherwise the number of chars in buf, excluding trailing \0
*
* the returned buffer will look like, shortest case:
* sign character ' ' or '-'
@@ -502,19 +500,17 @@ double earth_distance(double lat1, double lon1, double lat2, double lon2)
* So 21 digits like this: "-2147483647.123456789"
*
*/
-int timespec_str(const struct timespec *ts, /*@out@*/char *buf, int buf_size)
+void timespec_str(const struct timespec *ts, /*@out@*/char *buf, int buf_size)
{
- int ret;
char sign = ' ';
/*@-type@*//* splint is confused about timespec*/
if ( (0 > ts->tv_nsec ) || ( 0 > ts->tv_sec ) ) {
sign = '-';
}
- ret = snprintf( buf, buf_size, "%c%ld.%09ld",
+ (void) snprintf( buf, buf_size, "%c%ld.%09ld",
sign,
(long)labs(ts->tv_sec),
(long)labs(ts->tv_nsec));
/*@+type@*/
- return ret;
}
diff --git a/monitor_nmea.c b/monitor_nmea.c
index 8718a670..612fc65b 100644
--- a/monitor_nmea.c
+++ b/monitor_nmea.c
@@ -336,7 +336,7 @@ static void nmea_update(void)
(void)mvwprintw(gpgsawin, 4, 6, "> 1 day");
} else {
char buf[TIMESPEC_LEN];
- (void)timespec_str( &timedelta, buf, sizeof(buf) );
+ timespec_str( &timedelta, buf, sizeof(buf) );
(void)mvwprintw(gpgsawin, 4, 6, "%s", buf);
}
(void)wnoutrefresh(gpgsawin);
diff --git a/monitor_sirf.c b/monitor_sirf.c
index e158b511..bf76c955 100644
--- a/monitor_sirf.c
+++ b/monitor_sirf.c
@@ -600,7 +600,7 @@ static void sirf_update(void)
(void)mvwprintw(mid7win, 2, 28, "> 1 day");
} else {
char buf2[TIMESPEC_LEN];
- (void)timespec_str( &timedelta, buf2, sizeof(buf2) );
+ timespec_str( &timedelta, buf2, sizeof(buf2) );
(void)mvwprintw(mid7win, 2, 32, "%s", buf2);
}
(void)wnoutrefresh(mid7win);
diff --git a/monitor_ubx.c b/monitor_ubx.c
index 44ec5dd0..c0cfab3f 100644
--- a/monitor_ubx.c
+++ b/monitor_ubx.c
@@ -267,7 +267,7 @@ static void ubx_update(void)
(void)mvwprintw(ppswin, 1, 6, "> 1 day");
} else {
char buf2[TIMESPEC_LEN];
- (void)timespec_str( &timedelta, buf2, sizeof(buf2) );
+ timespec_str( &timedelta, buf2, sizeof(buf2) );
(void)mvwprintw(ppswin, 1, 6, "%s", buf2);
}
(void)wnoutrefresh(ppswin);
diff --git a/ntpshm.c b/ntpshm.c
index e5a6b3c2..25155b7a 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -295,8 +295,8 @@ int ntpshm_put(struct gps_device_t *session, volatile struct shmTime *shmseg, st
shmTime->valid = 1;
/*@-type@*/ /* splint is confused about struct timespec */
- (void)timespec_str( &td->real, real_str, sizeof(real_str) );
- (void)timespec_str( &td->clock, clock_str, sizeof(clock_str) );
+ timespec_str( &td->real, real_str, sizeof(real_str) );
+ timespec_str( &td->clock, clock_str, sizeof(clock_str) );
gpsd_report(&session->context->errout, LOG_RAW,
"NTP ntpshm_put(%s %s) %s @ %s\n",
session->gpsdata.dev.path,
@@ -380,8 +380,8 @@ static void chrony_send(struct gps_device_t *session, struct timedrift_t *td)
/*@+type@*/
/*@-type@*/ /* splint is confused about struct timespec */
- (void)timespec_str( &td->real, real_str, sizeof(real_str) );
- (void)timespec_str( &td->clock, clock_str, sizeof(clock_str) );
+ timespec_str( &td->real, real_str, sizeof(real_str) );
+ timespec_str( &td->clock, clock_str, sizeof(clock_str) );
gpsd_report(&session->context->errout, LOG_RAW,
"PPS chrony_send %s @ %s Offset: %0.9f\n",
real_str, clock_str, sample.offset);
diff --git a/ppsthread.c b/ppsthread.c
index 0fb123df..732c73f3 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -464,8 +464,8 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
* unsigned long as a wider-or-equal type to
* accomodate Linux's type.
*/
- (void)timespec_str( &pi.assert_timestamp, ts_str1, sizeof(ts_str1) );
- (void)timespec_str( &pi.clear_timestamp, ts_str2, sizeof(ts_str2) );
+ timespec_str( &pi.assert_timestamp, ts_str1, sizeof(ts_str1) );
+ timespec_str( &pi.clear_timestamp, ts_str2, sizeof(ts_str2) );
gpsd_report(&session->context->errout, LOG_PROG,
"KPPS assert %s, sequence: %ld - "
"clear %s, sequence: %ld\n",
@@ -481,7 +481,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
that should not be the case here */
cycle_kpps = timespec_diff_ns(ts_kpps, pulse_kpps[edge_kpps])/1000;
duration_kpps = timespec_diff_ns(ts_kpps, pulse_kpps[(int)(edge_kpps == 0)])/1000;
- (void)timespec_str( &ts_kpps, ts_str1, sizeof(ts_str1) );
+ timespec_str( &ts_kpps, ts_str1, sizeof(ts_str1) );
gpsd_report(&session->context->errout, LOG_PROG,
"KPPS cycle: %7d uSec, duration: %7d uSec @ %s\n",
cycle_kpps, duration_kpps, ts_str1);
@@ -524,7 +524,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
state_last = state;
/* save this edge so we know next cycle time */
pulse[edge] = clock_ts;
- (void)timespec_str( &clock_ts, ts_str1, sizeof(ts_str1) );
+ timespec_str( &clock_ts, ts_str1, sizeof(ts_str1) );
gpsd_report(&session->context->errout, LOG_PROG,
"PPS edge: %d, cycle: %7d uSec, duration: %7d uSec @ %s\n",
edge, cycle, duration, ts_str1);
@@ -708,8 +708,8 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
}
/*@ +unrecog @*/
/*@-type@*/ /* splint is confused about struct timespec */
- (void)timespec_str( &drift.clock, ts_str1, sizeof(ts_str1) );
- (void)timespec_str( &drift.real, ts_str2, sizeof(ts_str2) );
+ timespec_str( &drift.clock, ts_str1, sizeof(ts_str1) );
+ timespec_str( &drift.real, ts_str2, sizeof(ts_str2) );
gpsd_report(&session->context->errout, LOG_INF,
"PPS hooks called with %.20s clock: %s real: %s\n",
log1, ts_str1, ts_str2);
@@ -717,7 +717,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
/*@+compdef@*/
}
/*@-type@*/ /* splint is confused about struct timespec */
- (void)timespec_str( &clock_ts, ts_str1, sizeof(ts_str1) );
+ timespec_str( &clock_ts, ts_str1, sizeof(ts_str1) );
gpsd_report(&session->context->errout, LOG_PROG,
"PPS edge %.20s @ %s offset %.9f\n",
log1, ts_str1, offset);