✘lfpinit() signed or unsigned?

Gary E. Miller gem at rellim.com
Thu Mar 9 02:05:22 UTC 2017


Yo All!

I was playing with the clang option -Weverything and ran into a weird one.
well, many weird ones, but this stuck out first:

In include/ntp_fp.h:

l_fp is unsigned:

typedef uint64_t l_fp;

But strangely lfpinit() takes a signed first paramter and returns
an l_fp, which is unsigned:

static inline l_fp lfpinit(int32_t hi, uint32_t lo)

Strange, but not too strange, until I saw this in ntpd/ntp_control.c:
	ts = lfpinit((uint32_t)ts_i, (uint32_t)ts_f);

And stranger still here tests/libntp/strtolfp.c:
        l_fp expected = lfpinit(-300, 0);

Clearly the test is broken as lfpinit() can never return a negative and
the test expects a negative.

I can't find any place in the code, outside of the tests, where the
first parameter to lpfpinit() did not statrt out as an unsigned.

Does lfpinit() need to return a signed?  Or should the parameters to 
lfpinit() annd be unsigned?  I'm guessing the later, but I'm new to that
part of the code...

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
	gem at rellim.com  Tel:+1 541 382 8588

	    Veritas liberabit vos. -- Quid est veritas?
    "If you can’t measure it, you can’t improve it." - Lord Kelvin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20170308/e51f4ac5/attachment.bin>


More information about the devel mailing list