Skip to contentSkip to conversation

scsi-generic: correct usage of memset().

PATCH Applied Laurent Vivier 2 participants 2 messages Sep 22, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi-generic: correct usage of memset().

      void *memset(void *s, int c, size_t n);

DESCRIPTION
The memset() function fills the first n bytes of the
memory area
pointed to by s with the constant byte c."

Reported by Dietmar Maurer.

---
 hw/scsi-generic.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi-generic.c +2 -2
Index: qemu/hw/scsi-generic.c
===================================================================
@@ -548,8 +548,8 @@ static int get_blocksize(BlockDriverStat
     sg_io_hdr_t io_header;
     int ret;
 
-    memset(cmd, sizeof(cmd), 0);
-    memset(buf, sizeof(buf), 0);
+    memset(cmd, 0, sizeof(cmd));
+    memset(buf, 0, sizeof(buf));
     cmd[0] = READ_CAPACITY;
 
     memset(&io_header, 0, sizeof(io_header));
#1 lore raw
Quoted 9 lines · Laurent Vivier
      void *memset(void *s, int c, size_t n);

DESCRIPTION
The memset() function fills the first n bytes of the
memory area
pointed to by s with the constant byte c."

Reported by Dietmar Maurer.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 24 lines
---
 hw/scsi-generic.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: qemu/hw/scsi-generic.c
===================================================================

hw/scsi-generic.c +2 -2
@@ -548,8 +548,8 @@ static int get_blocksize(BlockDriverStat
     sg_io_hdr_t io_header;
     int ret;
 
-    memset(cmd, sizeof(cmd), 0);
-    memset(buf, sizeof(buf), 0);
+    memset(cmd, 0, sizeof(cmd));
+    memset(buf, 0, sizeof(buf));
     cmd[0] = READ_CAPACITY;
 
     memset(&io_header, 0, sizeof(io_header));