Browse Source

Fix compiler warning about memset() on image_config_t struct.

Petteri Aimonen 2 years ago
parent
commit
fc28a791d5
2 changed files with 18 additions and 5 deletions
  1. 10 2
      src/BlueSCSI_disk.cpp
  2. 8 3
      src/BlueSCSI_disk.h

+ 10 - 2
src/BlueSCSI_disk.cpp

@@ -150,8 +150,16 @@ static image_config_t g_DiskImages[S2S_MAX_TARGETS];
 
 void scsiDiskResetImages()
 {
-    for(int i = 0; i < S2S_MAX_TARGETS; i++)
-        g_DiskImages[i] = image_config_t();
+    for (int i = 0; i < S2S_MAX_TARGETS; i++)
+    {
+        g_DiskImages[i].clear();
+    }
+}
+
+void image_config_t::clear()
+{
+    static const image_config_t empty; // Statically zero-initialized
+    *this = empty;
 }
 
 void scsiDiskCloseSDCardImages()

+ 8 - 3
src/BlueSCSI_disk.h

@@ -43,9 +43,7 @@ extern "C" {
 // Extended configuration stored alongside the normal SCSI2SD target information
 struct image_config_t: public S2S_TargetCfg
 {
-    // There should be only one global instance of this struct per device, so disallow copy constructor.
-    image_config_t() = default;
-    image_config_t(const image_config_t&) = delete;
+    image_config_t() {};
 
     ImageBackingStore file;
 
@@ -83,6 +81,13 @@ struct image_config_t: public S2S_TargetCfg
 
     // Warning about geometry settings
     bool geometrywarningprinted;
+
+    // Clear any image state to zeros
+    void clear();
+
+private:
+    // There should be only one global instance of this struct per device, so make copy constructor private.
+    image_config_t(const image_config_t&) = default;
 };
 
 // Should be polled intermittently to update the platform eject buttons.