I wish to use ||
statements to stop execution flow once any of my functions returns a non-zero error code. However, if I use "bare" logical statements, as in
void function myFun(void)
{
struct myStruct *test = malloc(sizeof(struct myStruct));
if (!test)
return ;
(subFun1(&test) ||
subFun2(&test) ||
subFun3(&test) ||
subFun4(&test));
free(test);
}
gcc complains
error: value computed is not used [-Werror=unused-value]
I could also write something like that,
void function myFun(void)
{
struct myStruct *test = malloc(sizeof(struct myStruct));
if (!test)
return ;
if (subFun1(&test) ||
subFun2(&test) ||
subFun3(&test) ||
subFun4(&test))
;
free(test);
}
but it looks super-awkward.
What is the best way to handle this?