@@ -353,14 +353,21 @@
static int doioctl(int fd, int request, void *parm, const char *name)
{
int retVal;
+ int ioctl_errno;
if (!options[OptVerbose]) return ioctl(fd, request, parm);
retVal = ioctl(fd, request, parm);
- printf("%s: ", name);
- if (retVal < 0)
- printf("failed: %s\n", strerror(errno));
- else
- printf("ok\n");
+ if (options[OptVerbose]) {
+ /* Save errno because printf() may modify it */
+ ioctl_errno = errno;
+ printf("%s: ", name);
+ if (retVal < 0)
+ printf("failed: %s\n", strerror(errno));
+ else
+ printf("ok\n");
+ /* Restore errno for caller's use */
+ errno = ioctl_errno;
+ }
return retVal;
}
@@ -586,8 +593,8 @@
printf(" set to 0x%llx\n", set_reg.val);
} else {
- printf("Failed to set register 0x%08llx value 0x%llx\n",
- set_reg.reg, set_reg.val);
+ printf("Failed to set register 0x%08llx value 0x%llx: %s\n",
+ set_reg.reg, set_reg.val, strerror(errno));
}
set_reg.reg++;
}