All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Rosen Penev <rosenp@gmail.com>, linux-media@vger.kernel.org
Subject: Re: [PATCH 2/3] utils: switch strstr to std variant
Date: Mon, 11 May 2020 09:23:10 +0200	[thread overview]
Message-ID: <1b714b14-6d56-f697-7ef1-2b3411ee653d@xs4all.nl> (raw)
In-Reply-To: <20200511012549.1145814-2-rosenp@gmail.com>

On 11/05/2020 03:25, Rosen Penev wrote:
> strstr has const overloads in std, avoiding pointless conversions.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

This introduces a compile error:

v4l2-ctl-misc.cpp: In function ‘void misc_cmd(int, char*)’:
v4l2-ctl-misc.cpp:215:14: error: ‘strstr’ is not a member of ‘std’; did you mean ‘strstr’?
  215 |     if (std::strstr(value, "dht"))
      |              ^~~~~~
In file included from v4l2-ctl-misc.cpp:4:
/usr/include/string.h:323:1: note: ‘strstr’ declared here
  323 | strstr (const char *__haystack, const char *__needle) __THROW
      | ^~~~~~
v4l2-ctl-misc.cpp:217:14: error: ‘strstr’ is not a member of ‘std’; did you mean ‘strstr’?
  217 |     if (std::strstr(value, "dqt"))
      |              ^~~~~~
In file included from v4l2-ctl-misc.cpp:4:
/usr/include/string.h:323:1: note: ‘strstr’ declared here
  323 | strstr (const char *__haystack, const char *__needle) __THROW
      | ^~~~~~
v4l2-ctl-misc.cpp:219:14: error: ‘strstr’ is not a member of ‘std’; did you mean ‘strstr’?
  219 |     if (std::strstr(value, "dri"))
      |              ^~~~~~
In file included from v4l2-ctl-misc.cpp:4:
/usr/include/string.h:323:1: note: ‘strstr’ declared here
  323 | strstr (const char *__haystack, const char *__needle) __THROW
      | ^~~~~~

Probably a missing header.

Regards,

	Hans

> ---
>  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);
> 


  reply	other threads:[~2020-05-11  7:23 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 ` [PATCH 2/3] utils: switch strstr to std variant Rosen Penev
2020-05-11  7:23   ` Hans Verkuil [this message]
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=1b714b14-6d56-f697-7ef1-2b3411ee653d@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=rosenp@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.