[PATCH] ethdev: convert string initialization
Dariusz Sosnowski
dsosnowski at nvidia.com
Fri Oct 4 21:18:10 CEST 2024
> -----Original Message-----
> From: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
> Sent: Friday, October 4, 2024 09:27
> To: Ferruh Yigit <ferruh.yigit at amd.com>; NBU-Contact-Thomas Monjalon
> (EXTERNAL) <thomas at monjalon.net>; Ori Kam <orika at nvidia.com>; Aman Singh
> <aman.deep.singh at intel.com>; Konstantin Ananyev
> <konstantin.v.ananyev at yandex.ru>; Reshma Pattan <reshma.pattan at intel.com>;
> Stephen Hemminger <stephen at networkplumber.org>; Akhil Goyal
> <gakhil at marvell.com>; Anoob Joseph <anoobj at marvell.com>; Potnuri Bharat
> Teja <bharat at chelsio.com>; Hemant Agrawal <hemant.agrawal at nxp.com>;
> Sachin Saxena <sachin.saxena at nxp.com>; Matan Azrad <matan at nvidia.com>;
> Slava Ovsiienko <viacheslavo at nvidia.com>; Dariusz Sosnowski
> <dsosnowski at nvidia.com>; Bing Zhao <bingz at nvidia.com>; Suanming Mou
> <suanmingm at nvidia.com>; Chaoyong He <chaoyong.he at corigine.com>
> Cc: dev at dpdk.org; Morten Brørup <mb at smartsharesystems.com>; Bruce
> Richardson <bruce.richardson at intel.com>
> Subject: Re: [PATCH] ethdev: convert string initialization
>
> External email: Use caution opening links or attachments
>
>
> On 10/4/24 07:13, Ferruh Yigit wrote:
> > gcc 15 experimental [1], with -Wextra flag, gives warning in variable
> > initialization as string [2].
> >
> > The warning has a point when initialized variable is intended to use
> > as string, since assignment is missing the required null terminator
> > for this case. But warning is useless for our usecase.
> >
> > In this patch only updated a few instance to show the issue, there are
> > many instances to fix, if we prefer to go this way.
> > Other option is to disable warning but it can be useful for actual
> > string usecases, so I prefer to keep it.
> >
> > Converted string initialization to array initialization.
> >
> > [1]
> > gcc (GCC) 15.0.0 20241003 (experimental)
> >
> > [2]
> > ../lib/ethdev/rte_flow.h:906:36:
> > error: initializer-string for array of ‘unsigned char’ is too long
> > [-Werror=unterminated-string-initialization]
> > 906 | .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > ../lib/ethdev/rte_flow.h:907:36:
> > error: initializer-string for array of ‘unsigned char’ is too long
> > [-Werror=unterminated-string-initialization]
> > 907 | .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > ../lib/ethdev/rte_flow.h:1009:25:
> > error: initializer-string for array of ‘unsigned char’ is too long
> > [-Werror=unterminated-string-initialization]
> > 1009 | "\xff\xff\xff\xff\xff\xff\xff\xff"
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > ../lib/ethdev/rte_flow.h:1012:25:
> > error: initializer-string for array of ‘unsigned char’ is too long
> > [-Werror=unterminated-string-initialization]
> > 1012 | "\xff\xff\xff\xff\xff\xff\xff\xff"
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > ../lib/ethdev/rte_flow.h:1135:20:
> > error: initializer-string for array of ‘unsigned char’ is too long
> > [-Werror=unterminated-string-initialization]
> > 1135 | .hdr.vni = "\xff\xff\xff",
> > | ^~~~~~~~~~~~~~
> >
> > Signed-off-by: Ferruh Yigit <ferruh.yigit at amd.com>
> > Acked-by: Morten Brørup <mb at smartsharesystems.com>
> > Acked-by: Bruce Richardson <bruce.richardson at intel.com>
>
>
> Acked-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
Acked-by: Dariusz Sosnowski <dsosnowski at nvidia.com>
Best regards,
Dariusz Sosnowski
More information about the dev
mailing list