On 10/12/2015 06:44 PM, Mauro Carvalho Chehab wrote:
Fix those sparse warnings: drivers/media/media-entity.c:238:17: warning: Variable length array is used. drivers/media/media-entity.c:239:17: warning: Variable length array is used.
That allows sparse and other code check tools to verify if the function is using more stack than allowed.
It also solves a bad Kernel pratice of using var length arrays at the stack.
Change-Id: Ida2fd36bfd4031b1b6a40db37353db2af0b9bc7a Signed-off-by: Mauro Carvalho Chehab mchehab@osg.samsung.com
drivers/media/media-entity.c | 4 ++-- include/media/media-entity.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index eaeda2589ce5..064020ddac94 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -424,8 +424,8 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) {
DECLARE_BITMAP(active, entity->num_pads);
DECLARE_BITMAP(has_no_links, entity->num_pads);
DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS);
DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS);
entity->stream_count++; WARN_ON(entity->pipe && entity->pipe != pipe);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 44ab153c37fc..a02b1bd3e45e 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -306,6 +306,13 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity) #define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 #define MEDIA_ENTITY_ENUM_MAX_ID 64
+/*
- The number of pads can't be bigger than the number of entities,
- as the worse-case scenario is to have one entity linked up to
- MEDIA_ENTITY_ENUM_MAX_ID - 1 entities.
- */
I don't think this is true at all. The number of pads an entity has is defined by the number of inputs and outputs of the hardware and is independent of how many of those inputs/outputs are actually hooked up.
This patch basically imposes a limitation (that is quite reasonable at the moment) on the number of pads to prevent a sparse warning.
But we will see devices with more than 64 pads in the future, so this is a band-aid.
Regards,
Hans
+#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1)
struct media_entity_graph { struct { struct media_entity *entity;