In my development environment some of the ioctl
calls are failing on the first time, if I am calling the same ioctl
again then it returning success.
This is because of some hardware related time synchronization issues.
So we are going for some temporary solution like masking all ioctl
with one MACRO
, inside that MACRO
calling ioctl
three times.
but that MACRO
throws compilation error. Please suggest some solution to resolve this issue.
Sample Code
#include <stdio.h>
int func (int a, int b, int c)
{
return -1;
}
#define IOCTL_WRAPPER(a,b,c) \
{ \
int i = 0, retval = 0; \
while (i < 3) \
{ \
retval = func (a, b, c); \
if (retval != -1) \
{ \
break; \
} \
i++; \
} \
retval; \
}
int main ()
{
int RetVal = 0;
RetVal = IOCTL_WRAPPER(1, 2, 3);
if (RetVal != -1)
{
printf ("\n pass \n");
}
else
{
printf ("\n fail \n");
}
return 0;
}
Compilation Error
a.c: In function âmainâ:
a.c:9:13: error: expected expression before â{â token
{ \
^
a.c:27:14: note: in expansion of macro âIOCTL_WRAPPERâ
RetVal = IOCTL_WRAPPER(1, 2, 3);
^