From 240bb31fc01efd6d059afcd9884b29f6814be789 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 11 Nov 2015 09:39:21 +0100 Subject: netsniff-ng: nlmsg: Explicitly cast RTA_LEN to an int It looks like the result of RTA_PAYLOAD() can be of different type depending on architecture/kernel header version/... In order to prevent warnings related to non-matching types, just explicitly cast RTA_LEN to an int, since it can't possible be larger than the unsigned short of rta_len anyhow and it is used as an in in the call to device_addr2str(). Fixes: 664dcf4217 ("netsniff-ng: nlmsg: Use correct pritnf format specifier for int") Reported-by: Vadim Kochan Signed-off-by: Tobias Klauser --- proto_nlmsg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'proto_nlmsg.c') diff --git a/proto_nlmsg.c b/proto_nlmsg.c index d3c913d..843e5cc 100644 --- a/proto_nlmsg.c +++ b/proto_nlmsg.c @@ -24,7 +24,7 @@ #define INFINITY 0xFFFFFFFFU -#define RTA_LEN(attr) RTA_PAYLOAD(attr) +#define RTA_LEN(attr) ((int)RTA_PAYLOAD(attr)) #define RTA_INT(attr) (*(int *)RTA_DATA(attr)) #define RTA_UINT(attr) (*(unsigned int *)RTA_DATA(attr)) #define RTA_UINT8(attr) (*(uint8_t *)RTA_DATA(attr)) @@ -402,7 +402,7 @@ static void rtnl_print_ifaddr(struct nlmsghdr *hdr) tprintf(", created on(%.2fs)", (double)ci->cstamp / 100); tprintf(", updated on(%.2fs))", (double)ci->cstamp / 100); - tprintf(", Len %lu\n", RTA_LEN(attr)); + tprintf(", Len %d\n", RTA_LEN(attr)); break; } } @@ -566,7 +566,7 @@ static void rtnl_print_route(struct nlmsghdr *hdr) tprintf(", id(%d)", ci->rta_id); tprintf(", ts(%d)", ci->rta_ts); tprintf(", ts age(%ds))", ci->rta_tsage); - tprintf(", Len %lu\n", RTA_LEN(attr)); + tprintf(", Len %d\n", RTA_LEN(attr)); break; } } @@ -671,7 +671,7 @@ static void rtnl_print_neigh(struct nlmsghdr *hdr) tprintf(", used(%ds)", ci->ndm_used / hz); tprintf(", updated(%ds)", ci->ndm_updated / hz); tprintf(", refcnt(%d))", ci->ndm_refcnt); - tprintf(", Len %lu\n", RTA_LEN(attr)); + tprintf(", Len %d\n", RTA_LEN(attr)); break; } } -- cgit v1.2.3-54-g00ecf