Skip to contentSkip to conversation

uapi/netfilter: Prefer ISO-friendly __typeof__

PATCH Superseded Petr Vorel 2 participants 3 messages Apr 16, 2023 – Apr 24, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

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

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

---
Based on [1] merged into linux-next as b4bd35a19df5. There should be the same Fixes: which we agree in discussion in [1] (likely a79ff731a1b2, or d6fc9fcbaa65).

Kind regards,
Petr

[1] https://lore.kernel.org/lkml/[email protected]/

 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 v1 1/1
#1 lore raw
Quoted 3 lines · Petr Vorel

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

Thanks for finishing up the work!

Minor thing, the hash for my commit in -next seems to be 31088f6f7906 at the moment. As to the Fixes: tag, it looks like it should be (assuming that commit already exported the macro):

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

Aside from that, looks good to me, so:

Kevin

Quoted 35 lines

---
Based on [1] merged into linux-next as b4bd35a19df5. There should be the same Fixes: which we agree in discussion in [1] (likely a79ff731a1b2, or d6fc9fcbaa65).

Kind regards,
Petr

[1] https://lore.kernel.org/lkml/[email protected]/

 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) + \
author
#2 lore raw
Quoted 7 lines · Petr Vorel
Quoted 3 lines

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

Thanks for finishing up the work!

Quoted 7 lines

Minor thing, the hash for my commit in -next seems to be 31088f6f7906 at the moment. As to the Fixes: tag, it looks like it should be (assuming that commit already exported the macro):

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

Aside from that, looks good to me, so:

Thank you!

Andrew, I'll just wait for others to comment and then I'll send v2 (so that you don't need to update the work yourself).

Kind regards,
Petr

Quoted 39 lines

Kevin

Quoted 35 lines

---
Based on [1] merged into linux-next as b4bd35a19df5. There should be the same Fixes: which we agree in discussion in [1] (likely a79ff731a1b2, or d6fc9fcbaa65).

Kind regards,
Petr

[1] https://lore.kernel.org/lkml/[email protected]/

 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) + \