All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Linux Media Mailing List <linux-media@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Subject: [PATCH 1/7] [media] media-entity.c: get rid of var length arrays
Date: Thu,  1 Oct 2015 19:17:23 -0300	[thread overview]
Message-ID: <ef69ee1bc2c10fd1c5b389258d8156f3c38bdb33.1443737682.git.mchehab@osg.samsung.com> (raw)
In-Reply-To: <cover.1443737682.git.mchehab@osg.samsung.com>
In-Reply-To: <cover.1443737682.git.mchehab@osg.samsung.com>

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>

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 153a46469814..767fe55ba08e 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -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++;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 0c003d817493..197f93799753 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -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;
-- 
2.4.3



  reply	other threads:[~2015-10-01 22:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 22:17 [PATCH 0/7] Fix most sparse warnings Mauro Carvalho Chehab
2015-10-01 22:17 ` Mauro Carvalho Chehab [this message]
2015-10-01 22:17 ` [PATCH 2/7] [media] s5c73m3: fix a sparse warning Mauro Carvalho Chehab
2015-10-01 22:17 ` [PATCH 3/7] [media] netup_unidvb: remove most of the sparse warnings Mauro Carvalho Chehab
2015-10-01 22:17 ` [PATCH 4/7] [media] netup_unidvb_ci: Fix dereference of noderef expression Mauro Carvalho Chehab
2015-10-01 22:17 ` [PATCH 5/7] [media] mipi-csis: make sparse happy Mauro Carvalho Chehab
2015-10-01 22:17   ` Mauro Carvalho Chehab
2015-10-02 22:25   ` Arnd Bergmann
2015-10-02 22:25     ` Arnd Bergmann
2015-10-05 10:24     ` Sylwester Nawrocki
2015-10-05 10:24       ` Sylwester Nawrocki
2015-10-05 11:07       ` Arnd Bergmann
2015-10-05 11:07         ` Arnd Bergmann
2015-10-05 12:23         ` Sylwester Nawrocki
2015-10-05 12:23           ` Sylwester Nawrocki
2015-10-01 22:17 ` [PATCH 6/7] [media] c8sectpfe: fix namespace on memcpy/memset Mauro Carvalho Chehab
2015-10-01 22:17   ` Mauro Carvalho Chehab
2015-10-02 22:27   ` Arnd Bergmann
2015-10-02 22:27     ` Arnd Bergmann
2015-10-01 22:17 ` [PATCH 7/7] [media] rcar_jpu: Fix namespace for two __be16 vars Mauro Carvalho Chehab

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=ef69ee1bc2c10fd1c5b389258d8156f3c38bdb33.1443737682.git.mchehab@osg.samsung.com \
    --to=mchehab@osg.samsung.com \
    --cc=linux-media@vger.kernel.org \
    /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 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.