[Git][NTPsec/ntpsec][master] Address GitLab issue #294: compiler warning (gcc 7.0.1): refclock_neoclock

Eric S. Raymond gitlab at mg.gitlab.com
Sun May 7 15:24:13 UTC 2017


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
036db9df by Eric S. Raymond at 2017-05-07T11:22:41-04:00
Address GitLab issue #294: compiler warning (gcc 7.0.1): refclock_neoclock

Harden the code against changes in unit block member sizes. This
should suppress some warnings.

- - - - -


1 changed file:

- ntpd/refclock_neoclock.c


Changes:

=====================================
ntpd/refclock_neoclock.c
=====================================
--- a/ntpd/refclock_neoclock.c
+++ b/ntpd/refclock_neoclock.c
@@ -667,12 +667,19 @@ neoclock4x_control(int unit,
       tt = add_var(&out->kv_list, sizeof(tmpbuf)-1, RO|DEF);
       snprintf(tt, sizeof(tmpbuf)-1, "calc_utc=\"%s\"", tmpbuf);
 
-      tt = add_var(&out->kv_list, 40, RO|DEF);
-      snprintf(tt, 39, "radiosignal=\"%s\"", up->radiosignal);
-      tt = add_var(&out->kv_list, 40, RO|DEF);
-      snprintf(tt, 39, "antenna1=\"%d\"", up->antenna1);
-      tt = add_var(&out->kv_list, 40, RO|DEF);
-      snprintf(tt, 39, "antenna2=\"%d\"", up->antenna2);
+#define MAXINTSIZE	20	/* max % of decimal digits in integer */
+#define S_RADIOSIGNAL	sizeof(up->radiosignal) + 15
+      tt = add_var(&out->kv_list, S_RADIOSIGNAL+1, RO|DEF);
+      snprintf(tt, S_RADIOSIGNAL, "radiosignal=\"%s\"", up->radiosignal);
+#undef S_RADIOSIGNAL 
+#define S_ANTENNA1	MAXINTSIZE + 12
+      tt = add_var(&out->kv_list, S_ANTENNA1+1, RO|DEF);
+      snprintf(tt, S_ANTENNA1, "antenna1=\"%d\"", up->antenna1);
+#undef S_ANTENNA1
+#define S_ANTENNA2	MAXINTSIZE + 12
+      tt = add_var(&out->kv_list, S_ANTENNA2+1, RO|DEF);
+      snprintf(tt, S_ANTENNA2, "antenna2=\"%d\"", up->antenna2);
+#undef S_ANTENNA2
       tt = add_var(&out->kv_list, 40, RO|DEF);
       if('A' == up->timesource)
 	snprintf(tt, 39, "timesource=\"radio\"");
@@ -694,14 +701,21 @@ neoclock4x_control(int unit,
         snprintf(tt, 39, "dststatus=\"winter\"");
       else
         snprintf(tt, 39, "dststatus=\"unknown\"");
-      tt = add_var(&out->kv_list, 80, RO|DEF);
-      snprintf(tt, 79, "firmware=\"%s\"", up->firmware);
-      tt = add_var(&out->kv_list, 40, RO|DEF);
-      snprintf(tt, 39, "firmwaretag=\"%c\"", up->firmwaretag);
+#define S_FIRMWARE	sizeof(up->firmware) + 13 
+      tt = add_var(&out->kv_list, S_FIRMWARE+1, RO|DEF);
+      snprintf(tt, S_FIRMWARE, "firmware=\"%s\"", up->firmware);
+#undef S_FIRMWARE
+#define S_FIRMWARETAG	sizeof(up->firmware) + 15 
+      tt = add_var(&out->kv_list, S_FIRMWARETAG+1, RO|DEF);
+      snprintf(tt, S_FIRMWARETAG, "firmwaretag=\"%c\"", up->firmwaretag);
+#undef S_FIRMWARETAG
       tt = add_var(&out->kv_list, 80, RO|DEF);
       snprintf(tt, 79, "driver version=\"%s\"", NEOCLOCK4X_DRIVER_VERSION);
-      tt = add_var(&out->kv_list, 80, RO|DEF);
-      snprintf(tt, 79, "serialnumber=\"%s\"", up->serial);
+#define S_SERIAL	sizeof(up->serial) + 16
+      tt = add_var(&out->kv_list, S_SERIAL+1, RO|DEF);
+      snprintf(tt, S_SERIAL, "serialnumber=\"%s\"", up->serial);
+#undef S_SERIAL
+#undef MAXINTSIZE
     }
 }
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/036db9dfadec2be211d1d699668cb1088b2a7926

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/036db9dfadec2be211d1d699668cb1088b2a7926
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170507/f2f755ea/attachment.html>


More information about the vc mailing list