[ovs-dev] [PATCH 1/2] lldp: fix string warnings

Ben Pfaff blp at ovn.org
Thu Jun 14 21:50:16 UTC 2018


On Thu, Jun 14, 2018 at 05:10:10PM -0400, Aaron Conole wrote:
> Ben Pfaff <blp at ovn.org> writes:
> 
> > On Wed, Jun 13, 2018 at 03:43:03PM -0400, Aaron Conole wrote:
> >> lib/lldp/lldpd.c: In function :
> >> lib/lldp/lldpd.c:520:17: warning: output truncated before
> >> terminating nul copying as many bytes from a string as its length
> >> [-Wstringop-truncation]
> >>                 strncat(buffer, cfg->g_protocols[i].name,
> >>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>                 strlen(cfg->g_protocols[i].name));
> >>                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> 
> >> lib/lldp/lldpd.c: In function :
> >> lib/lldp/lldpd.c:519:17: warning: specified bound 2 equals source
> >> length [-Wstringop-overflow=]
> >>                 strncat(buffer, ", ", 2);
> >>                 ^~~~~~~~~~~~~~~~~~~~~~~~
> >> 
> >> Closer inspection shows that buffer is only used to output protocol names
> >> when debug logging is enabled, so restructure the code a bit as well.
> >> 
> >> Signed-off-by: Aaron Conole <aconole at redhat.com>
> >
> > Thanks, Aaron.  I made a few further simplifications and applied this to
> > master.
> >
> > What version of GCC are you using?  Are you turning up the warning
> > level explicitly?  I don't get these warnings with OVS default warnings
> > and GCC 7.2.
> 
> GCC 8.1.1
> 
> Shiny and new until the next release.

Thanks.

I sent a patch to enable GCC 8.x new warning options:
        https://patchwork.ozlabs.org/patch/929717/
I also switched to using it here myself.


More information about the dev mailing list