From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: "Morten Brørup" <mb@smartsharesystems.com>,
"Stephen Hemminger" <stephen@networkplumber.org>,
dev@dpdk.org
Subject: Re: [PATCH] common/sfc: replace out of bounds condition with static_assert
Date: Tue, 13 Feb 2024 10:47:46 +0300 [thread overview]
Message-ID: <2171e7ad-824f-490d-a917-e46bb1fa8ffb@oktetlabs.ru> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F178@smartserver.smartshare.dk>
On 1/19/24 02:05, Morten Brørup wrote:
>> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
>> Sent: Thursday, 18 January 2024 21.18
>>
>> 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 <stephen@networkplumber.org>
>> ---
>> drivers/common/sfc_efx/base/efx.h | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/common/sfc_efx/base/efx.h
>> b/drivers/common/sfc_efx/base/efx.h
>> index 3312c2fa8f81..9ce266c43610 100644
>> --- a/drivers/common/sfc_efx/base/efx.h
>> +++ b/drivers/common/sfc_efx/base/efx.h
>> @@ -17,8 +17,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)
>
> This probably works for the DPDK project.
>
> For other projects using the same file, it might also need "#include <assert.h>" (containing the static_assert convenience macro for C), and possibly your workaround for toolchain issues with missing C11 macro in FreeBSD. Maybe not in this file, but somewhere.
>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
next prev parent reply other threads:[~2024-02-13 7:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-18 20:18 Stephen Hemminger
2024-01-18 23:05 ` Morten Brørup
2024-02-13 7:47 ` Andrew Rybchenko [this message]
2024-01-19 22:13 ` [PATCH v2] " Stephen Hemminger
2024-01-20 7:53 ` Morten Brørup
2024-02-07 19:10 ` Ferruh Yigit
2024-02-07 22:34 ` Stephen Hemminger
2024-02-07 22:36 ` Stephen Hemminger
2024-02-07 23:30 ` Ferruh Yigit
2024-02-11 17:41 ` Stephen Hemminger
2024-02-11 22:24 ` [PATCH] " Stephen Hemminger
2024-02-12 5:48 ` [PATCH v4] " Stephen Hemminger
2024-02-12 12:09 ` Ferruh Yigit
2024-02-13 9:39 ` Ferruh Yigit
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=2171e7ad-824f-490d-a917-e46bb1fa8ffb@oktetlabs.ru \
--to=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=stephen@networkplumber.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).