* build failures from gcc warning about memset
@ 2009-10-25 17:16 Julian Graham
2009-10-25 22:03 ` Ludovic Courtès
2009-10-25 22:04 ` Andy Wingo
0 siblings, 2 replies; 4+ messages in thread
From: Julian Graham @ 2009-10-25 17:16 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 667 bytes --]
Hi all,
I've been fixing and reverting this locally for the past month or so,
and I'm not sure if anyone else has seen this, but it looks like
there's some static analysis code that's been added to GCC 4.3.3 that
warns about code paths that could produce a call to `memset' with a
size parameter of zero, and which causes the build of `master' to
fail. The exact text of the warning is:
/usr/include/bits/string3.h:82: warning: memset used with constant
zero length parameter; this could be due to transposed parameters
Find attached a tiny patch that adds a check on the size parameter in
`scm_gc_calloc', which seems to satisfy the compiler.
Regards,
Julian
[-- Attachment #2: 0001-Resolve-warning-in-gcc-4.3-about-transposed-paramete.patch --]
[-- Type: text/x-diff, Size: 778 bytes --]
From 92ce32eeac2600704fc643ea5f65bda92b2d3bd9 Mon Sep 17 00:00:00 2001
From: Julian Graham <julian.graham@aya.yale.edu>
Date: Sun, 25 Oct 2009 13:00:08 -0400
Subject: [PATCH] Resolve warning in gcc-4.3 about transposed parameters passed to memset
* libguile/gc-malloc.c (scm_gc_calloc): Add explicit check on size parameter
---
libguile/gc-malloc.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/libguile/gc-malloc.c b/libguile/gc-malloc.c
index a96a186..0e60eba 100644
--- a/libguile/gc-malloc.c
+++ b/libguile/gc-malloc.c
@@ -206,7 +206,8 @@ void *
scm_gc_calloc (size_t size, const char *what)
{
void *ptr = scm_gc_malloc (size, what);
- memset (ptr, 0x0, size);
+ if (size)
+ memset (ptr, 0x0, size);
return ptr;
}
--
1.6.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: build failures from gcc warning about memset
2009-10-25 17:16 build failures from gcc warning about memset Julian Graham
@ 2009-10-25 22:03 ` Ludovic Courtès
2009-10-25 22:04 ` Andy Wingo
1 sibling, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2009-10-25 22:03 UTC (permalink / raw)
To: guile-devel
Applied, thanks!
Ludo'.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: build failures from gcc warning about memset
2009-10-25 17:16 build failures from gcc warning about memset Julian Graham
2009-10-25 22:03 ` Ludovic Courtès
@ 2009-10-25 22:04 ` Andy Wingo
2009-10-26 9:26 ` Ludovic Courtès
1 sibling, 1 reply; 4+ messages in thread
From: Andy Wingo @ 2009-10-25 22:04 UTC (permalink / raw)
To: Julian Graham; +Cc: guile-devel
Hi Julian,
On Sun 25 Oct 2009 18:16, Julian Graham <joolean@gmail.com> writes:
> --- a/libguile/gc-malloc.c
> +++ b/libguile/gc-malloc.c
> @@ -206,7 +206,8 @@ void *
> scm_gc_calloc (size_t size, const char *what)
> {
> void *ptr = scm_gc_malloc (size, what);
> - memset (ptr, 0x0, size);
> + if (size)
> + memset (ptr, 0x0, size);
> return ptr;
> }
Actually scm_gc_malloc will give you back a zeroed array, afaik, as
GC_malloc does. The patch looks fine but if we can rely on
scm_gc_malloc's new behavior, we don't need the memset at all.
Thoughts from Ludovic would be nice :)
A
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-26 9:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-25 17:16 build failures from gcc warning about memset Julian Graham
2009-10-25 22:03 ` Ludovic Courtès
2009-10-25 22:04 ` Andy Wingo
2009-10-26 9:26 ` Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).