patch 'common/sfc_efx/base: use C11 static assert' has been queued to stable release 21.11.7

Kevin Traynor ktraynor at redhat.com
Tue Mar 5 16:34:27 CET 2024


Hi,

FYI, your patch has been queued to stable release 21.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/11/24. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/82aea5d9b46d7bb62c4b18e9a91033a1583287ea

Thanks.

Kevin

---
>From 82aea5d9b46d7bb62c4b18e9a91033a1583287ea Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Sun, 11 Feb 2024 21:48:59 -0800
Subject: [PATCH] common/sfc_efx/base: use C11 static assert
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[ upstream commit 047d7032b76a226f2f1c36775688950933f9121b ]

The sfc base code had its own definition of static assertions
using the out of bound array access hack. Replace it with a
static_assert like rte_common.h.

The use of null pointer to compute offset is not always a constant
in older versions of clang. Use standard offsetof() instead.

Fixes: f67e4719147d ("net/sfc/base: fix coding style")

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
Reviewed-by: Morten Brørup <mb at smartsharesystems.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
---
 drivers/common/sfc_efx/base/efx.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 398eb8dbd2..74fcd06583 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -8,4 +8,6 @@
 #define	_SYS_EFX_H
 
+#include <assert.h>
+
 #include "efx_annote.h"
 #include "efsys.h"
@@ -18,6 +20,12 @@ extern "C" {
 #endif
 
-#define	EFX_STATIC_ASSERT(_cond)		\
-	((void)sizeof (char[(_cond) ? 1 : -1]))
+/*
+ * Triggers an error at compilation time if the condition is false.
+ *
+ * The  { } exists to workaround a bug in clang (#55821)
+ * where it would not handle _Static_assert in a switch case.
+ */
+#define	EFX_STATIC_ASSERT(_cond) \
+	{ static_assert((_cond), #_cond); }
 
 #define	EFX_ARRAY_SIZE(_array)			\
@@ -25,5 +33,5 @@ extern "C" {
 
 #define	EFX_FIELD_OFFSET(_type, _field)		\
-	((size_t)&(((_type *)0)->_field))
+	offsetof(_type, _field)
 
 /* The macro expands divider twice */
-- 
2.43.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-03-05 14:08:55.932739434 +0000
+++ 0054-common-sfc_efx-base-use-C11-static-assert.patch	2024-03-05 14:08:54.695520884 +0000
@@ -1 +1 @@
-From 047d7032b76a226f2f1c36775688950933f9121b Mon Sep 17 00:00:00 2001
+From 82aea5d9b46d7bb62c4b18e9a91033a1583287ea Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit 047d7032b76a226f2f1c36775688950933f9121b ]
+
@@ -17 +18,0 @@
-Cc: stable at dpdk.org
@@ -27 +28 @@
-index 3312c2fa8f..5773cb00b3 100644
+index 398eb8dbd2..74fcd06583 100644



More information about the stable mailing list