From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
"Morten Brørup" <mb@smartsharesystems.com>,
"Bruce Richardson" <bruce.richardson@intel.com>
Subject: [PATCH v2] build: force gcc to initialize padding bits
Date: Fri, 24 Jan 2025 10:26:48 -0800 [thread overview]
Message-ID: <20250124182647.117636-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20250123172048.134417-1-stephen@networkplumber.org>
With GCC 15, the compiler has changed the default behavior when
initialization is used for aggregate variables. The new default
is to follow the standard (C23) and not initialize everything by
default. This breaks assumptions in some drivers and can be
lead to other bugs. Use the new zero initialization flag to
force of all fields to zero.
Note: other compilers always initialize to zero in these cases.
Only GCC seems to have decided to start initializing less as
a silly attempt at optimization.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
config/meson.build | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/config/meson.build b/config/meson.build
index 6aaad6d8a4..b6b3558e11 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -310,7 +310,7 @@ endif
# enable extra warnings and disable any unwanted warnings
# -Wall is added by default at warning level 1, and -Wextra
# at warning level 2 (DPDK default)
-warning_flags = [
+global_cflags = [
# additional warnings in alphabetical order
'-Wcast-qual',
'-Wdeprecated',
@@ -330,19 +330,22 @@ warning_flags = [
# globally disabled warnings
'-Wno-packed-not-aligned',
'-Wno-missing-field-initializers',
+
+ # guarantee that all non-initialized parts of structure/union are zero
+ '-fzero-init-padding-bits=all',
]
if not dpdk_conf.get('RTE_ARCH_64')
# for 32-bit, don't warn about casting a 32-bit pointer to 64-bit int - it's fine!!
- warning_flags += '-Wno-pointer-to-int-cast'
+ global_cflags += '-Wno-pointer-to-int-cast'
endif
if cc.get_id() == 'intel'
warning_ids = [181, 188, 2203, 2279, 2557, 3179, 3656]
foreach i:warning_ids
- warning_flags += '-diag-disable=@0@'.format(i)
+ global_cflags += '-diag-disable=@0@'.format(i)
endforeach
endif
-foreach arg: warning_flags
+foreach arg: global_cflags
if cc.has_argument(arg)
add_project_arguments(arg, language: 'c')
endif
--
2.45.2
prev parent reply other threads:[~2025-01-24 18:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 17:20 [PATCH] " Stephen Hemminger
2025-01-24 7:48 ` Morten Brørup
2025-01-24 9:38 ` Bruce Richardson
2025-01-24 18:37 ` Stephen Hemminger
2025-01-24 18:26 ` Stephen Hemminger [this message]
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=20250124182647.117636-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
/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).