[Git][NTPsec/ntpsec][master] Silence warning about sign comparison on some Linux distributions

Gary E. Miller gitlab at mg.gitlab.com
Wed Dec 28 01:58:29 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
a2d48b2a by Matt Selsky at 2016-12-27T17:57:12-08:00
Silence warning about sign comparison on some Linux distributions

../../ntpd/ntp_io.c:3295:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

We know that cnt is non-negative at this point and it should be safe to cast to
unsigned.

https://bugs.webkit.org/show_bug.cgi?id=102061 took a similar approach in the
WebKit codebase.

Signed-off-by: Gary E. Miller <gem at rellim.com>

- - - - -


1 changed file:

- ntpd/ntp_io.c


Changes:

=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3292,7 +3292,8 @@ process_routing_msgs(struct asyncio_reader *reader)
 	 */
 #ifdef HAVE_LINUX_RTNETLINK_H
 	for (nh = (struct nlmsghdr *)buffer;
-	     NLMSG_OK(nh, cnt);
+	     /* Avoid a sign comparison warning on some Linux distributions */
+	     NLMSG_OK(nh, (unsigned) cnt);
 	     nh = NLMSG_NEXT(nh, cnt)) {
 		msg_type = nh->nlmsg_type;
 #else



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


More information about the vc mailing list