misc: Appease GCC 8
authorJason Lowe-Power <jason@lowepower.com>
Fri, 3 Aug 2018 01:07:51 +0000 (18:07 -0700)
committerJason Lowe-Power <jason@lowepower.com>
Tue, 21 Aug 2018 14:41:29 +0000 (14:41 +0000)
GCC 8 adds a number of new warnings to -Wall which generate errors.

- Fix memset to 0 for structs by adding casts.
- Fix cast with const when the const was ignored.
- Fix catch a polymorphic type by value

We now compile with GCC 8!

Change-Id: Iab70ce11190eee67608fc25c0bedff170152b153
Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-on: https://gem5-review.googlesource.com/11949
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
src/arch/x86/decoder.hh
src/arch/x86/types.hh
src/base/bitunion.hh
src/cpu/testers/traffic_gen/pygen.cc
src/dev/storage/ide_ctrl.cc
src/dev/storage/ide_ctrl.hh

index 3630ea8c8dc170c604d085d689ebb9fbc0de1b85..c0b30b5e8ddd4a46902589305f20b7166821e2ba 100644 (file)
@@ -239,7 +239,7 @@ class Decoder
         outOfBytes(true), instDone(false),
         state(ResetState)
     {
-        memset(&emi, 0, sizeof(emi));
+        emi.reset();
         mode = LongMode;
         submode = SixtyFourBitMode;
         emi.mode.mode = mode;
index 6e1b1cf2fee458d6f90255883b6d60a901e410a3..f2b064650cd0d5e483c9f20c2ff0aca84a81d2e4 100644 (file)
@@ -199,6 +199,10 @@ namespace X86ISA
     //The intermediate structure used by the x86 decoder.
     struct ExtMachInst
     {
+        void reset() {
+            memset(static_cast<void *>(this), 0, sizeof(*this));
+        }
+
         //Prefixes
         LegacyPrefixVector legacy;
         Rex rex;
index 49a956eeccfcf05d0e4e08cccef9da6205e90529..1a32991a8a6f101c56686275e71b20ef2c5bbb60 100644 (file)
@@ -435,7 +435,7 @@ namespace BitfieldBackend
     inline std::ostream &
     bitfieldBackendPrinter(std::ostream &os, const char &t)
     {
-        os << (const int)t;
+        os << (int)t;
         return os;
     }
 
@@ -443,7 +443,7 @@ namespace BitfieldBackend
     inline std::ostream &
     bitfieldBackendPrinter(std::ostream &os, const unsigned char &t)
     {
-        os << (const unsigned int)t;
+        os << (unsigned int)t;
         return os;
     }
 }
index ce1d591301c5c82cadc2132bec413c96d1dc52b9..9ce2fbf83407c6320fd612a87d941661ee25cfcb 100644 (file)
@@ -74,7 +74,7 @@ PyTrafficGen::nextGenerator()
             metaGenerator->cast<std::shared_ptr<BaseGen>>();
         metaGenerator++;
         return gen;
-    } catch (py::cast_error) {
+    } catch (py::cast_error&) {
         fatal("Meta generator didn't return a valid trace generator\n");
     }
 }
index d1c9f7d73beea2ca1f222d031dbb4b8abf78f187..12d606beeff68427e32a7aaab47a1486ec09745b 100644 (file)
@@ -83,7 +83,7 @@ IdeController::Channel::Channel(
     cmdAddr(0), cmdSize(_cmdSize), ctrlAddr(0), ctrlSize(_ctrlSize),
     master(NULL), slave(NULL), selected(NULL)
 {
-    memset(&bmiRegs, 0, sizeof(bmiRegs));
+    bmiRegs.reset();
     bmiRegs.status.dmaCap0 = 1;
     bmiRegs.status.dmaCap1 = 1;
 }
index 94a9c65e58b373d2a547c5c3790ca4441d25900b..24d3da02a0bf7ebdde13ae4116df032034596a98 100644 (file)
@@ -81,6 +81,10 @@ class IdeController : public PciDevice
         /** Registers used for bus master interface */
         struct BMIRegs
         {
+            void reset() {
+                memset(static_cast<void *>(this), 0, sizeof(*this));
+            }
+
             BMICommandReg command;
             uint8_t reserved0;
             BMIStatusReg status;