From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, hverkuil@xs4all.nl
Subject: Re: [v4l-utils PATCH 1/1] v4l: libv4l2subdev: Precisely convert media bus string to code
Date: Sun, 13 Dec 2015 23:33:45 +0200 [thread overview]
Message-ID: <32957783.JQTylZjONc@avalon> (raw)
In-Reply-To: <1449674087-19122-1-git-send-email-sakari.ailus@linux.intel.com>
Hi Sakari,
Thank you for the patch.
On Wednesday 09 December 2015 17:14:47 Sakari Ailus wrote:
> The length of the string was ignored, making it possible for the
> conversion to fail due to extra characters in the string.
I'm not sure to follow you there. Is the issue that passing a string such as
"SBGGR10" would match "SBGGR10_DPCM8" if it was listed before "SBGGR10" ? If
that's the case I'd write the commit message as
Any character beyond the fist `length' characters in the mbus_formats strings
are ignored, causing incorrect matches if the format entry starts with but
isn't equal to the passed format.
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> This patch should be applied before the set "[v4l-utils PATCH v2 0/3] List
> supported formats in libv4l2subdev":
>
> <URL:http://www.spinics.net/lists/linux-media/msg95377.html>
>
> utils/media-ctl/libv4l2subdev.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/utils/media-ctl/libv4l2subdev.c
> b/utils/media-ctl/libv4l2subdev.c index 33c1ee6..cce527d 100644
> --- a/utils/media-ctl/libv4l2subdev.c
> +++ b/utils/media-ctl/libv4l2subdev.c
> @@ -769,14 +769,12 @@ enum v4l2_mbus_pixelcode
> v4l2_subdev_string_to_pixelcode(const char *string, unsigned int i;
>
> for (i = 0; i < ARRAY_SIZE(mbus_formats); ++i) {
> - if (strncmp(mbus_formats[i].name, string, length) == 0)
> - break;
> + if (strncmp(mbus_formats[i].name, string, length) == 0
> + && strlen(mbus_formats[i].name) == length)
How about mbus_formats[i].name[length] == '\0' instead ? That should be more
efficient.
I also wonder whether we shouldn't just get rid of the length argument and
force the passed format string to be zero-terminated.
> + return mbus_formats[i].code;
> }
>
> - if (i == ARRAY_SIZE(mbus_formats))
> - return (enum v4l2_mbus_pixelcode)-1;
> -
> - return mbus_formats[i].code;
> + return (enum v4l2_mbus_pixelcode)-1;
> }
>
> static struct {
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2015-12-14 1:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-09 15:14 [v4l-utils PATCH 1/1] v4l: libv4l2subdev: Precisely convert media bus string to code Sakari Ailus
2015-12-13 21:33 ` Laurent Pinchart [this message]
2016-01-25 11:39 ` Sakari Ailus
2016-01-25 19:41 ` Laurent Pinchart
2016-01-25 20:47 ` Sakari Ailus
2016-01-25 20:53 ` Laurent Pinchart
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=32957783.JQTylZjONc@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox