dev, arm: fix error class-memaccess with GCC >= 8.1
authorMaurice Becker <madnaurice@googlemail.com>
Tue, 18 Sep 2018 08:14:24 +0000 (10:14 +0200)
committerMaurice Becker <madnaurice@googlemail.com>
Tue, 18 Sep 2018 16:57:56 +0000 (16:57 +0000)
From GCC 8.1 on GCC issues a warning when using memset et al on structs and
classes. With the way gem5 builds, this actually prevents successful
builds.

Instead of using a pointer with SCSIReply as type, we cast to a void
pointer to avoid the message. On the way we wrap the memset call into a
method of SCSIReply called reset for better code readability.

Signed-off-by: Maurice Becker <madnaurice@googlemail.com>
Change-Id: I3ed3fd9714be5d253aba01ca00b1863e1ae5cb68
Reviewed-on: https://gem5-review.googlesource.com/12685
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/dev/arm/ufs_device.cc
src/dev/arm/ufs_device.hh

index cd1bbcafbed399462eed7fbbfe93aef3c4f96990..137ad8c2750fa2cbfc60a9605a8f39212a164682 100644 (file)
@@ -161,7 +161,7 @@ struct UFSHostDevice::SCSIReply
 UFSHostDevice::UFSSCSIDevice::SCSICMDHandle(uint32_t* SCSI_msg)
 {
     struct SCSIReply scsi_out;
-    memset(&scsi_out, 0, sizeof(struct SCSIReply));
+    scsi_out.reset();
 
     /**
      * Create the standard SCSI reponse information
index 69abc27411d10bdd928307b857ce3ae277eeea6d..97b9693ce505aff1848129de4a8d308639b87050 100644 (file)
@@ -373,6 +373,10 @@ class UFSHostDevice : public DmaDevice
      * build a SCSI reply.
      */
     struct SCSIReply {
+        void reset() {
+            memset(static_cast<void*>(this), 0, sizeof(*this));
+        }
+
         uint8_t status;
         uint32_t msgSize;
         uint8_t LUN;