chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
network-address,test-network: avoid undefined behaviour
[elogind.git]
/
src
/
udev
/
v4l_id
/
v4l_id.c
diff --git
a/src/udev/v4l_id/v4l_id.c
b/src/udev/v4l_id/v4l_id.c
index a2a80b5f4312fc3ad6a10a7d713387ed180c9bf1..0ebe43463992208ef1b28774c02d06e58c5487ab 100644
(file)
--- a/
src/udev/v4l_id/v4l_id.c
+++ b/
src/udev/v4l_id/v4l_id.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2009 Kay Sievers <kay
.sievers
@vrfy.org>
+ * Copyright (C) 2009 Kay Sievers <kay@vrfy.org>
* Copyright (c) 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
*
* This program is free software; you can redistribute it and/or
* Copyright (c) 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
*
* This program is free software; you can redistribute it and/or
@@
-18,11
+18,7
@@
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include <unistd.h>
-#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <sys/types.h>
#include <fcntl.h>
#include <getopt.h>
#include <sys/types.h>
@@
-30,17
+26,18
@@
#include <sys/ioctl.h>
#include <linux/videodev2.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>
-int main (int argc, char *argv[])
-{
+#include "util.h"
+
+int main(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{}
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{}
};
-
int fd
;
+
_cleanup_close_ int fd = -1
;
char *device;
struct v4l2_capability v2cap;
char *device;
struct v4l2_capability v2cap;
-
while (1
) {
+
for (;;
) {
int option;
option = getopt_long(argc, argv, "h", options, NULL);
int option;
option = getopt_long(argc, argv, "h", options, NULL);
@@
-49,7
+46,10
@@
int main (int argc, char *argv[])
switch (option) {
case 'h':
switch (option) {
case 'h':
- printf("Usage: v4l_id [--help] <device file>\n\n");
+ printf("%s [-h,--help] <device file>\n\n"
+ "Video4Linux device identification.\n\n"
+ " -h Print this message\n"
+ , program_invocation_short_name);
return 0;
default:
return 1;
return 0;
default:
return 1;
@@
-59,11
+59,11
@@
int main (int argc, char *argv[])
if (device == NULL)
return 2;
if (device == NULL)
return 2;
- fd = open
(device, O_RDONLY);
+ fd = open(device, O_RDONLY);
if (fd < 0)
return 3;
if (fd < 0)
return 3;
- if (ioctl
(fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
+ if (ioctl(fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
printf("ID_V4L_VERSION=2\n");
printf("ID_V4L_PRODUCT=%s\n", v2cap.card);
printf("ID_V4L_CAPABILITIES=:");
printf("ID_V4L_VERSION=2\n");
printf("ID_V4L_PRODUCT=%s\n", v2cap.card);
printf("ID_V4L_CAPABILITIES=:");
@@
-82,6
+82,5
@@
int main (int argc, char *argv[])
printf("\n");
}
printf("\n");
}
- close (fd);
return 0;
}
return 0;
}