[PATCH] examples/cmdline: fix build error with gcc 12

Bruce Richardson bruce.richardson at intel.com
Thu Jan 19 19:12:02 CET 2023


On Thu, Jan 19, 2023 at 08:44:41AM -0800, Stephen Hemminger wrote:
> On Thu, 19 Jan 2023 08:59:10 +0000
> Bruce Richardson <bruce.richardson at intel.com> wrote:
> 
> > > >  struct object {
> > > >  	SLIST_ENTRY(object) next;  
> > > 
> > > I confirm it solves the build warning, but what about to get rid of
> > > `OBJ_NAME_LEN_MAX` completely if the intentions is to make size same as
> > > cmdline library array:
> > >   
> > Sure.
> > Another potential fix is just to cast-away [(void)] the return value from
> > strlcpy and allow truncation.
> > 
> > Olivier, as maintainer, what is your preferred fix here?
> > 
> > /Bruce
> 
> Another option would be to use flex-array and not have fixed size.

I think that would add too many other additional complications. At least
using the static array makes the sizes clear and allows the compilers to
warn about possible truncation so we have to explicitly deal with it.


More information about the stable mailing list