hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 28 Mar 2013 18:43:04 +0000 (18:43 +0000)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 1 Apr 2013 14:08:33 +0000 (09:08 -0500)
Make sure we set the buffer to something in the softusb_read_{dmem,pmem}
error paths, since the caller will use the buffer unconditionally.
(Newer gcc is smart enough to spot this and complain about 'may be
used uninitialized'.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1364496184-11994-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/milkymist-softusb.c

index b279d4e908ba48c379ab6d39698ff0fe4dd88827..90a0ae57696dca218ac5165278c975c316267e5e 100644 (file)
@@ -132,6 +132,7 @@ static inline void softusb_read_dmem(MilkymistSoftUsbState *s,
     if (offset + len >= s->dmem_size) {
         error_report("milkymist_softusb: read dmem out of bounds "
                 "at offset 0x%x, len %d", offset, len);
+        memset(buf, 0, len);
         return;
     }
 
@@ -156,6 +157,7 @@ static inline void softusb_read_pmem(MilkymistSoftUsbState *s,
     if (offset + len >= s->pmem_size) {
         error_report("milkymist_softusb: read pmem out of bounds "
                 "at offset 0x%x, len %d", offset, len);
+        memset(buf, 0, len);
         return;
     }