IDE: Silent compiler warning in ide_pio_bytes()
PATCH 1/1 IDE: Silent compiler warning in ide_pio_bytes()
PageHighMem() isn't cheap so avoid calling it several times on the same page. I had the hope that this would silent the following compilation warning:
drivers/ide/ide-taskfile.c: In function 'ide_pio_bytes':drivers/ide/ide-taskfile.c:229: warning: 'flags' may be used uninitialized in this function
which is a false positive, but it did not. So let's just initialize the flags and be done with it, so that other developers don't waste their time looking at it.
--- drivers/ide/ide-taskfile.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/ide/ide-taskfile.c +5 -3
@@ -226,7 +226,7 @@ void ide_pio_bytes(ide_drive_t *drive, sstruct scatterlist *sg = hwif->sg_table;struct scatterlist *cursg = cmd->cursg;struct page *page; -unsigned long flags; +unsigned long flags =0 ;/* Silent compiler warning */ unsigned int offset;u8 *buf;
@@ -236,6 +236,7 @@ void ide_pio_bytes(ide_drive_t *drive, swhile (len) {unsigned nr_bytes =min (len, cursg->length - cmd->cursg_ofs); +int page_is_high;if (nr_bytes >PAGE_SIZE ) nr_bytes =PAGE_SIZE ;
@@ -247,7 +248,8 @@ void ide_pio_bytes(ide_drive_t *drive, s page =nth_page (page, (offset >>PAGE_SHIFT )); offset %=PAGE_SIZE ; -if (PageHighMem (page)) + page_is_high =PageHighMem (page); +if (page_is_high)local_irq_save (flags); buf =kmap_atomic (page,KM_BIO_SRC_IRQ ) + offset;
@@ -268,7 +270,7 @@ void ide_pio_bytes(ide_drive_t *drive, skunmap_atomic (buf,KM_BIO_SRC_IRQ ); -if (PageHighMem (page)) +if (page_is_high)local_irq_restore (flags); len -= nr_bytes;
Signature · 1 line
Jean Delvare
Quoted 20 lines · Jean Delvare
PageHighMem()isn't cheap so avoid calling it several times on the same page. I had the hope that this would silent the following compilation warning:
drivers/ide/ide-taskfile.c: In function 'ide_pio_bytes':drivers/ide/ide-taskfile.c:229: warning: 'flags' may be used uninitialized in this functionwhich is a false positive, but it did not. So let's just initialize the flags and be done with it, so that other developers don't waste their time looking at it.
Signed-off-by Jean Delvare <[email protected]>Cc Bartlomiej Zolnierkiewicz <[email protected]>--- drivers/ide/ide-taskfile.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/ide/ide-taskfile.c void ide_pio_bytes(ide_drive_t *drive, s · line 229
Quoted 5 lines
drivers/ide/ide-taskfile.c +1
-1@@ -226,7 +226,7 @@ void ide_pio_bytes(ide_drive_t *drive, sstruct scatterlist *sg = hwif->sg_table;struct scatterlist *cursg = cmd->cursg;struct page *page; -unsigned long flags; +unsigned long flags =0 ;/* Silent compiler warning */
or maybe
unsigned long uninitialized_var(flags);
Quoted 2 lines
drivers/ide/ide-taskfile.c +0
-0unsigned int offset;u8 *buf;
[..]
Signature · 2 lines
Regards/Gruss,
Boris.From: Jean Delvare <[email protected]>
Date: Mon, 22 Jun 2009 21:10:52 +0200
Quoted 7 lines
PageHighMem()isn't cheap so avoid calling it several times on the same page. I had the hope that this would silent the following compilation warning:
drivers/ide/ide-taskfile.c: In function 'ide_pio_bytes':drivers/ide/ide-taskfile.c:229: warning: 'flags' may be used uninitialized in this function
Quoted 6 lines
which is a false positive, but it did not. So let's just initialize the flags and be done with it, so that other developers don't waste their time looking at it.
Signed-off-by Jean Delvare <[email protected]>Cc Bartlomiej Zolnierkiewicz <[email protected]>
Like Borislav, I think it's better to use uninitialized_var(). It describes the situation completely.
Please submit an updated patch, and thank you for this.
Hi Dave, Borislav,
Quoted 14 lines · David Miller
From: Jean Delvare <[email protected]>
Date: Mon, 22 Jun 2009 21:10:52 +0200Quoted 11 lines
PageHighMem()isn't cheap so avoid calling it several times on the same page. I had the hope that this would silent the following compilation warning:
drivers/ide/ide-taskfile.c: In function 'ide_pio_bytes':drivers/ide/ide-taskfile.c:229: warning: 'flags' may be used uninitialized in this functionwhich is a false positive, but it did not. So let's just initialize the flags and be done with it, so that other developers don't waste their time looking at it.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Jean Delvare <[email protected]>Cc Bartlomiej Zolnierkiewicz <[email protected]>Like Borislav, I think it's better to use
uninitialized_var(). It describes the situation completely.Please submit an updated patch, and thank you for this.
I fear somebody else will have to do that. I personally think uninitialized_var() should not have been invented, I don't want to have my name associated with any of its uses for it will inevitably lead to bugs in the future.
I'll resubmit a patch not fixing the warning (because the rest is still useful I think) but that's about all I can offer.
Signature · 1 line
Jean Delvare
From: Jean Delvare <[email protected]>
Date: Tue, 23 Jun 2009 08:53:24 +0200
Quoted 7 lines
I fear somebody else will have to do that. I personally think
uninitialized_var()should not have been invented, I don't want to have my name associated with any of its uses for it will inevitably lead to bugs in the future.I'll resubmit a patch not fixing the warning (because the rest is still useful I think) but that's about all I can offer.
The alternative will be that someone will ask "when does the '0' case get used" and have to sort through that and potentially ask people here on the lists.
But you posted and update patch which solves the problem in an even nicer way :-)
Quoted 8 lines · David Miller
From: Jean Delvare <[email protected]>
Date: Tue, 23 Jun 2009 08:53:24 +0200Quoted 5 lines
I fear somebody else will have to do that. I personally think
uninitialized_var()should not have been invented, I don't want to have my name associated with any of its uses for it will inevitably lead to bugs in the future.
Quoted 6 lines
Quoted 2 lines
I'll resubmit a patch not fixing the warning (because the rest is still useful I think) but that's about all I can offer.
The alternative will be that someone will ask "when does the '0' case get used" and have to sort through that and potentially ask people here on the lists.
The comment I added, /* Silent compiler warning */, should have answered this question pretty clearly, methinks.
Quoted 2 lines
But you posted and update patch which solves the problem in an even nicer way :-)
Is it enough to silent the warning for you? I wasn't for me (gcc 4.3.2), although I expected it to... gcc should be able to see there is no code path leading to the variable being used uninitialized.
Signature · 1 line
Jean Delvare
From: Jean Delvare <[email protected]>
Date: Tue, 23 Jun 2009 11:52:07 +0200
Quoted 12 lines · David Miller
Quoted 11 lines
From: Jean Delvare <[email protected]>
Date: Tue, 23 Jun 2009 08:53:24 +0200Quoted 7 lines
I fear somebody else will have to do that. I personally think
uninitialized_var()should not have been invented, I don't want to have my name associated with any of its uses for it will inevitably lead to bugs in the future.I'll resubmit a patch not fixing the warning (because the rest is still useful I think) but that's about all I can offer.
Quoted 6 lines
Quoted 3 lines
The alternative will be that someone will ask "when does the '0' case get used" and have to sort through that and potentially ask people here on the lists.
The comment I added, /* Silent compiler warning */, should have answered this question pretty clearly, methinks.
Yet the uninitialzed_var() tag was created to indicate this tree-wide. A convention for the entire tree.
You can try to fight city hall with your protest, but I suspect biting off one's nose to spite one's face is not profitable in the end.
Quoted 6 lines
Quoted 2 lines
But you posted and update patch which solves the problem in an even nicer way :-)
Is it enough to silent the warning for you? I wasn't for me (gcc 4.3.2), although I expected it to... gcc should be able to see there is no code path leading to the variable being used uninitialized.
I didn't check, I suspected that you rewrote the patch this way because it did kill the warning for you. Guess not.
I'll be the pragmatist and add the uninitialized_var() myself, and will not for posterity your continued support of "the anti- uninitialized_var() cause" :-)