* [PATCH] mmc: block: Fix compile time warning for uninitalized variables
@ 2011-11-23 10:11 Tushar Behera
2011-11-25 10:06 ` Adrian Hunter
0 siblings, 1 reply; 2+ messages in thread
From: Tushar Behera @ 2011-11-23 10:11 UTC (permalink / raw)
To: linux-mmc; +Cc: cjb
This patch fixes following compile time warnings.
drivers/mmc/card/block.c: In function ‘mmc_blk_issue_rq’:
drivers/mmc/card/block.c:828:18: warning: ‘arg’ may be used uninitialized in this function [-Wun initialized]
drivers/mmc/card/block.c:794:25: note: ‘arg’ was declared here
drivers/mmc/card/block.c:827:6: warning: ‘nr’ may be used uninitialized in this function [-Wunin itialized]
drivers/mmc/card/block.c:794:21: note: ‘nr’ was declared here
drivers/mmc/card/block.c:827:6: warning: ‘from’ may be used uninitialized in this function [-Wun initialized]
drivers/mmc/card/block.c:794:15: note: ‘from’ was declared here
If the code follows the labels 'out' and 'retry', then we get
to situation when these variables are used uninitialized.
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
The patch is rebased on v3.2-rc2.
I don't have much idea on what should be the default value
for these variables. The fixes are provided just to do away
with the compile time warnings.
drivers/mmc/card/block.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index a1cb21f..8e0ffe9 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -791,7 +791,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
{
struct mmc_blk_data *md = mq->data;
struct mmc_card *card = md->queue.card;
- unsigned int from, nr, arg;
+ unsigned int from = 0, nr = 0, arg = 0;
int err = 0, type = MMC_BLK_SECDISCARD;
if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
--
1.7.4.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] mmc: block: Fix compile time warning for uninitalized variables
2011-11-23 10:11 [PATCH] mmc: block: Fix compile time warning for uninitalized variables Tushar Behera
@ 2011-11-25 10:06 ` Adrian Hunter
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Hunter @ 2011-11-25 10:06 UTC (permalink / raw)
To: Tushar Behera; +Cc: linux-mmc, cjb, kyungmin.park, Jaehoon Chung
On 23/11/11 12:11, Tushar Behera wrote:
> This patch fixes following compile time warnings.
>
> drivers/mmc/card/block.c: In function ‘mmc_blk_issue_rq’:
> drivers/mmc/card/block.c:828:18: warning: ‘arg’ may be used uninitialized in this function [-Wun initialized]
> drivers/mmc/card/block.c:794:25: note: ‘arg’ was declared here
> drivers/mmc/card/block.c:827:6: warning: ‘nr’ may be used uninitialized in this function [-Wunin itialized]
> drivers/mmc/card/block.c:794:21: note: ‘nr’ was declared here
> drivers/mmc/card/block.c:827:6: warning: ‘from’ may be used uninitialized in this function [-Wun initialized]
> drivers/mmc/card/block.c:794:15: note: ‘from’ was declared here
>
> If the code follows the labels 'out' and 'retry', then we get
> to situation when these variables are used uninitialized.
>
> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> ---
>
> The patch is rebased on v3.2-rc2.
>
> I don't have much idea on what should be the default value
> for these variables. The fixes are provided just to do away
> with the compile time warnings.
It is a "goto" that is wrong, not the initialization.
But there is another problem. The sanitize code is
side-stepping the reset and retry path entirely.
>
> drivers/mmc/card/block.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index a1cb21f..8e0ffe9 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -791,7 +791,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
> {
> struct mmc_blk_data *md = mq->data;
> struct mmc_card *card = md->queue.card;
> - unsigned int from, nr, arg;
> + unsigned int from = 0, nr = 0, arg = 0;
> int err = 0, type = MMC_BLK_SECDISCARD;
>
> if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-25 10:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-23 10:11 [PATCH] mmc: block: Fix compile time warning for uninitalized variables Tushar Behera
2011-11-25 10:06 ` Adrian Hunter
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.