tests: Fix virmacmaptest when allocation fails

If the allocation fails in DO_TEST_FLUSH_PROLOGUE, then 'mgr == NULL',
but the code continues on - which won't be good. So modify the macro
to cause an immediate failure and jump to a cleanup label.

Found by Coverity as FORWARD_NULL event.
This commit is contained in:
John Ferlan 2016-12-07 08:07:54 -05:00
parent 0658184944
commit 80acf4b867

View File

@ -170,8 +170,12 @@ mymain(void)
} while (0)
#define DO_TEST_FLUSH_PROLOGUE \
if (!(mgr = virMacMapNew(NULL))) \
ret = -1;
do { \
if (!(mgr = virMacMapNew(NULL))) { \
ret = -1; \
goto cleanup; \
} \
} while (0)
#define DO_TEST_FLUSH(d, ...) \
do { \
@ -226,6 +230,7 @@ mymain(void)
DO_TEST_FLUSH("dom1", "9e:89:49:99:51:0e", "89:b4:3f:08:88:2c", "54:0b:4c:e2:0a:39");
DO_TEST_FLUSH("dom1", "bb:88:07:19:51:9d", "b7:f1:1a:40:a2:95", "88:94:39:a3:90:b4");
DO_TEST_FLUSH_EPILOGUE("complex");
cleanup:
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}