> -----Original Message-----
> From: Wu, WenxuanX <wenxuanx...@intel.com>
> Sent: 2022年6月20日 9:39
> To: Zhang, Qi Z <qi.z.zh...@intel.com>; Yang, Qiming
> <qiming.y...@intel.com>; dev@dpdk.org; tho...@monjalon.net
> Cc: step...@networkplumber.org; sta...@dpdk.org
> Subject: RE: [PATCH] ice/base: fix gcc 12 warning stringop-overflow
>
> Hi all,
>
> The warning below gcc 12 :
> inlined from ‘ice_add_adv_recipe’
> at ../drivers/net/ice/base/ice_switch.c:7951:11,
> inlined from ‘ice_add_adv_rule’
> at ../drivers/net/ice/base/ice_switch.c:8911:11:
> ../drivers/net/ice/base/ice_switch.c:7220:61: error: writing 1 byte into a
> region of size 0 [-Werror=stringop-overflow=]
> 7220 | buf[recps].content.lkup_indx[i + 1] =
> entry->fv_idx[i];
> |
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
> In file included from ../drivers/net/ice/base/ice_controlq.h:8,
> from ../drivers/net/ice/base/ice_type.h:54,
> from ../drivers/net/ice/base/ice_common.h:8,
> from ../drivers/net/ice/base/ice_switch.h:8,
> from ../drivers/net/ice/base/ice_switch.c:5:
> ../drivers/net/ice/base/ice_adminq_cmd.h: In function ‘ice_add_adv_rule’:
> ../drivers/net/ice/base/ice_adminq_cmd.h:744:12: note: at offset 5 into
> destination object ‘lkup_indx’ of size 5
> 744 | u8 lkup_indx[5];
> | ^~~~~~~~~
> In function ‘ice_add_sw_recipe’,
> inlined from ‘ice_add_adv_recipe’
> at ../drivers/net/ice/base/ice_switch.c:7951:11,
> inlined from ‘ice_add_adv_rule’
> at ../drivers/net/ice/base/ice_switch.c:8911:11:
> ../drivers/net/ice/base/ice_switch.c:7220:61: error: writing 1 byte into a
> region of size 0 [-Werror=stringop-overflow=]
> 7220 | buf[recps].content.lkup_indx[i + 1] =
> entry->fv_idx[i];
> |
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
> ../drivers/net/ice/base/ice_adminq_cmd.h: In function ‘ice_add_adv_rule’:
> ../drivers/net/ice/base/ice_adminq_cmd.h:744:12: note: at offset [6, 254]
> into destination object ‘lkup_indx’ of size 5
> 744 | u8 lkup_indx[5];
> | ^~~~~~~~~
> In function ‘ice_add_sw_recipe’,
> inlined from ‘ice_add_adv_recipe’
> at ../drivers/net/ice/base/ice_switch.c:7951:11,
> inlined from ‘ice_add_adv_rule’
> at ../drivers/net/ice/base/ice_switch.c:8911:11:
> ../drivers/net/ice/base/ice_switch.c:7220:61: error: writing 1 byte into a
> region of size 0 [-Werror=stringop-overflow=]
> 7220 | buf[recps].content.lkup_indx[i + 1] =
> entry->fv_idx[i];
> |
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
> ../drivers/net/ice/base/ice_adminq_cmd.h: In function ‘ice_add_adv_rule’:
> ../drivers/net/ice/base/ice_adminq_cmd.h:744:12: note: at offset [7, 255]
> into destination object ‘lkup_indx’ of size 5
> 744 | u8 lkup_indx[5];
> | ^~~~~~~~~
> cc1: all warnings being treated as errors
>
> Thanks
> Wenxuan
>
> > -----Original Message-----
> > From: Zhang, Qi Z <qi.z.zh...@intel.com>
> > Sent: 2022年6月19日 20:35
> > To: Wu, WenxuanX <wenxuanx...@intel.com>; Yang, Qiming
> > <qiming.y...@intel.com>; dev@dpdk.org; tho...@monjalon.net
> > Cc: step...@networkplumber.org; sta...@dpdk.org
> > Subject: RE: [PATCH] ice/base: fix gcc 12 warning stringop-overflow
> >
> >
> >
> > > -----Original Message-----
> > > From: Wu, WenxuanX <wenxuanx...@intel.com>
> > > Sent: Thursday, June 16, 2022 6:33 PM
> > > To: Yang, Qiming <qiming.y...@intel.com>; Zhang, Qi Z
> > > <qi.z.zh...@intel.com>; dev@dpdk.org; tho...@monjalon.net
> > > Cc: step...@networkplumber.org; Wu, WenxuanX
> > <wenxuanx...@intel.com>;
> > > sta...@dpdk.org
> > > Subject: [PATCH] ice/base: fix gcc 12 warning stringop-overflow
> > >
> > > From: Wenxuan Wu <wenxuanx...@intel.com>
> > >
> > > Gcc with -O2 flag, would retrieve the value in one time.
> > > This patch changed the type of fv_idx in struct ice_recp_grp_entry
> > > to align with its callers which is also u8 type.
> > >
> > > When u8 idx[5] = a value u16 index[4], gcc12 would give this
> > > warning, because it is not big enough to store the bytes(bigger than
> > > 5 bytes) in one time (-O2 would do it in this way).
> > >
> > > Fixes: 04b8ec1ea807 ("net/ice/base: add protocol structures and
> > > defines")
> > > Cc: sta...@dpdk.org
> > > Signed-off-by: Wenxuan Wu <wenxuanx...@intel.com>
> > > ---
> > > drivers/net/ice/base/ice_protocol_type.h | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/net/ice/base/ice_protocol_type.h
> > > b/drivers/net/ice/base/ice_protocol_type.h
> > > index 0e6e5990be..cfe3b62630 100644
> > > --- a/drivers/net/ice/base/ice_protocol_type.h
> > > +++ b/drivers/net/ice/base/ice_protocol_type.h
> > > @@ -421,7 +421,7 @@ struct ice_recp_grp_entry { #define
> > > ICE_INVAL_CHAIN_IND 0xFF
> > > u16 rid;
> > > u8 chain_idx;
> > > - u16 fv_idx[ICE_NUM_WORDS_RECIPE];
> > > + u8 fv_idx[ICE_NUM_WORDS_RECIPE];
> >
> > If you change the data type from u16 to u8 for the FV index, you'd
> > better also change the type of all the symbols to store the same
> > thing. e.g. the parameter "fv_idx" of ice_find_prot_off.
> > So, what's exactly the issue that GCC 12 reported? can we fix it from
> > the other side without changing a type in the base code?
change from u8 lkup_indx[5] to u16 lkup_indx[5] can also resolve this
issue.
> >
> >
> > > u16 fv_mask[ICE_NUM_WORDS_RECIPE];
> > > struct ice_pref_recipe_group r_group; };
> > > --
> > > 2.25.1