]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
psim.cc: change initialzation of VLAs
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 10 Apr 2015 08:19:25 +0000 (10:19 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 15 Apr 2015 10:34:50 +0000 (12:34 +0200)
Use memset to fill integer VLAs.

Fix for:

CID 1219649 (#1 of 1): Uninitialized scalar variable (UNINIT)
 uninit_use: Using uninitialized value primary_count[primary]

CID 1219648 (#1 of 1): Uninitialized scalar variable (UNINIT)
 uninit_use: Using uninitialized value first_count[osds[0UL]]

CID 1219647 (#1 of 1): Uninitialized scalar variable (UNINIT)
 uninit_use: Using uninitialized value count[osds[i]]

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/tools/psim.cc

index 3022b1c15042b7f1718b1b764b48bee8e35799ba..04a1987d2ec36eabaa0ef9036b58434be0715100 100644 (file)
@@ -32,22 +32,22 @@ int main(int argc, char **argv)
   int count[n];
   int first_count[n];
   int primary_count[n];
+  int size[4];
+
+  memset(count, 0, sizeof(count));
+  memset(first_count, 0, sizeof(first_count));
+  memset(primary_count, 0, sizeof(primary_count));
+  memset(size, 0, sizeof(size));
+
   for (int i=0; i<n; i++) {
     osdmap.set_state(i, osdmap.get_state(i) | CEPH_OSD_UP);
     //if (i<12)
       osdmap.set_weight(i, CEPH_OSD_IN);
-    count[i] = 0;
-    first_count[i] = 0;
-    primary_count[i] = 0;
   }
 
   //pg_pool_t *p = (pg_pool_t *)osdmap.get_pg_pool(0);
   //p->type = pg_pool_t::TYPE_ERASURE;
 
-  int size[4];
-  for (int i=0; i<4; i++)
-    size[i] = 0;
-
   for (int n = 0; n < 10; n++) {   // namespaces
     char nspace[20];
     snprintf(nspace, sizeof(nspace), "n%d", n);