aboutsummaryrefslogtreecommitdiffstats
path: root/utils/v4l2-ctl
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-05-10 18:25:47 -0700
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-05-11 09:21:29 +0200
commitbbdc0269bf49aa8dd8259d0c31efff2366f6647f (patch)
tree516c2ef42233cb6b5c71a8100a4ae71f87cf6fd8 /utils/v4l2-ctl
parentc39488120a52f88b730c406e2c6abf3176f5d06f (diff)
utils: replace chr functions with std variants
*chr in std offers const overloads, which avoid conversions. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'utils/v4l2-ctl')
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-common.cpp10
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-edid.cpp5
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-streaming.cpp7
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-vbi.cpp5
4 files changed, 15 insertions, 12 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index bbd00e95..47f5da1a 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -1,7 +1,6 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include <inttypes.h>
#include <getopt.h>
#include <sys/types.h>
@@ -22,6 +21,7 @@
#include <sys/klog.h>
#endif
+#include <cstring>
#include <list>
#include <vector>
#include <map>
@@ -152,7 +152,7 @@ static int calc_node_val(const char *s)
{
int n = 0;
- s = strrchr(s, '/') + 1;
+ s = std::strrchr(s, '/') + 1;
for (unsigned i = 0; prefixes[i]; i++) {
unsigned l = strlen(prefixes[i]);
@@ -741,7 +741,7 @@ static bool parse_subset(char *optarg)
memset(&subset, 0, sizeof(subset));
while (*optarg) {
- p = strchr(optarg, ',');
+ p = std::strchr(optarg, ',');
if (p)
*p = 0;
if (optarg[0] == 0) {
@@ -808,7 +808,7 @@ void common_cmd(const std::string &media_bus_info, int ch, char *optarg)
common_usage();
std::exit(EXIT_FAILURE);
}
- if (strchr(value, '=')) {
+ if (std::strchr(value, '=')) {
common_usage();
std::exit(EXIT_FAILURE);
}
@@ -824,7 +824,7 @@ void common_cmd(const std::string &media_bus_info, int ch, char *optarg)
common_usage();
std::exit(EXIT_FAILURE);
}
- if (const char *equal = strchr(value, '=')) {
+ if (const char *equal = std::strchr(value, '=')) {
set_ctrls[std::string(value, (equal - value))] = equal + 1;
}
else {
diff --git a/utils/v4l2-ctl/v4l2-ctl-edid.cpp b/utils/v4l2-ctl/v4l2-ctl-edid.cpp
index a2df6089..b13d8209 100644
--- a/utils/v4l2-ctl/v4l2-ctl-edid.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-edid.cpp
@@ -1,7 +1,8 @@
+#include <cstring>
+
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include <inttypes.h>
#include <fcntl.h>
#include <ctype.h>
@@ -710,7 +711,7 @@ static unsigned short parse_phys_addr(const char *value)
{
unsigned p1, p2, p3, p4;
- if (!strchr(value, '.'))
+ if (!std::strchr(value, '.'))
return strtoul(value, NULL, 0);
if (sscanf(value, "%x.%x.%x.%x", &p1, &p2, &p3, &p4) != 4) {
fprintf(stderr, "Expected a physical address of the form x.x.x.x\n");
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 0d5a1e1a..8578610d 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -1,7 +1,8 @@
+#include <cstring>
+
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include <inttypes.h>
#include <getopt.h>
#include <sys/types.h>
@@ -1660,7 +1661,7 @@ static FILE *open_output_file(cv4l_fd &fd)
if (!host_to)
return NULL;
- char *p = strchr(host_to, ':');
+ char *p = std::strchr(host_to, ':');
struct sockaddr_in serv_addr;
struct hostent *server;
struct v4l2_fract aspect;
@@ -1925,7 +1926,7 @@ static FILE *open_input_file(cv4l_fd &fd, __u32 type)
if (!host_from)
return NULL;
- char *p = strchr(host_from, ':');
+ char *p = std::strchr(host_from, ':');
int listen_fd;
socklen_t clilen;
struct sockaddr_in serv_addr = {}, cli_addr;
diff --git a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
index 6a4f627f..ee55012f 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
@@ -1,7 +1,8 @@
+#include <cstring>
+
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include <inttypes.h>
#include <getopt.h>
#include <sys/types.h>
@@ -98,7 +99,7 @@ void vbi_cmd(int ch, char *optarg)
std::exit(EXIT_FAILURE);
}
while (*optarg) {
- subs = strchr(optarg, ',');
+ subs = std::strchr(optarg, ',');
if (subs)
*subs = 0;

Privacy Policy