From 89bf8cd11f914eff585c23797fd88a641b9cb3dd Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 5 Sep 2008 08:27:28 +0200 Subject: v4l2-ctl: improve error reporting From: Hans Verkuil Based on a similar patch from Jean Delvare. By default errors are shown. --verbose also reports successful calls and --silent suppresses the output altogether, only returning an application error code. Priority: normal Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-ctl.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'v4l2-apps') diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index ae9293414..1c765cf96 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -93,6 +93,7 @@ enum Option { OptListFormats, OptLogStatus, OptVerbose, + OptSilent, OptGetVideoOutFormat, OptSetVideoOutFormat, OptGetSlicedVbiCap, @@ -291,15 +292,15 @@ static void usage(void) " set the video capture format [VIDIOC_S_FMT]\n" " pixelformat is either the format index as reported by\n" " --list-formats, or the fourcc value as a string\n" - " --verbose turn on verbose ioctl error reporting.\n" + " --silent only set the result code, do not print any messages\n" + " --verbose turn on verbose ioctl status reporting\n" "\n"); printf("Uncommon options:\n" " --get-fmt-video-out\n" " query the video output format [VIDIOC_G_FMT]\n" " --set-fmt-video-out=width=,height=\n" " set the video output format [VIDIOC_S_FMT]\n" - " --get-fmt-overlay\n" - " query the video overlay format [VIDIOC_G_FMT]\n" + " --get-fmt-overlay query the video overlay format [VIDIOC_G_FMT]\n" " --get-fmt-output-overlay\n" " query the video output overlay format [VIDIOC_G_FMT]\n" " --set-fmt-output-overlay=chromakey=,global_alpha=\n" @@ -1017,12 +1018,11 @@ static int doioctl(int fd, int request, void *parm, const char *name) if (retVal < 0) { app_result = -1; } - if (!options[OptVerbose]) return retVal; - printf("%s: ", name); + if (options[OptSilent]) return retVal; if (retVal < 0) - printf("failed: %s\n", strerror(errno)); - else - printf("ok\n"); + printf("%s: failed: %s\n", name, strerror(errno)); + else if (options[OptVerbose]) + printf("%s: ok\n", name); return retVal; } -- cgit v1.2.3