netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nft 0/3] Two fixes to avoid "-Wstrict-overflow" warnings
@ 2023-09-27 12:23 Thomas Haller
  2023-09-27 12:23 ` [PATCH nft 1/3] nft: add NFT_ARRAY_SIZE() helper Thomas Haller
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Thomas Haller @ 2023-09-27 12:23 UTC (permalink / raw)
  To: NetFilter; +Cc: Thomas Haller

The "-Wstrict-overflow=5" warning seems useful, as it's easy to get this
wrong. I think C really should have "-fwrapv" behavior, but the reality
is that we need to be careful about signed overflow. The warning helps
with that, and luckily there are only a few places that require fixes.
Note that libparser and mini-gmp.c cannot build with "-Wstrict-overflow=5".

Maybe there are other warnings, as it depends on the optimization level
and the compiler. This works for my gcc and -O3.

Thomas Haller (3):
  nft: add NFT_ARRAY_SIZE() helper
  nfnl_osf: rework nf_osf_parse_opt() and avoid "-Wstrict-overflow"
    warning
  netlink_linearize: avoid strict-overflow warning in
    netlink_gen_bitwise()

 include/nft.h           |   2 +
 src/netlink_linearize.c |   7 +--
 src/nfnl_osf.c          | 128 ++++++++++++++++++----------------------
 3 files changed, 63 insertions(+), 74 deletions(-)

-- 
2.41.0


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

end of thread, other threads:[~2023-09-27 20:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).