summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 13:54:32 -0500
committerAnthony G. Basile <blueness@gentoo.org>2015-03-18 19:07:03 -0400
commita46b4ff7cc207dd7cc0d5cc22d721fee77debe8b (patch)
tree047f7189ddbe718f167c95cd35449683cc25761e
parenta45a9a1c320d87a5d2448b4773395374f771d1e5 (diff)
v4l_id: use standard option parsing loop
Not terribly important, but the loop wasn't an actual loop, making coverity unhappy. CID #1261725. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-rw-r--r--src/v4l_id/v4l_id.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/v4l_id/v4l_id.c b/src/v4l_id/v4l_id.c
index 0e3d3003cb..1dce0d5665 100644
--- a/src/v4l_id/v4l_id.c
+++ b/src/v4l_id/v4l_id.c
@@ -40,29 +40,28 @@ int main(int argc, char *argv[]) {
_cleanup_close_ int fd = -1;
char *device;
struct v4l2_capability v2cap;
+ int c;
- for (;;) {
- int option;
+ while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
- option = getopt_long(argc, argv, "h", options, NULL);
- if (option == -1)
- break;
-
- switch (option) {
+ switch (c) {
case 'h':
printf("%s [-h,--help] <device file>\n\n"
"Video4Linux device identification.\n\n"
" -h Print this message\n"
, program_invocation_short_name);
return 0;
+ case '?':
+ return -EINVAL;
+
default:
- return 1;
+ assert_not_reached("Unhandled option");
}
- }
- device = argv[optind];
+ device = argv[optind];
if (device == NULL)
return 2;
+
fd = open(device, O_RDONLY);
if (fd < 0)
return 3;