[PATCH v2] common/sfc: replace out of bounds condition with static_assert
Stephen Hemminger
stephen at networkplumber.org
Sun Feb 11 18:41:49 CET 2024
On Wed, 7 Feb 2024 23:30:07 +0000
Ferruh Yigit <ferruh.yigit at amd.com> wrote:
> On 2/7/2024 10:36 PM, Stephen Hemminger wrote:
> > On Wed, 7 Feb 2024 19:10:37 +0000
> > Ferruh Yigit <ferruh.yigit at amd.com> wrote:
> >
> >> ../drivers/common/sfc_efx/base/ef10_filter.c:1246:18: error: shift count
> >>> = width of type [-Werror,-Wshift-count-overflow]
> >> matches_count = MCDI_OUT_DWORD(req,
> >> ^~~~~~~~~~~~~~~~~~~
> >> ../drivers/common/sfc_efx/base/efx_mcdi.h:493:2: note: expanded from
> >> macro 'MCDI_OUT_DWORD'
> >> EFX_DWORD_FIELD(*MCDI_OUT2(_emr, efx_dword_t, _ofst), \
> >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> ../drivers/common/sfc_efx/base/efx_types.h:533:30: note: expanded from
> >> macro 'EFX_DWORD_FIELD'
> >> EFX_HIGH_BIT(_field)) & EFX_MASK32(_field))
> >> ^~~~~~~~~~~~~~~~~~
> >> ../drivers/common/sfc_efx/base/efx_types.h:145:23: note: expanded from
> >> macro 'EFX_MASK32'
> >> (((((uint32_t)1) << EFX_WIDTH(_field))) - 1))
> >
> > None of this got changed by the patch. Looks like it would not compile
> > even without the patch on your version of clang.
> >
>
> Nope, error only happens with the patch.
>
> And CI seems reporting the errors:
> https://mails.dpdk.org/archives/test-report/2024-January/558546.html
This patch is allowing compiler to see some things as constant which
were hidden before. The driver is buggy, for example, look at this:
/*
* Stop lint complaining about some shifts.
*/
#ifdef __lint
extern int fix_lint;
#define FIX_LINT(_x) (_x + fix_lint)
#else
#define FIX_LINT(_x) (_x)
#endif
Looks like it is wallpapering over some errors.
More information about the dev
mailing list