[PATCH] netlink: Remove extra brackets of nla_for_each_attr()

Subsystems: networking [general], the rest

STALE1782d

2 messages, 2 authors, 2021-09-16 · open the first message on its own page

[PATCH] netlink: Remove extra brackets of nla_for_each_attr()

From: Jiasheng Jiang <hidden>
Date: 2021-09-16 02:07:40

It's obvious that '&(rem)' has unneeded brackets.
Therefore it's better to remove them.

Signed-off-by: Jiasheng Jiang <redacted>
---
 include/net/netlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 1ceec51..5822e0d 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -1920,7 +1920,7 @@ static inline int nla_total_size_64bit(int payload)
 #define nla_for_each_attr(pos, head, len, rem) \
 	for (pos = head, rem = len; \
 	     nla_ok(pos, rem); \
-	     pos = nla_next(pos, &(rem)))
+	     pos = nla_next(pos, &rem))
 
 /**
  * nla_for_each_nested - iterate over nested attributes
-- 
2.7.4

Re: [PATCH] netlink: Remove extra brackets of nla_for_each_attr()

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2021-09-16 02:50:40

On Thu, 16 Sep 2021 02:07:08 +0000
Jiasheng Jiang [off-list ref] wrote:
quoted hunk
It's obvious that '&(rem)' has unneeded brackets.
Therefore it's better to remove them.

Signed-off-by: Jiasheng Jiang <redacted>
---
 include/net/netlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 1ceec51..5822e0d 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -1920,7 +1920,7 @@ static inline int nla_total_size_64bit(int payload)
 #define nla_for_each_attr(pos, head, len, rem) \
 	for (pos = head, rem = len; \
 	     nla_ok(pos, rem); \
-	     pos = nla_next(pos, &(rem)))
+	     pos = nla_next(pos, &rem))
 
 /**
  * nla_for_each_nested - iterate over nested attributes
No.

nla_for_each_attr is a macro and in a macro, there should be
added parenthesis around any use of macro argument to prevent
unintended side effects.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help