psim.cc: change initialzation of VLAs

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>
This commit is contained in:
Danny Al-Gaaf 2015-04-10 10:19:25 +02:00
parent c3b2e872d3
commit 655c12ac50

View 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);