On Mon, May 11, 2020 at 12:23 AM Hans Verkuil <hverkuil@xxxxxxxxx> wrote: > > On 11/05/2020 03:25, Rosen Penev wrote: > > strstr has const overloads in std, avoiding pointless conversions. > > > > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx> > > 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. Fixed by my other patch of course :). > > 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); > > >