Clock variables for DCF77

Achim Gratz Stromeko at nexgo.de
Mon Mar 11 20:28:17 UTC 2019


Achim Gratz via devel writes:
> I have reported that quite some time ago already, but some recent
> changes to how the system and clock variables are displayed make it much
> more prominent and clearly that there's still some bug to squash:

Found it and fixed it locally:

--8<---------------cut here---------------start------------->8---
diff --git a/ntpd/refclock_generic.c b/ntpd/refclock_generic.c
index e96af45f2..843a47a8d 100644
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -3187,13 +3187,13 @@ parse_control(
                tt = ap(start, LEN_STATES, tt,
                    "; running time: %s\"", l_mktime(sum));
 
-               add_var(&out->kv_list, 32, RO);
+               tt = add_var(&out->kv_list, 32, RO);
                snprintf(tt, 32,  "refclock_id=\"%s\"", parse->parse_type->cl_id);
 
-               add_var(&out->kv_list, 80, RO);
+               tt = add_var(&out->kv_list, 80, RO);
                snprintf(tt, 80,  "refclock_iomode=\"%s\"", parse->binding->bd_description);
 
-               add_var(&out->kv_list, 128, RO);
+               tt = add_var(&out->kv_list, 128, RO);
                snprintf(tt, 128, "refclock_driver_version=\"%s\"", VERSION);
--8<---------------cut here---------------end--------------->8---

Now, that stupidity of writing repeatedly to the same pointer without
advancing it (and thrashing the data structure as a result) was
introduced in 28687046e08eaba with the completely misleading title "More
Coverity cleanup. No logic changes.", which makes me wonder about some
other changes in that commit.  In general, I think coverity was getting
hung up on the result of ap() getting assigned to the same pointer that
it got as argument, which is actually not fixed in all places (see the
start of the diff for one instance).

That sort of cleanup should really be done as a semantic patch and
applied to the full codebase, maybe using Coccinelle.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs



More information about the devel mailing list