All of lore.kernel.org
 help / color / mirror / Atom feed
* [media-ctl PATCH] Compare entity name length aswell
@ 2012-04-25 13:57 Sergio Aguirre
  2012-04-28 15:04 ` Aguirre, Sergio
  0 siblings, 1 reply; 6+ messages in thread
From: Sergio Aguirre @ 2012-04-25 13:57 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, Sergio Aguirre

Otherwise, some false positives might arise when
having 2 subdevices with similar names, like:

"OMAP4 ISS ISP IPIPEIF"
"OMAP4 ISS ISP IPIPE"

Before this patch, trying to find "OMAP4 ISS ISP IPIPE", resulted
in a false entity match, retrieving "OMAP4 ISS ISP IPIPEIF"
information instead.

Checking length should ensure such cases are handled well.

Signed-off-by: Sergio Aguirre <saaguirre@ti.com>
---
 src/mediactl.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/mediactl.c b/src/mediactl.c
index 5b8c587..451a386 100644
--- a/src/mediactl.c
+++ b/src/mediactl.c
@@ -66,7 +66,8 @@ struct media_entity *media_get_entity_by_name(struct media_device *media,
 	for (i = 0; i < media->entities_count; ++i) {
 		struct media_entity *entity = &media->entities[i];
 
-		if (strncmp(entity->info.name, name, length) == 0)
+		if ((strncmp(entity->info.name, name, length) == 0) &&
+		    (strlen(entity->info.name) == length))
 			return entity;
 	}
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-29 23:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-25 13:57 [media-ctl PATCH] Compare entity name length aswell Sergio Aguirre
2012-04-28 15:04 ` Aguirre, Sergio
2012-04-29 17:40   ` Laurent Pinchart
2012-04-29 22:36     ` Aguirre, Sergio
2012-04-29 23:13       ` Laurent Pinchart
2012-04-29 23:18         ` Aguirre, Sergio

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.