* [PATCH] mmc: fix card block compile warnings
@ 2012-03-22 7:35 Linus Walleij
2012-03-22 10:58 ` Ulf Hansson
0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2012-03-22 7:35 UTC (permalink / raw)
To: Chris Ball, linux-mmc; +Cc: Linus Walleij
I'm pretty tired of seeing these in my kernel compiles:
drivers/mmc/card/block.c: In function ‘mmc_blk_issue_secdiscard_rq’:
drivers/mmc/card/block.c:911:18: warning: ‘arg’ may be used uninitialized in this function [-Wuninitialized]
drivers/mmc/card/block.c:910:6: warning: ‘nr’ may be used uninitialized in this function [-Wuninitialized]
drivers/mmc/card/block.c:910:6: warning: ‘from’ may be used uninitialized in this function [-Wuninitialized]
This patch marks the variables explicitly uninitialized as
seems to be the intention, I can assure myself they are not
actually uninitialized at use time by just reading the code.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/mmc/card/block.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index c6a383d..214ae68 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -874,7 +874,9 @@ 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 uninitialized_var(from);
+ unsigned int uninitialized_var(nr);
+ unsigned int uninitialized_var(arg);
int err = 0, type = MMC_BLK_SECDISCARD;
if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
--
1.7.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: fix card block compile warnings
2012-03-22 7:35 [PATCH] mmc: fix card block compile warnings Linus Walleij
@ 2012-03-22 10:58 ` Ulf Hansson
2012-03-22 18:02 ` Linus Walleij
0 siblings, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2012-03-22 10:58 UTC (permalink / raw)
To: Linus Walleij; +Cc: Chris Ball, linux-mmc@vger.kernel.org
On 03/22/2012 08:35 AM, Linus Walleij wrote:
> I'm pretty tired of seeing these in my kernel compiles:
> drivers/mmc/card/block.c: In function ‘mmc_blk_issue_secdiscard_rq’:
> drivers/mmc/card/block.c:911:18: warning: ‘arg’ may be used uninitialized in this function [-Wuninitialized]
> drivers/mmc/card/block.c:910:6: warning: ‘nr’ may be used uninitialized in this function [-Wuninitialized]
> drivers/mmc/card/block.c:910:6: warning: ‘from’ may be used uninitialized in this function [-Wuninitialized]
>
> This patch marks the variables explicitly uninitialized as
> seems to be the intention, I can assure myself they are not
> actually uninitialized at use time by just reading the code.
>
> Signed-off-by: Linus Walleij<linus.walleij@linaro.org>
> ---
> drivers/mmc/card/block.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index c6a383d..214ae68 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -874,7 +874,9 @@ 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 uninitialized_var(from);
> + unsigned int uninitialized_var(nr);
> + unsigned int uninitialized_var(arg);
> int err = 0, type = MMC_BLK_SECDISCARD;
>
> if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
Is not the problem only related to the arg variable?
What about:
unsigned int from, nr, arg = 0;
Yours!
Ulf Hansson
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: fix card block compile warnings
2012-03-22 10:58 ` Ulf Hansson
@ 2012-03-22 18:02 ` Linus Walleij
2012-03-23 5:46 ` Rabin Vincent
0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2012-03-22 18:02 UTC (permalink / raw)
To: Ulf Hansson; +Cc: Chris Ball, linux-mmc@vger.kernel.org
On Thu, Mar 22, 2012 at 11:58 AM, Ulf Hansson
<ulf.hansson@stericsson.com> wrote:
> On 03/22/2012 08:35 AM, Linus Walleij wrote:
>> - unsigned int from, nr, arg;
>> + unsigned int uninitialized_var(from);
>> + unsigned int uninitialized_var(nr);
>> + unsigned int uninitialized_var(arg);
>> int err = 0, type = MMC_BLK_SECDISCARD;
>>
>> if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
>
>
> Is not the problem only related to the arg variable?
Nope the compiler complains about all three...
> What about:
> unsigned int from, nr, arg = 0;
That also works, but we had a previous patch with that approach
NACKed in the past, the reason was that the problem does not
appear in x86 GCC, just in ARM GCC which is more sensitive.
(commit 8c320c079cde0286d71368961231e426539868b4)
By reading the code you can easily see that the variables aren't
actually used uninitialized, it's juts GCC that is unable to
follow the code path and determine that they are initialized in
all paths.
But assigning zero is fine with me, Chris may decide...
Thanks,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: fix card block compile warnings
2012-03-22 18:02 ` Linus Walleij
@ 2012-03-23 5:46 ` Rabin Vincent
2012-03-23 9:05 ` Linus Walleij
0 siblings, 1 reply; 5+ messages in thread
From: Rabin Vincent @ 2012-03-23 5:46 UTC (permalink / raw)
To: Linus Walleij; +Cc: Ulf Hansson, Chris Ball, linux-mmc@vger.kernel.org
On Thu, Mar 22, 2012 at 23:32, Linus Walleij <linus.walleij@linaro.org> wrote:
> By reading the code you can easily see that the variables aren't
> actually used uninitialized, it's juts GCC that is unable to
> follow the code path and determine that they are initialized in
> all paths.
If the mmc_switch(..SANITIZE_START..) returns -EIO and mmc_blk_reset()
returns 0, then the variables _are_ used uninitialized.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: fix card block compile warnings
2012-03-23 5:46 ` Rabin Vincent
@ 2012-03-23 9:05 ` Linus Walleij
0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2012-03-23 9:05 UTC (permalink / raw)
To: Rabin Vincent; +Cc: Ulf Hansson, Chris Ball, linux-mmc@vger.kernel.org
On Fri, Mar 23, 2012 at 6:46 AM, Rabin Vincent <rabin@rab.in> wrote:
> On Thu, Mar 22, 2012 at 23:32, Linus Walleij <linus.walleij@linaro.org> wrote:
>> By reading the code you can easily see that the variables aren't
>> actually used uninitialized, it's juts GCC that is unable to
>> follow the code path and determine that they are initialized in
>> all paths.
>
> If the mmc_switch(..SANITIZE_START..) returns -EIO and mmc_blk_reset()
> returns 0, then the variables _are_ used uninitialized.
Argh! You're right. (As usual.)
But that makes me wonder if the code flow is even correct
for sanitize.
I'll have a closer look and come up with something better!
Thanks,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-23 9:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-22 7:35 [PATCH] mmc: fix card block compile warnings Linus Walleij
2012-03-22 10:58 ` Ulf Hansson
2012-03-22 18:02 ` Linus Walleij
2012-03-23 5:46 ` Rabin Vincent
2012-03-23 9:05 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox