On Wed, 7 Feb 2024 19:10:37 +0000 Ferruh Yigit <ferruh.yi...@amd.com> wrote:
> On 1/19/2024 10:13 PM, Stephen Hemminger wrote: > > 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. > > > > Fixes: f67e4719147d ("net/sfc/base: fix coding style") > > Signed-off-by: Stephen Hemminger <step...@networkplumber.org> > > Acked-by: Morten Brørup <m...@smartsharesystems.com> > > --- > > v2 - add assert.h to make sure it works in other environments > > > > drivers/common/sfc_efx/base/efx.h | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/common/sfc_efx/base/efx.h > > b/drivers/common/sfc_efx/base/efx.h > > index 3312c2fa8f81..38f2aed3e336 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,8 +19,8 @@ > > extern "C" { > > #endif > > > > -#define EFX_STATIC_ASSERT(_cond) \ > > - ((void)sizeof (char[(_cond) ? 1 : -1])) > > +#define EFX_STATIC_ASSERT(_cond) \ > > + do { static_assert((_cond), "assert failed" #_cond); } while (0) > > > > #define EFX_ARRAY_SIZE(_array) \ > > (sizeof (_array) / sizeof ((_array)[0])) > > Getting following build error with clang: What version of clang? It works for me with clang 16.0.6