v4l2-dbg: report fail reason to the user
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 15 Nov 2009 10:33:10 +0000 (11:33 +0100)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 15 Nov 2009 10:33:10 +0000 (11:33 +0100)
From: Marton Nemeth <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.

Priority: normal

Signed-off-by: Marton Nemeth <nm127@freemail.hu>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
[hverkuil@xs4all.nl: minor additional cleanup in doioctl()]
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
utils/v4l2-dbg.cpp

index 1a481c0..8c57c24 100644 (file)
@@ -352,15 +352,14 @@ static const char *binary(unsigned long long val)
 
 static int doioctl(int fd, int request, void *parm, const char *name)
 {
-       int retVal;
+       int retVal = ioctl(fd, request, parm);
 
-       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]) {
+               if (retVal < 0)
+                       printf("%s: failed: %s\n", name, strerror(errno));
+               else
+                       printf("%s: ok\n", name);
+       }
 
        return retVal;
 }
@@ -586,8 +585,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++;
                }