From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nft 1/3] nft: add NFT_ARRAY_SIZE() helper
Date: Wed, 27 Sep 2023 16:24:19 +0200 [thread overview]
Message-ID: <6298b85f20f868e97e1465f06d7e68139b57aca8.camel@redhat.com> (raw)
In-Reply-To: <20230927122744.3434851-2-thaller@redhat.com>
On Wed, 2023-09-27 at 14:23 +0200, Thomas Haller wrote:
> Add NFT_ARRAY_SIZE() macro, commonly known as ARRAY_SIZE() (or
> G_N_ELEMENTS()).
>
> <nft.h> is the right place for macros and static-inline functions. It
> is
> included in *every* C sources, as it only depends on libc headers and
> <config.h>. NFT_ARRAY_SIZE() is part of the basic toolset, that
> should
> be available everywhere.
>
> Signed-off-by: Thomas Haller <thaller@redhat.com>
> ---
> include/nft.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/include/nft.h b/include/nft.h
> index 9384054c11c8..4463b5c0fa4a 100644
> --- a/include/nft.h
> +++ b/include/nft.h
> @@ -8,4 +8,6 @@
> #include <stdint.h>
> #include <stdlib.h>
>
> +#define NFT_ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
> +
> #endif /* NFTABLES_NFT_H */
oh, I just found the "array_size()" macro. Didn't expect it to be
lower-case.
Will use that in v2.
Thomas
next prev parent reply other threads:[~2023-09-27 14:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 12:23 [PATCH nft 0/3] Two fixes to avoid "-Wstrict-overflow" warnings Thomas Haller
2023-09-27 12:23 ` [PATCH nft 1/3] nft: add NFT_ARRAY_SIZE() helper Thomas Haller
2023-09-27 14:24 ` Thomas Haller [this message]
2023-09-27 14:28 ` Pablo Neira Ayuso
2023-09-27 12:23 ` [PATCH nft 2/3] nfnl_osf: rework nf_osf_parse_opt() and avoid "-Wstrict-overflow" warning Thomas Haller
2023-09-27 16:42 ` Pablo Neira Ayuso
2023-09-27 17:04 ` Thomas Haller
2023-09-27 17:11 ` Pablo Neira Ayuso
2023-09-27 17:50 ` Thomas Haller
2023-09-27 19:16 ` Pablo Neira Ayuso
2023-09-27 20:11 ` Thomas Haller
2023-09-27 20:21 ` Pablo Neira Ayuso
2023-09-27 12:23 ` [PATCH nft 3/3] netlink_linearize: avoid strict-overflow warning in netlink_gen_bitwise() Thomas Haller
2023-09-27 17:06 ` Thomas Haller
2023-09-27 17:14 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6298b85f20f868e97e1465f06d7e68139b57aca8.camel@redhat.com \
--to=thaller@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).