Why is it that I don't see anything displayed when I run this? I was expecting EINVAL
to be printed instead of nothing.
#include <stdio.h>
unsigned int set_request(int val)
{
printf("set_request entry\n");
return 0;
}
void main()
{
unsigned int val = 2;
if (val == 0 || val == 1)
if (set_request(val))
printf("EIO\n");
else
printf("EINVAL\n");
}
jj@coffy:~/nvmemaster/tmp$ ./a.out
jj@coffy:~/nvmemaster/tmp$
I am getting the right behaviour when I add {}
, but I would like to know the behaviour of if
without {}
.
Alternatively if I modify the assignment line to 0 as shown below, then I am seeing something else odd. Now I wasn't expecting EINVAL
to be printed.
#include <stdio.h>
unsigned int set_request(int val)
{
printf("set_request entry\n");
return 0;
}
void main()
{
unsigned int val = 0;
if (val == 0 || val == 1)
if (set_request(val))
printf("EIO\n");
else
printf("EINVAL\n");
}
jj@coffy:~/nvmemaster/tmp$ gcc if.c
jj@coffy:~/nvmemaster/tmp$ ./a.out
set_request entry
EINVAL
jj@coffy:~/nvmemaster/tmp$