[Libguestfs] [PATCH nbdkit] server/public.c: Uninline nbdkit_strdup_intern to avoid compiler warning.

Richard W.M. Jones rjones at redhat.com
Thu Sep 3 13:55:31 UTC 2020


On Thu, Sep 03, 2020 at 08:54:08AM -0500, Eric Blake wrote:
> On 9/3/20 4:41 AM, Richard W.M. Jones wrote:
> >Previously with GCC 10.2 this code produced:
> >
> >In function ‘nbdkit_strndup_intern’,
> >     inlined from ‘nbdkit_strdup_intern’ at public.c:839:10:
> >public.c:827:10: error: ‘strndup’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
> >   827 |   copy = strndup (str, n);
> >       |          ^~~~~~~~~~~~~~~~
> >---
> >  server/public.c | 16 +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> >
> 
> I find the gcc warning annoying, but this workaround is fine (and
> potentially even a bit more efficient, because it uses fewer
> function calls).
> 
> ACK, regardless of whether gcc also agrees with your bug report.

Nope they didn't :-(
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96916

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list