v4l2-dbg: report fail reason to the user
authorMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 12 Nov 2009 08:16:11 +0000 (08:16 +0000)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 12 Nov 2009 08:16:11 +0000 (08:16 +0000)
From: Márton Németh <nm127@freemail.hu>

Report the fail reason to the user when writing a register even if
the verbose mode is switched off.

Remove duplicated code ioctl() call which may cause different ioctl()
function call in case of verbose and non verbose if not handled carefully.

Signed-off-by: Márton Németh <nm127@freemail.hu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
utils/v4l2-dbg.cpp

index 1a481c0..9ba0a65 100644 (file)
@@ -354,13 +354,14 @@ static int doioctl(int fd, int request, void *parm, const char *name)
 {
        int retVal;
 
-       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]) {
+               printf("%s: ", name);
+               if (retVal < 0)
+                       printf("failed: %s\n", strerror(errno));
+               else
+                       printf("ok\n");
+       }
 
        return retVal;
 }
@@ -586,8 +587,8 @@ int main(int argc, char **argv)
 
                                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++;
                }