Skip to contentSkip to conversation

uapi/netfilter: Prefer ISO-friendly __typeof__

PATCH In review Petr Vorel 2 participants 3 messages May 4, 2023 – Jul 10, 2023 netfilter

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH v2 1/1 uapi/netfilter: Prefer ISO-friendly __typeof__

typeof() is a GNU extension, UAPI requires ISO C, therefore __typeof__() should be used. Similarly to 31088f6f7906 ("uapi/linux/const.h: Prefer ISO-friendly __typeof__") use __typeof__() also in x_tables.h.

Fixes 72b2b1dd77e8 ("netfilter: xtables: replace XT_ENTRY_ITERATE macro")

---
Changes v1->v2:
* Add Kevin's Reviewed-by:
https://lore.kernel.org/lkml/[email protected]/
* Update hash to 31088f6f7906 (Kevin)
* Add Fixes: 72b2b1dd77e8 (Kevin)

 include/uapi/linux/netfilter/x_tables.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/uapi/linux/netfilter/x_tables.h +4 -4
index 796af83a963a..d4eced07f2a2 100644
@@ -172,11 +172,11 @@ struct xt_counters_info {
 
 /* pos is normally a struct ipt_entry/ip6t_entry/etc. */
 #define xt_entry_foreach(pos, ehead, esize) \
-	for ((pos) = (typeof(pos))(ehead); \
-	     (pos) < (typeof(pos))((char *)(ehead) + (esize)); \
-	     (pos) = (typeof(pos))((char *)(pos) + (pos)->next_offset))
+	for ((pos) = (__typeof__(pos))(ehead); \
+	     (pos) < (__typeof__(pos))((char *)(ehead) + (esize)); \
+	     (pos) = (__typeof__(pos))((char *)(pos) + (pos)->next_offset))
 
-/* can only be xt_entry_match, so no use of typeof here */
+/* can only be xt_entry_match, so no use of __typeof__ here */
 #define xt_ematch_foreach(pos, entry) \
 	for ((pos) = (struct xt_entry_match *)entry->elems; \
 	     (pos) < (struct xt_entry_match *)((char *)(entry) + \
Signature · 1 line
2.40.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Petr Vorel

typeof() is a GNU extension, UAPI requires ISO C, therefore __typeof__() should be used. Similarly to 31088f6f7906 ("uapi/linux/const.h: Prefer ISO-friendly __typeof__") use __typeof__() also in x_tables.h.

Fixes 72b2b1dd77e8 ("netfilter: xtables: replace XT_ENTRY_ITERATE macro")
Quoted 33 lines

---
Changes v1->v2:
* Add Kevin's Reviewed-by:
https://lore.kernel.org/lkml/[email protected]/
* Update hash to 31088f6f7906 (Kevin)
* Add Fixes: 72b2b1dd77e8 (Kevin)

 include/uapi/linux/netfilter/x_tables.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/uapi/linux/netfilter/x_tables.h +4 -5
index 796af83a963a..d4eced07f2a2 100644
@@ -172,11 +172,11 @@ struct xt_counters_info {
 
 /* pos is normally a struct ipt_entry/ip6t_entry/etc. */
 #define xt_entry_foreach(pos, ehead, esize) \
-       for ((pos) = (typeof(pos))(ehead); \
-            (pos) < (typeof(pos))((char *)(ehead) + (esize)); \
-            (pos) = (typeof(pos))((char *)(pos) + (pos)->next_offset))
+       for ((pos) = (__typeof__(pos))(ehead); \
+            (pos) < (__typeof__(pos))((char *)(ehead) + (esize)); \
+            (pos) = (__typeof__(pos))((char *)(pos) + (pos)->next_offset))
 
-/* can only be xt_entry_match, so no use of typeof here */
+/* can only be xt_entry_match, so no use of __typeof__ here */
 #define xt_ematch_foreach(pos, entry) \
        for ((pos) = (struct xt_entry_match *)entry->elems; \
             (pos) < (struct xt_entry_match *)((char *)(entry) + \
--

2.40.0

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#2 lore raw
Quoted 6 lines · Petr Vorel
Quoted 4 lines

typeof() is a GNU extension, UAPI requires ISO C, therefore __typeof__() should be used. Similarly to 31088f6f7906 ("uapi/linux/const.h: Prefer ISO-friendly __typeof__") use __typeof__() also in x_tables.h.

Quoted 6 lines
Quoted 3 lines
Fixes 72b2b1dd77e8 ("netfilter: xtables: replace XT_ENTRY_ITERATE macro")

Hi Andrew,

gently ping, could you please merge this to next tree? Or do we need to wait to next merge window?

Kind regards,
Petr

Quoted 32 lines
Quoted 32 lines

---
Changes v1->v2:
* Add Kevin's Reviewed-by:
https://lore.kernel.org/lkml/[email protected]/
* Update hash to 31088f6f7906 (Kevin)
* Add Fixes: 72b2b1dd77e8 (Kevin)

 include/uapi/linux/netfilter/x_tables.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/uapi/linux/netfilter/x_tables.h +4 -5
index 796af83a963a..d4eced07f2a2 100644
@@ -172,11 +172,11 @@ struct xt_counters_info {
 
 /* pos is normally a struct ipt_entry/ip6t_entry/etc. */
 #define xt_entry_foreach(pos, ehead, esize) \
-       for ((pos) = (typeof(pos))(ehead); \
-            (pos) < (typeof(pos))((char *)(ehead) + (esize)); \
-            (pos) = (typeof(pos))((char *)(pos) + (pos)->next_offset))
+       for ((pos) = (__typeof__(pos))(ehead); \
+            (pos) < (__typeof__(pos))((char *)(ehead) + (esize)); \
+            (pos) = (__typeof__(pos))((char *)(pos) + (pos)->next_offset))
 
-/* can only be xt_entry_match, so no use of typeof here */
+/* can only be xt_entry_match, so no use of __typeof__ here */
 #define xt_ematch_foreach(pos, entry) \
        for ((pos) = (struct xt_entry_match *)entry->elems; \
             (pos) < (struct xt_entry_match *)((char *)(entry) + \
--

2.40.0