> > > > >
> > > > > Hi Qi,
> > > > >
> > > > > Thanks for these patches, and also for rebasing to the latest!
> > > > >
> > > > > ciniparser.c adds a new warning (see below). Could you fix that
> > > > > up in a new patch on top of the initial import (i.e. we retain
> > > > > the as-is import, and make a record of what we changed).
> > > > >
> > > > > Looks like the -Wformat-truncation= warnings were first
> > > > > introduced in gcc-7.1, but only became really zealous after
> > > > > gcc-8.1. The right solution here might just be to suppress it by
> > > > > adding a -Wno-format- truncation to CFLAGS, but I'm open to
> > > > > considering other alternatives.
> > > >
> > > > That warning looks pretty handy.
> > > >
> > > > >
> > > > >    $ gcc --version
> > > > >    gcc (GCC) 8.2.1 20181105 (Red Hat 8.2.1-5)
> > > > >
> > > > >    ccan/ciniparser/ciniparser.c: In function ‘ciniparser_load’:
> > > > >    ccan/ciniparser/ciniparser.c:442:39: warning: ‘%s’ directive
> > > > > output may be truncated writing up to 1024 bytes into a region
> > > > > of size between 0 and 1024 [-Wformat-truncation=]
> > > > >        snprintf(tmp, ASCIILINESZ + 1, "%s:%s", section, key);
> > > > >                                           ^~            ~~~
> > > > >    In file included from /usr/include/stdio.h:873,
> > > > >                     from ./ccan/ciniparser/ciniparser.h:39,
> > > > >                     from ccan/ciniparser/ciniparser.c:36:
> > > > >    /usr/include/bits/stdio2.h:67:10: note:
> > > > > ‘__builtin___snprintf_chk’ output between 2 and 2050 bytes into
> > > > > a destination of size 1025
> > > > >       return __builtin___snprintf_chk (__s, __n,
> > > > > __USE_FORTIFY_LEVEL - 1,
> > > > >
> > > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > ~~~~~~
> > > > >            __bos (__s), __fmt, __va_arg_pack ());
> > > > >            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > >
> > > > Since it's an snprintf without the error return being checked,
> > > > perhaps it would be happier as an sprintf with a precision
> > > > specified to limit the output?
> > >
> > > That would work, but 'section' and 'key' are both ASCIILINESZ+1, so
> > > how would we specify precision for both the %s specifiers? i.e.
> > > would we have to make up an artificial split?
> >
> > Good point. No way to do it without variable precision. However,
> > looking closer I think the warning only triggers when the return value
> > is not checked, so perhaps better to just add error handling to that
> > case.
> 
> Yep that seems reasonable to me.

Hi,

Thank you for your comments.
I updated the gcc version in my local environment and got the warning messages.
I will make a new version to fix them.

Thank you.
Qi
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to