]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[media] media-entity.c: get rid of var length arrays
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 1 Oct 2015 21:07:53 +0000 (18:07 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 1 Oct 2015 21:10:05 +0000 (18:10 -0300)
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.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/media-entity.c
include/media/media-entity.h

index 153a4646981400f05d60bddc658bd43a5a0f6ff3..767fe55ba08eece04b1873250dc09683a3af641e 100644 (file)
@@ -235,8 +235,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);
                unsigned int i;
 
                entity->stream_count++;
index 0c003d8174937ba47afa097d6a54b4fb8adce31d..197f9379975395dd259defbeb92bf0a5eccd2e86 100644 (file)
@@ -116,6 +116,13 @@ static inline u32 media_entity_subtype(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.
+ */
+#define MEDIA_ENTITY_MAX_PADS          (MEDIA_ENTITY_ENUM_MAX_ID - 1)
+
 struct media_entity_graph {
        struct {
                struct media_entity *entity;