mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
eventtest.c: detect write failure and avoid dead stores
* tests/eventtest.c (mymain): Exit nonzero upon write failure. This also avoids several dead stores of the form ret = safewrite...
This commit is contained in:
parent
198bd0516a
commit
25b20b7103
@ -248,7 +248,6 @@ resetAll(void)
|
|||||||
static int
|
static int
|
||||||
mymain(int argc, char **argv)
|
mymain(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
char *progname;
|
char *progname;
|
||||||
int i;
|
int i;
|
||||||
pthread_t eventThread;
|
pthread_t eventThread;
|
||||||
@ -304,7 +303,8 @@ mymain(int argc, char **argv)
|
|||||||
/* First time, is easy - just try triggering one of our
|
/* First time, is easy - just try triggering one of our
|
||||||
* registered handles */
|
* registered handles */
|
||||||
startJob("Simple write", &test);
|
startJob("Simple write", &test);
|
||||||
ret = safewrite(handles[1].pipeFD[1], &one, 1);
|
if (safewrite(handles[1].pipeFD[1], &one, 1) != 1)
|
||||||
|
return EXIT_FAILURE;
|
||||||
if (finishJob(1, -1) != EXIT_SUCCESS)
|
if (finishJob(1, -1) != EXIT_SUCCESS)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
@ -314,7 +314,8 @@ mymain(int argc, char **argv)
|
|||||||
* try triggering another handle */
|
* try triggering another handle */
|
||||||
virEventRemoveHandleImpl(handles[0].watch);
|
virEventRemoveHandleImpl(handles[0].watch);
|
||||||
startJob("Deleted before poll", &test);
|
startJob("Deleted before poll", &test);
|
||||||
ret = safewrite(handles[1].pipeFD[1], &one, 1);
|
if (safewrite(handles[1].pipeFD[1], &one, 1) != 1)
|
||||||
|
return EXIT_FAILURE;
|
||||||
if (finishJob(1, -1) != EXIT_SUCCESS)
|
if (finishJob(1, -1) != EXIT_SUCCESS)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
@ -346,8 +347,9 @@ mymain(int argc, char **argv)
|
|||||||
* about */
|
* about */
|
||||||
startJob("Deleted during dispatch", &test);
|
startJob("Deleted during dispatch", &test);
|
||||||
handles[2].delete = handles[3].watch;
|
handles[2].delete = handles[3].watch;
|
||||||
ret = safewrite(handles[2].pipeFD[1], &one, 1);
|
if (safewrite(handles[2].pipeFD[1], &one, 1) != 1
|
||||||
ret = safewrite(handles[3].pipeFD[1], &one, 1);
|
|| safewrite(handles[3].pipeFD[1], &one, 1) != 1)
|
||||||
|
return EXIT_FAILURE;
|
||||||
if (finishJob(2, -1) != EXIT_SUCCESS)
|
if (finishJob(2, -1) != EXIT_SUCCESS)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
@ -356,7 +358,8 @@ mymain(int argc, char **argv)
|
|||||||
/* Extreme fun, lets delete ourselves during dispatch */
|
/* Extreme fun, lets delete ourselves during dispatch */
|
||||||
startJob("Deleted during dispatch", &test);
|
startJob("Deleted during dispatch", &test);
|
||||||
handles[2].delete = handles[2].watch;
|
handles[2].delete = handles[2].watch;
|
||||||
ret = safewrite(handles[2].pipeFD[1], &one, 1);
|
if (safewrite(handles[2].pipeFD[1], &one, 1) != 1)
|
||||||
|
return EXIT_FAILURE;
|
||||||
if (finishJob(2, -1) != EXIT_SUCCESS)
|
if (finishJob(2, -1) != EXIT_SUCCESS)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
@ -446,7 +449,8 @@ mymain(int argc, char **argv)
|
|||||||
testPipeReader,
|
testPipeReader,
|
||||||
&handles[1], NULL);
|
&handles[1], NULL);
|
||||||
startJob("Write duplicate", &test);
|
startJob("Write duplicate", &test);
|
||||||
ret = safewrite(handles[1].pipeFD[1], &one, 1);
|
if (safewrite(handles[1].pipeFD[1], &one, 1) != 1)
|
||||||
|
return EXIT_FAILURE;
|
||||||
if (finishJob(1, -1) != EXIT_SUCCESS)
|
if (finishJob(1, -1) != EXIT_SUCCESS)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user