[PATCH] Use size_t for mallinfo fields.

H.J. Lu hjl.tools@gmail.com
Mon Aug 31 14:00:10 GMT 2020


On Mon, Aug 31, 2020 at 6:57 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
>
>
> On 31/08/2020 10:35, H.J. Lu via Libc-alpha wrote:
> > On Fri, Aug 28, 2020 at 12:06 PM DJ Delorie via Libc-alpha
> > <libc-alpha@sourceware.org> wrote:
> >>
> >> Martin Li¡ka <mliska@suse.cz> writes:
> >>
> >>> PING^1
> >>
> >> LGTM
> >>
> >> Reviewed-by: DJ Delorie <dj@redhat.com>
> >>
> >>> On 8/12/20 2:29 PM, Martin Liška wrote:
> >>>> On 8/11/20 7:08 PM, DJ Delorie wrote:
> >>>>> Florian Weimer <fw@deneb.enyo.de> writes:
> >>>>>> DJ, what do you think about this patch?
> >>>>>
> >>>>> I have no real problems with the patch, but two minor things that could
> >>>>> be handled in a follow-up patch...
> >>>>
> >>>> Thank you for the review.
> >>>> Can I read it as ready to go into master?
> >>>>
> >>>>>
> >>>>> 1. The copy code for the old function doesn't handle overflow.  We've
> >>>>> Â Â Â  seen bug reports for this before so should consider the edge cases.
> >>>>> Â Â Â  IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
> >>>>> Â Â Â  should be stored instead of a randomly truncated value.
> >>>>>
> >>>>> 2. The new documentation makes no mention of the older "compatible"
> >>>>> Â Â Â  interface.
> >>>>>
> >>>>
> >>>> Both comments are valid to me and I can address them in a follow-up patch.
> >>>>
> >>>> Martin
> >>
> >
> > $ gcc ../sysdeps/x86_64/multiarch/test-multiarch.c -c -std=gnu11
> > -fgnu89-inline  -O2 -g -Wall -Wwrite-strings -Wundef -Werror
> > -fmerge-all-constants -frounding-math -fno-stack-protector
> > -Wstrict-prototypes -Wold-style-definition -fmath-errno
> > -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0         -I../include
> > -I/export/build/gnu/tools-build/glibc/build-x86_64-linux/csu
> > -I/export/build/gnu/tools-build/glibc/build-x86_64-linux
> > -I../sysdeps/unix/sysv/linux/x86_64/64
> > -I../sysdeps/unix/sysv/linux/x86_64
> > -I../sysdeps/unix/sysv/linux/x86/include
> > -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl
> > -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl
> > -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux
> > -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu
> > -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv
> > -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix
> > -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch
> > -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu
> > -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86
> > -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include
> > -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64
> > -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32
> > -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic
> > -I.. -I../libio -I.   -D_LIBC_REENTRANT -include
> > /export/build/gnu/tools-build/glibc/build-x86_64-linux/libc-modules.h
> > -DMODULE_NAME=testsuite -include ../include/libc-symbols.h
> > -DTOP_NAMESPACE=glibc -o
> > /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
> > -MD -MP -MF /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o.dt
> > -MT /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
> >
> > In file included from ../include/malloc.h:3,
> >                  from ../sysdeps/x86_64/multiarch/../../../test-skeleton.c:31,
> >                  from ../sysdeps/x86_64/multiarch/test-multiarch.c:96:
> > ../malloc/malloc.h:118:1: error: empty declaration [-Werror]
> >   118 | __MALLOC_DEPRECATED;
> >       | ^~~~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> >
>
> I hit this today as well, I think the straightforward fix is:
>
> diff --git a/malloc/malloc.h b/malloc/malloc.h
> index e25b33462a..b2371f7704 100644
> --- a/malloc/malloc.h
> +++ b/malloc/malloc.h
> @@ -115,8 +115,7 @@ struct mallinfo2
>  };
>
>  /* Returns a copy of the updated current mallinfo. */
> -__MALLOC_DEPRECATED;
> -extern struct mallinfo mallinfo (void) __THROW;
> +extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
>
>  /* Returns a copy of the updated current mallinfo. */
>  extern struct mallinfo2 mallinfo2 (void) __THROW;

LGTM.

Thanks.

-- 
H.J.


More information about the Libc-alpha mailing list