patch 'common/sfc_efx/base: use C11 static assert' has been queued to stable release 23.11.1
Xueming Li
xuemingl at nvidia.com
Tue Mar 5 10:47:28 CET 2024
Hi,
FYI, your patch has been queued to stable release 23.11.1
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/31/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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging
This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=c7b50f40e114efaacade1feaaf11f8f6ff3d6bbb
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From c7b50f40e114efaacade1feaaf11f8f6ff3d6bbb 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
Cc: Xueming Li <xuemingl at nvidia.com>
[ 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 3312c2fa8f..5773cb00b3 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -7,6 +7,8 @@
#ifndef _SYS_EFX_H
#define _SYS_EFX_H
+#include <assert.h>
+
#include "efx_annote.h"
#include "efsys.h"
#include "efx_types.h"
@@ -17,14 +19,20 @@
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) \
(sizeof (_array) / sizeof ((_array)[0]))
#define EFX_FIELD_OFFSET(_type, _field) \
- ((size_t)&(((_type *)0)->_field))
+ offsetof(_type, _field)
/* The macro expands divider twice */
#define EFX_DIV_ROUND_UP(_n, _d) (((_n) + (_d) - 1) / (_d))
--
2.34.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2024-03-05 17:39:34.203637107 +0800
+++ 0107-common-sfc_efx-base-use-C11-static-assert.patch 2024-03-05 17:39:30.893566497 +0800
@@ -1 +1 @@
-From 047d7032b76a226f2f1c36775688950933f9121b Mon Sep 17 00:00:00 2001
+From c7b50f40e114efaacade1feaaf11f8f6ff3d6bbb Mon Sep 17 00:00:00 2001
@@ -7,0 +8,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 047d7032b76a226f2f1c36775688950933f9121b ]
@@ -17 +19,0 @@
-Cc: stable at dpdk.org
More information about the stable
mailing list