Skip to contentSkip to conversation

scsi/sym53c8xx: Fix a warning in sym_eh_handler

PATCH In review Jean Delvare 3 participants 5 messages Oct 24, 2007 – Oct 25, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi/sym53c8xx: Fix a warning in sym_eh_handler

In 2.6.24-rc1 I see the following warning:
drivers/scsi/sym53c8xx_2/sym_glue.c: In function "sym_eh_handler":
drivers/scsi/sym53c8xx_2/sym_glue.c:612: warning: "io_reset" may be used uninitialized in this function

Although gcc is wrong and the code is actually correct, it can easily be made more obvious to keep the compiler quiet.

---
 drivers/scsi/sym53c8xx_2/sym_glue.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/scsi/sym53c8xx_2/sym_glue.c +6 -7
@@ -609,8 +609,8 @@ static int sym_eh_handler(int op, char *
 	 */
 #define WAIT_FOR_PCI_RECOVERY	35
 	if (pci_channel_offline(pdev)) {
-		struct completion *io_reset;
-		int finished_reset = 0;
+		struct completion *io_reset = NULL;
+		int finished_reset;
 		init_completion(&eh_done);
 		spin_lock_irq(shost->host_lock);
 		/* Make sure we didn't race */
@@ -618,15 +618,14 @@ static int sym_eh_handler(int op, char *
 			if (!sym_data->io_reset)
 				sym_data->io_reset = &eh_done;
 			io_reset = sym_data->io_reset;
-		} else {
-			finished_reset = 1;
 		}
 		spin_unlock_irq(shost->host_lock);
-		if (!finished_reset)
+		if (io_reset) {
 			finished_reset = wait_for_completion_timeout(io_reset,
 						WAIT_FOR_PCI_RECOVERY*HZ);
-		if (!finished_reset)
-			return SCSI_FAILED;
+			if (!finished_reset)
+				return SCSI_FAILED;
+		}
 	}
 
 	spin_lock_irq(shost->host_lock);
Signature · 1 line
Jean Delvare
#1 lore raw
Quoted 6 lines · Jean Delvare

In 2.6.24-rc1 I see the following warning:
drivers/scsi/sym53c8xx_2/sym_glue.c: In function "sym_eh_handler":
drivers/scsi/sym53c8xx_2/sym_glue.c:612: warning: "io_reset" may be used uninitialized in this function

Although gcc is wrong and the code is actually correct, it can easily be made more obvious to keep the compiler quiet.

Which compiler version? I don't see this with 4.2.1.

Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
#2 lore raw
Quoted 9 lines · Matthew Wilcox
Quoted 6 lines · Jean Delvare

In 2.6.24-rc1 I see the following warning:
drivers/scsi/sym53c8xx_2/sym_glue.c: In function "sym_eh_handler":
drivers/scsi/sym53c8xx_2/sym_glue.c:612: warning: "io_reset" may be used uninitialized in this function

Although gcc is wrong and the code is actually correct, it can easily be made more obvious to keep the compiler quiet.

Which compiler version? I don't see this with 4.2.1.

gcc version 4.1.2.

Signature · 1 line
Jean Delvare
#3 lore raw
In reply to Jean Delvare
Quoted 37 lines · Jean Delvare

In 2.6.24-rc1 I see the following warning:
drivers/scsi/sym53c8xx_2/sym_glue.c: In function "sym_eh_handler":
drivers/scsi/sym53c8xx_2/sym_glue.c:612: warning: "io_reset" may be used uninitialized in this function

Although gcc is wrong and the code is actually correct, it can easily be made more obvious to keep the compiler quiet.

---
 drivers/scsi/sym53c8xx_2/sym_glue.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/scsi/sym53c8xx_2/sym_glue.c +3 -5
@@ -609,8 +609,8 @@ static int sym_eh_handler(int op, char *
 	 */
 #define WAIT_FOR_PCI_RECOVERY	35
 	if (pci_channel_offline(pdev)) {
-		struct completion *io_reset;
-		int finished_reset = 0;
+		struct completion *io_reset = NULL;
+		int finished_reset;
 		init_completion(&eh_done);
 		spin_lock_irq(shost->host_lock);
 		/* Make sure we didn't race */
@@ -618,15 +618,14 @@ static int sym_eh_handler(int op, char *
 			if (!sym_data->io_reset)
 				sym_data->io_reset = &eh_done;
 			io_reset = sym_data->io_reset;
-		} else {
-			finished_reset = 1;
 		}
 		spin_unlock_irq(shost->host_lock);
-		if (!finished_reset)
+		if (io_reset) {

drivers/scsi/sym53c8xx_2/sym_glue.c static int sym_eh_handler(int op, char * · line 631

Quoted 10 lines
drivers/scsi/sym53c8xx_2/sym_glue.c +3 -2
 			finished_reset = wait_for_completion_timeout(io_reset,
 						WAIT_FOR_PCI_RECOVERY*HZ);
-		if (!finished_reset)
-			return SCSI_FAILED;
+			if (!finished_reset)
+				return SCSI_FAILED;
+		}
 	}
 
 	spin_lock_irq(shost->host_lock);

I think you should use uninitialized_var and not brute = NULL; This is because, than uninitialized_var can be tested for in the future and removed if no longer relevant. And also for the user of the code it is easier to understand.

Boaz

#4 lore raw
Quoted 5 lines · Boaz Harrosh
Quoted 4 lines · Jean Delvare
drivers/scsi/sym53c8xx_2/sym_glue.c +2 -2
-		struct completion *io_reset;
-		int finished_reset = 0;
+		struct completion *io_reset = NULL;
+		int finished_reset;

[...]

Quoted 4 lines

drivers/scsi/sym53c8xx_2/sym_glue.c static int sym_eh_handler(int op, char * · line 623

Quoted 2 lines
drivers/scsi/sym53c8xx_2/sym_glue.c +1 -1
-		if (!finished_reset)
+		if (io_reset) {

I think you should use uninitialized_var and not brute = NULL;

Look at the patch more carefully ... uninitialized_var would be inappropriate.

Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."