From patchwork Fri Oct 18 15:51:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1179493 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46vr9n3qt7z9sNw for ; Sat, 19 Oct 2019 02:51:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390044AbfJRPvY (ORCPT ); Fri, 18 Oct 2019 11:51:24 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:44346 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389072AbfJRPvY (ORCPT ); Fri, 18 Oct 2019 11:51:24 -0400 Received: from localhost ([::1]:57436 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1iLUXD-0006Kb-6J; Fri, 18 Oct 2019 17:51:23 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH] nft: Use ARRAY_SIZE() macro in nft_strerror() Date: Fri, 18 Oct 2019 17:51:14 +0200 Message-Id: <20191018155114.7423-1-phil@nwl.cc> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org 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 Acked-by: Pablo Neira Ayuso --- 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;