[Git][NTPsec/ntpsec][master] Make sure NTP_API is defined before doing comparison tests

Matt Selsky gitlab at mg.gitlab.com
Tue Apr 11 14:17:46 UTC 2017


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
40c17222 by Matt Selsky at 2017-04-11T10:15:59-04:00
Make sure NTP_API is defined before doing comparison tests

Avoids these warnings:
warning: "NTP_API" is not defined [-Wundef]

- - - - -


1 changed file:

- ntptime/ntptime.c


Changes:

=====================================
ntptime/ntptime.c
=====================================
--- a/ntptime/ntptime.c
+++ b/ntptime/ntptime.c
@@ -129,13 +129,11 @@ main(
 			ntx.modes |= MOD_NANO;
 			break;
 #endif
-#ifdef NTP_API
-# if NTP_API > 3
+#if defined NTP_API && NTP_API > 3
 		case 'T':
 			ntx.modes = MOD_TAI;
 			ntx.constant = atoi(ntp_optarg);
 			break;
-# endif
 #endif
 		case 'c':
 			cost++;
@@ -210,12 +208,8 @@ main(
 #else
 "",
 #endif
-#ifdef NTP_API
-# if NTP_API > 3
+#if defined NTP_API && NTP_API > 3
 "-T tai_offset	set TAI offset\n",
-# else
-"",
-# endif
 #else
 "",
 #endif
@@ -295,7 +289,7 @@ main(
 		const char *ofmt2 = "  time %s, (.%0*d),\n";
 		const char *ofmt3 = "  maximum error %lu us, estimated error %lu us";
 		const char *ofmt4 = "  ntptime=%x.%x unixtime=%x.%0*d %s";
-#if NTP_API > 3
+#if defined NTP_API && NTP_API > 3
 		const char *ofmt5 = ", TAI offset %ld\n";
 #else
 		const char *ofmt6 = "\n";
@@ -305,7 +299,7 @@ main(
 		const char *jfmt2 = "\"time\":\"%s\",\"fractional-time\":\".%0*d\",";
 		const char *jfmt3 = "\"maximum-error\":%lu,\"estimated-error\":%lu,";
 		const char *jfmt4 = "\"raw-ntp-time\":\"%x.%x\",\"raw-unix-time\":\"%x.%0*d %s\",";
-#if NTP_API > 3
+#if defined NTP_API && NTP_API > 3
 		const char *jfmt5 = "\"TAI-offset\":%d,";
 #else
 		const char *jfmt6 = "";



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/40c17222243fe5a039ada4bc488300e1151ae8f7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170411/67716384/attachment.html>


More information about the vc mailing list