[PATCH] netlink: fix gcc -Wconversion compilation warning

From: Kirill A . Shutemov
Date: Tue Dec 14 2010 - 05:50:39 EST


$ cat << EOF | gcc -Wconversion -xc -S -o/dev/null -
unsigned f(void) {return NLMSG_HDRLEN;}
EOF
<stdin>: In function 'f':
<stdin>:3:26: warning: negative integer implicitly converted to unsigned type

Define NLMSG_ALIGNTO as size_t, NLMSG_ALIGN always returns size_t and
drop non-sense casting in NLMSG_HDRLEN. Now NLMSG_HDRLEN returns size_t.

Signed-off-by: Dmitry V. Levin <ldv@xxxxxxxxxxxx>
Signed-off-by: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>
---
include/linux/netlink.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 1235669..db7d373 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -70,9 +70,9 @@ struct nlmsghdr {
Check NLM_F_EXCL
*/

-#define NLMSG_ALIGNTO 4
-#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
-#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
+#define NLMSG_ALIGNTO ((size_t) 4)
+#define NLMSG_ALIGN(len) ( ((size_t)(len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
+#define NLMSG_HDRLEN NLMSG_ALIGN(sizeof(struct nlmsghdr))
#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
--
Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/