Repository : ssh://git@open-mesh.org/batctl
On branch : next
commit c1ffa59fe0b5415b1d7353689dcc30b4ac6f68ad Author: Sven Eckelmann sven@open-mesh.com Date: Tue Oct 15 12:29:07 2013 +0200
batctl: Fix warning about comparing signed vs. unsigned
The macros NLMSG_OK and NLMSG_NEXT operate on the parameter len as if it would be a variable from the type size_t. Using ssize_t (signed size_t) can cause warnings about comparing a signed with an unsigned variable.
It is ok to store the signed len variable in an unsigned variable because an check is used to stop processing when it was negative.
Signed-off-by: Sven Eckelmann sven@open-mesh.com Signed-off-by: Marek Lindner mareklindner@neomailbox.ch
c1ffa59fe0b5415b1d7353689dcc30b4ac6f68ad functions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/functions.c b/functions.c index d8d86ce..9e03e72 100644 --- a/functions.c +++ b/functions.c @@ -637,7 +637,7 @@ static struct ether_addr *resolve_mac_from_cache(int ai_family, size_t buflen; struct nlmsghdr *nh; ssize_t len; - size_t l3_len; + size_t l3_len, mlen; int socknl; int parsed; int finished = 0; @@ -667,8 +667,9 @@ static struct ether_addr *resolve_mac_from_cache(int ai_family, len = resolve_mac_from_cache_dump(socknl, &buf, &buflen); if (len < 0) goto err_sock; + mlen = len;
- for (nh = buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len)) { + for (nh = buf; NLMSG_OK(nh, mlen); nh = NLMSG_NEXT(nh, mlen)) { if (nh->nlmsg_type == NLMSG_DONE) { finished = 1; break;