monitor: fix integer comparison error (clang)
James Prestwood
PATCH 1/1 monitor: fix integer comparison error (clang)
Though the documentation for NLMSG_OK uses an int type for the length the actual check is based on nlmsghdr->nlmsg_len which is a 32 bit unsigned integer. Clang was complaining about one call in nlmon.c because nlmsg_len was int type. Every other usage in nlmon.c uses a uint32_t, so use that both for consistency and to fix the warning.
monitor/nlmon.c:7998:29: error: comparison of integers of different
signs: '__u32' (aka 'unsigned int') and 'int'
[-Werror,-Wsign-compare]
for (nlmsg = iov.iov_base; NLMSG_OK(nlmsg, nlmsg_len);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/linux/netlink.h:100:24: note: expanded from macro 'NLMSG_OK'
(nlh)->nlmsg_len <= (len))
---
monitor/nlmon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)monitor/nlmon.c +1 -1
@@ -7944,7 +7944,7 @@ static bool nlmon_receive(struct l_io *io, void *user_data)unsigned char buf[8192 ];unsigned char control[32 ];ssize_t bytes_read; -int nlmsg_len; +uint32_t nlmsg_len;int fd; fd =l_io_get_fd (io);
Signature · 1 line
2.34.1
Denis Kenzior
AppliedHi James,
Quoted 7 lines · James Prestwood
Though the documentation for
NLMSG_OKuses an int type for the length the actual check is based onnlmsghdr->nlmsg_lenwhich is a 32 bit unsigned integer. Clang was complaining about one call innlmon.cbecausenlmsg_lenwas int type. Every other usage innlmon.cuses auint32_t, so use that both for consistency and to fix the warning.
monitor/nlmon.c:7998:29: error: comparison of integers of different
Quoted 10 lines
signs: '__u32' (aka 'unsigned int') and 'int'
[-Werror,-Wsign-compare]
for (nlmsg = iov.iov_base; NLMSG_OK(nlmsg, nlmsg_len);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/linux/netlink.h:100:24: note: expanded from macro 'NLMSG_OK'
(nlh)->nlmsg_len <= (len))
---
monitor/nlmon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)Applied, thanks.
Regards,
-Denis