[ipxe-devel] [PATCH] Fix size used for memset in alloc_output_file (zbin.c)
Daniel P. Berrange
berrange at redhat.com
Tue Mar 5 15:18:20 UTC 2013
From: "Daniel P. Berrange" <berrange at redhat.com>
The 'output->buf' field is a char pointer, not an array,
so sizeof() is not applicable - must use the allocated
string length instead.
Identified by gcc:
util/zbin.c: In function ‘alloc_output_file’:
util/zbin.c:146:37: warning: argument to ‘sizeof’ in ‘memset’ call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
memset ( output->buf, 0xff, sizeof ( output->buf ) );
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
src/util/zbin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/zbin.c b/src/util/zbin.c
index 0dabaf1..3b7cf95 100644
--- a/src/util/zbin.c
+++ b/src/util/zbin.c
@@ -143,7 +143,7 @@ static int alloc_output_file ( size_t max_len, struct output_file *output ) {
max_len );
return -1;
}
- memset ( output->buf, 0xff, sizeof ( output->buf ) );
+ memset ( output->buf, 0xff, max_len );
return 0;
}
--
1.8.1.4
More information about the ipxe-devel
mailing list