]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix build with older gcc
authorJán Tomko <jtomko@redhat.com>
Fri, 23 Jan 2015 09:30:01 +0000 (10:30 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 23 Jan 2015 09:35:20 +0000 (10:35 +0100)
My commit af1c98e4 broke the build on RHEL-6:
vircgrouptest.c: In function 'testCgroupGetPercpuStats':
vircgrouptest.c:566: error: nested extern declaration of
'_gl_verify_function2' [-Wnested-externs]

The only thing that needs checking is that the array size
is at least EXPECTED_NCPUS, to prevent access beyond the array.

We can ensure the minimum size also by specifying the array
size upfront.

tests/vircgrouptest.c

index b65ea3fba5d17f817f9a42dbc80aff0cfc0d2be5..a455a8101ab6bf06c114bbf46f35bbca3a5f47c4 100644 (file)
@@ -541,7 +541,7 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
     virTypedParameterPtr params = NULL;
 # define EXPECTED_NCPUS 160
 
-    unsigned long long expected[] = {
+    unsigned long long expected[EXPECTED_NCPUS] = {
         0, 0, 0, 0, 0, 0, 0, 0,
         7059492996, 0, 0, 0, 0, 0, 0, 0,
         4180532496, 0, 0, 0, 0, 0, 0, 0,
@@ -563,7 +563,6 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
         5683512916, 0, 0, 0, 0, 0, 0, 0,
         635751356, 0, 0, 0, 0, 0, 0, 0,
     };
-    verify(ARRAY_CARDINALITY(expected) == EXPECTED_NCPUS);
 
     if (VIR_ALLOC_N(params, EXPECTED_NCPUS) < 0)
         goto cleanup;