* [B.A.T.M.A.N.] [PATCH] batctl: Fix warning about comparing signed vs. unsigned
@ 2013-10-15 10:29 Sven Eckelmann
2013-10-15 14:01 ` Marek Lindner
0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2013-10-15 10:29 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
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>
---
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;
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batctl: Fix warning about comparing signed vs. unsigned
2013-10-15 10:29 [B.A.T.M.A.N.] [PATCH] batctl: Fix warning about comparing signed vs. unsigned Sven Eckelmann
@ 2013-10-15 14:01 ` Marek Lindner
0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2013-10-15 14:01 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
[-- Attachment #1: Type: text/plain, Size: 602 bytes --]
On Tuesday 15 October 2013 12:29:07 Sven Eckelmann wrote:
> 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>
> ---
> functions.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Applied in revision c1ffa59.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-15 14:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15 10:29 [B.A.T.M.A.N.] [PATCH] batctl: Fix warning about comparing signed vs. unsigned Sven Eckelmann
2013-10-15 14:01 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox