[PATCH] ccan: Fix calling memset with zero length parameter.
Andreas Schneider
asn at samba.org
Thu Jul 11 06:04:00 MDT 2013
On Thursday 11 July 2013 13:47:46 Volker Lendecke wrote:
> On Thu, Jul 11, 2013 at 01:36:54PM +0200, Andreas Schneider wrote:
> > Signed-off-by: Andreas Schneider <asn at samba.org>
> > ---
> >
> > lib/ccan/tally/tally.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/ccan/tally/tally.c b/lib/ccan/tally/tally.c
> > index 774373c..395c17c 100644
> > --- a/lib/ccan/tally/tally.c
> > +++ b/lib/ccan/tally/tally.c
> > @@ -510,7 +510,9 @@ char *tally_histogram(const struct tally *tally,
> >
> > count = 0;
> >
> > }
> >
> > - memset(p, '*', count);
> > + if (count > 0) {
> > + memset(p, '*', count);
> > + }
> >
> > p += count;
> > *p = '\n';
> > p++;
>
> Hmmm. That's not allowed?
>
> Volker
VERIFY Build Log the build on i686 reports a broken memset() call at
line 2385 of the build log:
2381 from ../lib/ccan/likely/likely.h:5,
2382 from ../lib/ccan/tally/tally.c:4:
2383 In function 'memset',
2384 inlined from 'tally_histogram' at ../lib/ccan/tally/tally.c:513:9:
2385 /usr/include/bits/string3.h:81:30: warning: call to
'__warn_memset_zero_len' declared with attribute warning: memset used with
constant zero length parameter; this could be due to transposed parameters
[enabled by default]
2386 __warn_memset_zero_len ();
2387 ^
I didn't see how could could be always 0 here but probably count = 0 is what
the compiler sees and warns about.
-- andreas
--
Andreas Schneider GPG-ID: F33E3FC6
Samba Team asn at samba.org
www.samba.org
More information about the samba-technical
mailing list