All of lore.kernel.org
 help / color / mirror / Atom feed
* [iptables PATCH] nft: Use ARRAY_SIZE() macro in nft_strerror()
@ 2019-10-18 15:51 Phil Sutter
  2019-10-23 11:20 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Sutter @ 2019-10-18 15:51 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Variable 'table' is an array of type struct table_struct, so this is a
classical use-case for ARRAY_SIZE() macro.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables/nft.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iptables/nft.c b/iptables/nft.c
index 89b1c7a808f57..3c230c121f8b9 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -2888,7 +2888,7 @@ const char *nft_strerror(int err)
 	    { NULL, ENOENT, "No chain/target/match by that name" },
 	  };
 
-	for (i = 0; i < sizeof(table)/sizeof(struct table_struct); i++) {
+	for (i = 0; i < ARRAY_SIZE(table); i++) {
 		if ((!table[i].fn || table[i].fn == nft_fn)
 		    && table[i].err == err)
 			return table[i].message;
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-10-24 10:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18 15:51 [iptables PATCH] nft: Use ARRAY_SIZE() macro in nft_strerror() Phil Sutter
2019-10-23 11:20 ` Pablo Neira Ayuso
2019-10-23 11:23   ` Pablo Neira Ayuso
2019-10-23 12:16     ` Phil Sutter
2019-10-23 20:41       ` Pablo Neira Ayuso
2019-10-24  8:45         ` Phil Sutter
2019-10-24  9:29           ` Pablo Neira Ayuso
2019-10-24  9:51             ` Phil Sutter
2019-10-24 10:01               ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.