[Git][NTPsec/ntpsec][master] configure conditional warning flags, fix some ntpd warnings
Eric S. Raymond
gitlab at mg.gitlab.com
Sun Apr 9 19:06:32 UTC 2017
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
de96cee2 by Trevor N at 2017-04-09T14:53:52-04:00
configure conditional warning flags, fix some ntpd warnings
add compiler-support check for -Wformat-signedness and -Wsign-conversion in wafhelpers/configure.py
fix -Wformat warnings in ntpd/ntp_util.c, ntpd/refclock_pps.c
fix -Wformat warnings, add default case to diagnostic message in ntpd/refclock_trimble.c
- - - - -
4 changed files:
- ntpd/ntp_util.c
- ntpd/refclock_pps.c
- ntpd/refclock_trimble.c
- wafhelpers/configure.py
Changes:
=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -361,7 +361,7 @@ timespec_to_MJDtime(const struct timespec *time)
day = (u_long)time->tv_sec / S_PER_DAY + MJD_1970;
sec = (u_long)time->tv_sec % S_PER_DAY;
msec = (u_long)time->tv_nsec / NS_PER_MS; /* nano secs to milli sec */
- snprintf(buf, LIB_BUFLENGTH, "%lu %lu.%03ld", day, sec, msec);
+ snprintf(buf, LIB_BUFLENGTH, "%lu %lu.%03lu", day, sec, msec);
return buf;
}
@@ -397,7 +397,7 @@ record_peer_stats(
fprintf(peerstats.fp,
"%s %s %x %.9f %.9f %.9f %.9f\n",
timespec_to_MJDtime(&now),
- socktoa(&peer->srcadr), status, peer->offset,
+ socktoa(&peer->srcadr), (u_int)status, peer->offset,
peer->delay, peer->disp, peer->jitter);
fflush(peerstats.fp);
}
@@ -544,7 +544,7 @@ record_raw_stats(
clock_gettime(CLOCK_REALTIME, &now);
filegen_setup(&rawstats, now.tv_sec);
if (rawstats.fp != NULL) {
- fprintf(rawstats.fp, "%s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s %d\n",
+ fprintf(rawstats.fp, "%s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s %u\n",
timespec_to_MJDtime(&now),
socktoa(srcadr), dstadr ? socktoa(dstadr) : "-",
ulfptoa(*t1, 9), ulfptoa(*t2, 9),
@@ -631,7 +631,7 @@ void record_use_stats(void)
stime /= 1E6;
stime += usage.ru_stime.tv_sec - oldusage.ru_stime.tv_sec;
fprintf(usestats.fp,
- "%s %lu %.3f %.3f %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+ "%s %lu %.3f %.3f %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
timespec_to_MJDtime(&now), current_time - use_stattime,
utime, stime,
usage.ru_minflt - oldusage.ru_minflt,
=====================================
ntpd/refclock_pps.c
=====================================
--- a/ntpd/refclock_pps.c
+++ b/ntpd/refclock_pps.c
@@ -256,7 +256,7 @@ pps_poll(
pp->polls++;
mprintf_clock_stats(peer,
- "%ld %d %d %d %d",
+ "%lu %d %d %d %d",
up->ppsctl.sequence,
up->pcount, up->scount, up->kcount, up->rcount);
up->pcount = up->scount = up->kcount = up->rcount = 0;
=====================================
ntpd/refclock_trimble.c
=====================================
--- a/ntpd/refclock_trimble.c
+++ b/ntpd/refclock_trimble.c
@@ -655,7 +655,7 @@ TSIP_decode (
#ifdef DEBUG
if (debug > 1)
printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d UTC %02d\n",
- up->unit, mb(0) & 0xff, event, pp->hour, pp->minute,
+ up->unit, (u_int)(mb(0) & 0xff), event, pp->hour, pp->minute,
pp->second, pp->nsec, mb(12), mb(11), pp->year, GPS_UTC_Offset);
#endif
/* Only use this packet when no
@@ -735,9 +735,9 @@ TSIP_decode (
#ifdef DEBUG
if (debug > 1)
printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d UTC %02x %s\n",
- up->unit, mb(0) & 0xff, event, pp->hour, pp->minute,
+ up->unit, (u_int)(mb(0) & 0xff), event, pp->hour, pp->minute,
pp->second, pp->nsec, mb(15), mb(14), pp->year,
- mb(19), *Tracking_Status[st]);
+ (u_int)mb(19), *Tracking_Status[st]);
#endif
return 1;
break;
@@ -771,7 +771,7 @@ TSIP_decode (
#ifdef DEBUG
if (debug > 1)
printf("TSIP_decode: unit %d: 0x%02x leap %d\n",
- up->unit, mb(0) & 0xff, pp->leap);
+ up->unit, (u_int)(mb(0) & 0xff), pp->leap);
if (debug > 1) {
printf("Receiver MODE: 0x%02X\n", (uint8_t)mb(1));
if (mb(1) == 0x00)
@@ -839,7 +839,7 @@ TSIP_decode (
pp->nsec = 0;
#ifdef DEBUG
printf("\nTiming Flags are:\n");
- printf("Timing flag value is: 0x%X\n", mb(9));
+ printf("Timing flag value is: 0x%X\n", (u_int)mb(9));
if ((mb(9) & 0x01) != 0)
printf (" Getting UTC time\n");
else
@@ -880,7 +880,9 @@ TSIP_decode (
#ifdef DEBUG
if (debug > 1)
- printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d ",up->unit, mb(0) & 0xff, event, pp->hour, pp->minute, pp->second, pp->nsec, mb(14), mb(13), pp->year);
+ printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d ",
+ up->unit, (u_int)(mb(0) & 0xff), event,
+ pp->hour, pp->minute, pp->second, pp->nsec, mb(14), mb(13), pp->year);
#endif
return 1;
break;
@@ -942,6 +944,8 @@ TSIP_decode (
case 0x0C:
printf("The Chosen satellite is unusable\n");
break;
+ default:
+ printf("(Status code is invalid)\n");
}
#endif
/* Error Codes */
@@ -994,7 +998,7 @@ TSIP_decode (
up->polled = -1;
#ifdef DEBUG
printf("TSIP_decode: unit %d: bad packet %02x-%02x event %d len %d\n",
- up->unit, up->rpt_buf[0] & 0xff, mb(0) & 0xff,
+ up->unit, (u_int)(up->rpt_buf[0] & 0xff), (u_int)(mb(0) & 0xff),
event, (int)up->rpt_cnt);
#endif
return 0;
=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -292,7 +292,6 @@ def cmd_configure(ctx, config):
"-Wformat",
"-Wformat-nonliteral", # needs -Wformat
"-Wformat-security", # needs -Wformat
- "-Wformat-signedness", # needs =Wformat
"-Wimplicit-function-declaration",
"-Winit-self",
"-Winline",
@@ -306,13 +305,15 @@ def cmd_configure(ctx, config):
"-Wpointer-arith",
# "-Wredundant-decls", # incompatible w/ Unity
"-Wshadow",
- "-Wsign-conversion", # fails on Solaris and OpenBSD 6
"-Wsuggest-attribute=noreturn",
"-Wsuggest-attribute=pure",
"-Wswitch-default",
"-Wwrite-strings",
-
]
+ cc_test_flags += [
+ ('w_format_signedness', '-Wformat-signedness'), # fails on OpenBSD 6
+ ('w_sign_conversion', "-Wsign-conversion"), # fails on Solaris and OpenBSD 6
+ ]
ctx.env.CFLAGS += [
# -O1 will turn on -D_FORTIFY_SOURCE=2 for us
@@ -386,6 +387,16 @@ int main(int argc, char **argv) {
"-flto",
]
+ # debug warnings that are not available with all compilers
+ if ctx.env.HAS_w_format_signedness:
+ ctx.env.CFLAGS += [
+ '-Wformat-signedness',
+ ]
+ if ctx.env.HAS_w_sign_conversion:
+ ctx.env.CFLAGS += [
+ '-Wsign-conversion',
+ ]
+
# old gcc takes -z,relro, but then barfs if -fPIE available and used.
# ("relro", "-Wl,-z,relro"), # marks some sections read only
old_run_build_cls = ctx.run_build_cls
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/de96cee2e2369a2dd1244d89fea992d90deab46a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170409/d96d45c8/attachment.html>
More information about the vc
mailing list