batctl: Fix warning about comparing signed vs. unsigned
PATCH 1/1 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.
--- functions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
functions.c +3 -2
@@ -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 ;
Signature · 1 line
1.8.4.rc3
Marek Lindner
AppliedQuoted 11 lines · On Tuesday 15 October 2013 12:29:07 Sven Eckelmann wrote:
The macros
NLMSG_OKandNLMSG_NEXToperate on the parameter len as if it would be a variable from the typesize_t. Usingssize_t(signedsize_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 <[email protected]>--- functions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Applied in revision c1ffa59.
Thanks,
Marek