From: "Németh Márton" <nm127@freemail.hu>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Hans de Goede <hdegoede@redhat.com>,
Jean-Francois Moine <moinejf@free.fr>,
V4L Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH] v4l2-dbg: report fail reason to the user
Date: Thu, 12 Nov 2009 08:23:41 +0100 [thread overview]
Message-ID: <4AFBB7FD.5090607@freemail.hu> (raw)
In-Reply-To: <4AF8F8EB.8090705@freemail.hu>
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>
---
diff -r 60f784aa071d v4l2-apps/util/v4l2-dbg.cpp
--- a/v4l2-apps/util/v4l2-dbg.cpp Wed Nov 11 18:28:53 2009 +0100
+++ b/v4l2-apps/util/v4l2-dbg.cpp Thu Nov 12 08:21:20 2009 +0100
@@ -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++;
}
next prev parent reply other threads:[~2009-11-12 7:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-08 12:32 [PATCH] v4l2-dbg: report fail reason to the user Németh Márton
2009-11-09 10:16 ` Hans Verkuil
2009-11-10 5:23 ` Németh Márton
2009-11-12 7:23 ` Németh Márton [this message]
2009-11-12 7:29 ` Hans Verkuil
2009-11-12 8:16 ` Németh Márton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AFBB7FD.5090607@freemail.hu \
--to=nm127@freemail.hu \
--cc=hdegoede@redhat.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=moinejf@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox