]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: Use ARRAY_SIZE() macro in nft_strerror()
authorPhil Sutter <phil@nwl.cc>
Thu, 17 Oct 2019 21:55:02 +0000 (23:55 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 23 Oct 2019 12:05:17 +0000 (14:05 +0200)
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>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft.c

index 89b1c7a808f57e9ef3b2e092319f1efef81decfd..3c230c121f8b9d6c8b3b6042ad1ecfc536fe54d1 100644 (file)
@@ -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;