From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [PATCH nft 2/5] utils: call abort() after BUG() macro
Date: Tue, 29 Aug 2023 20:54:08 +0200 [thread overview]
Message-ID: <20230829185509.374614-3-thaller@redhat.com> (raw)
In-Reply-To: <20230829185509.374614-1-thaller@redhat.com>
Otherwise, we get spurious warnings. The compiler should be aware that there is
no return from BUG(). Call abort() there, which is marked as __attribute__
((__noreturn__)).
In file included from ./include/nftables.h:6,
from ./include/rule.h:4,
from src/payload.c:26:
src/payload.c: In function 'icmp_dep_to_type':
./include/utils.h:39:34: error: this statement may fall through [-Werror=implicit-fallthrough=]
39 | #define BUG(fmt, arg...) ({ fprintf(stderr, "BUG: " fmt, ##arg); assert(0); })
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/payload.c:791:17: note: in expansion of macro 'BUG'
791 | BUG("Invalid map for simple dependency");
| ^~~
src/payload.c:792:9: note: here
792 | case PROTO_ICMP_ECHO: return ICMP_ECHO;
| ^~~~
Signed-off-by: Thomas Haller <thaller@redhat.com>
---
include/utils.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/utils.h b/include/utils.h
index efc8dec013a1..5b8b181c1e99 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -3,6 +3,7 @@
#include <asm/byteorder.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
@@ -36,7 +37,7 @@
#define __must_check __attribute__((warn_unused_result))
#define __noreturn __attribute__((__noreturn__))
-#define BUG(fmt, arg...) ({ fprintf(stderr, "BUG: " fmt, ##arg); assert(0); })
+#define BUG(fmt, arg...) ({ fprintf(stderr, "BUG: " fmt, ##arg); assert(0); abort(); })
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
--
2.41.0
next prev parent reply other threads:[~2023-08-29 18:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 18:54 [PATCH nft 0/5] fix compiler warnings with clang and "-Wextra" Thomas Haller
2023-08-29 18:54 ` [PATCH nft 1/5] rule: fix "const static" declaration Thomas Haller
2023-08-29 18:54 ` Thomas Haller [this message]
2023-08-29 18:54 ` [PATCH nft 3/5] src: silence "implicit-fallthrough" warnings Thomas Haller
2023-08-29 18:54 ` [PATCH nft 4/5] xt: avoid "-Wmissing-field-initializers" for "original_opts" Thomas Haller
2023-08-29 18:54 ` [PATCH nft 5/5] datatype: check against negative "type" argument in datatype_lookup() Thomas Haller
2023-08-29 19:10 ` Pablo Neira Ayuso
2023-08-29 19:14 ` Pablo Neira Ayuso
2023-08-29 19:58 ` Thomas Haller
2023-08-30 7:46 ` Pablo Neira Ayuso
2023-08-30 8:08 ` Thomas Haller
2023-08-30 8:23 ` 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=20230829185509.374614-3-thaller@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).