[ovs-dev] [PATCH 1/2] lldp: fix string warnings
Aaron Conole
aconole at redhat.com
Thu Jun 14 21:10:10 UTC 2018
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,
>
> Ben.
More information about the dev
mailing list