[PATCH] ccan: Fix calling memset with zero length parameter.
Volker Lendecke
Volker.Lendecke at SerNet.DE
Thu Jul 11 06:59:15 MDT 2013
On Thu, Jul 11, 2013 at 02:04:00PM +0200, Andreas Schneider wrote:
> 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.
To avoid an additional if-statement, what about the
alternative attached patch?
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
>From 05eb75a8cd7d6ee9d703bc9c1b7de67cb8cc31d5 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 11 Jul 2013 14:57:53 +0200
Subject: [PATCH] ccan: Fix calling memset with zero length parameter
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/ccan/tally/tally.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/ccan/tally/tally.c b/lib/ccan/tally/tally.c
index 774373c..29f0555 100644
--- a/lib/ccan/tally/tally.c
+++ b/lib/ccan/tally/tally.c
@@ -506,11 +506,11 @@ char *tally_histogram(const struct tally *tally,
if (count > covered) {
count -= covered;
+ memset(p, '*', count);
} else {
count = 0;
}
- memset(p, '*', count);
p += count;
*p = '\n';
p++;
--
1.7.9.5
More information about the samba-technical
mailing list