* [PATCH v2 1/1] v4l: libv4l2subdev: Precisely convert media bus string to code
@ 2016-01-25 12:35 Sakari Ailus
2016-01-25 19:41 ` Laurent Pinchart
0 siblings, 1 reply; 2+ messages in thread
From: Sakari Ailus @ 2016-01-25 12:35 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, hverkuil
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>
---
since v1:
- Use mbus_formats[i].name[length] == '\0' instead of comparing strlen()
result.
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..dc2cd87 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
+ && mbus_formats[i].name[length] == '\0')
+ 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 {
--
2.1.0.231.g7484e3b
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/1] v4l: libv4l2subdev: Precisely convert media bus string to code
2016-01-25 12:35 [PATCH v2 1/1] v4l: libv4l2subdev: Precisely convert media bus string to code Sakari Ailus
@ 2016-01-25 19:41 ` Laurent Pinchart
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2016-01-25 19:41 UTC (permalink / raw)
To: Sakari Ailus; +Cc: linux-media, hverkuil
Hi Sakari,
Thank you for the patch.
On Monday 25 January 2016 14:35:06 Sakari Ailus wrote:
> 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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> since v1:
> - Use mbus_formats[i].name[length] == '\0' instead of comparing strlen()
> result.
>
> 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..dc2cd87 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
> + && mbus_formats[i].name[length] == '\0')
> + 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-25 19:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-25 12:35 [PATCH v2 1/1] v4l: libv4l2subdev: Precisely convert media bus string to code Sakari Ailus
2016-01-25 19:41 ` Laurent Pinchart
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.