Linux Media Controller development
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-media@vger.kernel.org
Subject: [PATCH 2/3] utils: switch strstr to std variant
Date: Sun, 10 May 2020 18:25:48 -0700	[thread overview]
Message-ID: <20200511012549.1145814-2-rosenp@gmail.com> (raw)
In-Reply-To: <20200511012549.1145814-1-rosenp@gmail.com>

strstr has const overloads in std, avoiding pointless conversions.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 utils/libcecutil/cec-log.cpp       | 2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp | 4 ++--
 utils/v4l2-ctl/v4l2-ctl-misc.cpp   | 6 +++---
 utils/v4l2-dbg/v4l2-dbg.cpp        | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/utils/libcecutil/cec-log.cpp b/utils/libcecutil/cec-log.cpp
index 9410c071..0dcb4675 100644
--- a/utils/libcecutil/cec-log.cpp
+++ b/utils/libcecutil/cec-log.cpp
@@ -62,7 +62,7 @@ static void log_arg(const struct cec_arg *arg, const char *arg_name, __u32 val)
 		}
 		return;
 	case CEC_ARG_TYPE_U16:
-		if (strstr(arg_name, "phys-addr"))
+		if (std::strstr(arg_name, "phys-addr"))
 			printf("\t%s: %x.%x.%x.%x\n", arg_name, cec_phys_addr_exp(val));
 		else
 			printf("\t%s: %u (0x%04x)\n", arg_name, val, val);
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index 47f5da1a..0640a521 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -1190,13 +1190,13 @@ void common_get(cv4l_fd &_fd)
 				char *q;
 
 				buf[len] = 0;
-				while ((q = strstr(p, "START STATUS"))) {
+				while ((q = std::strstr(p, "START STATUS"))) {
 					p = q + 1;
 				}
 				if (p) {
 					while (p > buf && *p != '<') p--;
 					q = p;
-					while ((q = strstr(q, "<6>"))) {
+					while ((q = std::strstr(q, "<6>"))) {
 						memcpy(q, "   ", 3);
 					}
 					printf("%s", p);
diff --git a/utils/v4l2-ctl/v4l2-ctl-misc.cpp b/utils/v4l2-ctl/v4l2-ctl-misc.cpp
index 6db87568..deb481b4 100644
--- a/utils/v4l2-ctl/v4l2-ctl-misc.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-misc.cpp
@@ -212,11 +212,11 @@ void misc_cmd(int ch, char *optarg)
 				jpegcomp.quality = strtol(value, 0L, 0);
 				break;
 			case 17:
-				if (strstr(value, "dht"))
+				if (std::strstr(value, "dht"))
 					jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DHT;
-				if (strstr(value, "dqt"))
+				if (std::strstr(value, "dqt"))
 					jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DQT;
-				if (strstr(value, "dri"))
+				if (std::strstr(value, "dri"))
 					jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DRI;
 				break;
 			case 18:
diff --git a/utils/v4l2-dbg/v4l2-dbg.cpp b/utils/v4l2-dbg/v4l2-dbg.cpp
index 86266376..06301ae0 100644
--- a/utils/v4l2-dbg/v4l2-dbg.cpp
+++ b/utils/v4l2-dbg/v4l2-dbg.cpp
@@ -784,14 +784,14 @@ list_done:
 				char *q;
 
 				buf[len] = 0;
-				while ((q = strstr(p, "START STATUS"))) {
+				while ((q = std::strstr(p, "START STATUS"))) {
 					found_status = true;
 					p = q + 1;
 				}
 				if (found_status) {
 					while (p > buf && *p != '<') p--;
 					q = p;
-					while ((q = strstr(q, "<6>"))) {
+					while ((q = std::strstr(q, "<6>"))) {
 						memcpy(q, "   ", 3);
 					}
 					printf("%s", p);
-- 
2.26.2


  reply	other threads:[~2020-05-11  1:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11  1:25 [PATCH 1/3] utils: replace chr functions with std variants Rosen Penev
2020-05-11  1:25 ` Rosen Penev [this message]
2020-05-11  7:23   ` [PATCH 2/3] utils: switch strstr to std variant Hans Verkuil
2020-05-12  6:00     ` Rosen Penev
2020-05-11  1:25 ` [PATCH 3/3] utils: switch C to C++ headers Rosen Penev
2020-05-11  7:21   ` Hans Verkuil
2020-05-12 20:51     ` Rosen Penev

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=20200511012549.1145814-2-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=linux-media@vger.kernel.org \
    /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