linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi/sym53c8xx: Fix a warning in sym_eh_handler
@ 2007-10-24  9:59 Jean Delvare
  2007-10-24 11:25 ` Matthew Wilcox
  2007-10-25  9:37 ` Boaz Harrosh
  0 siblings, 2 replies; 5+ messages in thread
From: Jean Delvare @ 2007-10-24  9:59 UTC (permalink / raw)
  To: Matthew Wilcox, linux-scsi

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.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
 drivers/scsi/sym53c8xx_2/sym_glue.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

--- linux-2.6.24-rc1.orig/drivers/scsi/sym53c8xx_2/sym_glue.c	2007-10-24 09:59:46.000000000 +0200
+++ linux-2.6.24-rc1/drivers/scsi/sym53c8xx_2/sym_glue.c	2007-10-24 11:53:14.000000000 +0200
@@ -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);


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi/sym53c8xx: Fix a warning in sym_eh_handler
  2007-10-24  9:59 [PATCH] scsi/sym53c8xx: Fix a warning in sym_eh_handler Jean Delvare
@ 2007-10-24 11:25 ` Matthew Wilcox
  2007-10-24 12:46   ` Jean Delvare
  2007-10-25  9:37 ` Boaz Harrosh
  1 sibling, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2007-10-24 11:25 UTC (permalink / raw)
  To: Jean Delvare; +Cc: linux-scsi

On Wed, Oct 24, 2007 at 11:59:20AM +0200, Jean Delvare wrote:
> 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.

-- 
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."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi/sym53c8xx: Fix a warning in sym_eh_handler
  2007-10-24 11:25 ` Matthew Wilcox
@ 2007-10-24 12:46   ` Jean Delvare
  0 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2007-10-24 12:46 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-scsi

On Wed, 24 Oct 2007 05:25:43 -0600, Matthew Wilcox wrote:
> On Wed, Oct 24, 2007 at 11:59:20AM +0200, Jean Delvare wrote:
> > 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.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi/sym53c8xx: Fix a warning in sym_eh_handler
  2007-10-24  9:59 [PATCH] scsi/sym53c8xx: Fix a warning in sym_eh_handler Jean Delvare
  2007-10-24 11:25 ` Matthew Wilcox
@ 2007-10-25  9:37 ` Boaz Harrosh
  2007-10-25 11:19   ` Matthew Wilcox
  1 sibling, 1 reply; 5+ messages in thread
From: Boaz Harrosh @ 2007-10-25  9:37 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Matthew Wilcox, linux-scsi, Andrew Morton

On Wed, Oct 24 2007 at 11:59 +0200, Jean Delvare <khali@linux-fr.org> wrote:
> 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.
> 
> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> ---
>  drivers/scsi/sym53c8xx_2/sym_glue.c |   13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> --- linux-2.6.24-rc1.orig/drivers/scsi/sym53c8xx_2/sym_glue.c	2007-10-24 09:59:46.000000000 +0200
> +++ linux-2.6.24-rc1/drivers/scsi/sym53c8xx_2/sym_glue.c	2007-10-24 11:53:14.000000000 +0200
> @@ -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);
> 
> 
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




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi/sym53c8xx: Fix a warning in sym_eh_handler
  2007-10-25  9:37 ` Boaz Harrosh
@ 2007-10-25 11:19   ` Matthew Wilcox
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Wilcox @ 2007-10-25 11:19 UTC (permalink / raw)
  To: Boaz Harrosh; +Cc: Jean Delvare, linux-scsi, Andrew Morton

On Thu, Oct 25, 2007 at 11:37:18AM +0200, Boaz Harrosh wrote:
> On Wed, Oct 24 2007 at 11:59 +0200, Jean Delvare <khali@linux-fr.org> wrote:
> > -		struct completion *io_reset;
> > -		int finished_reset = 0;
> > +		struct completion *io_reset = NULL;
> > +		int finished_reset;
[...]
> > -		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.

-- 
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."

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-10-25 11:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-24  9:59 [PATCH] scsi/sym53c8xx: Fix a warning in sym_eh_handler Jean Delvare
2007-10-24 11:25 ` Matthew Wilcox
2007-10-24 12:46   ` Jean Delvare
2007-10-25  9:37 ` Boaz Harrosh
2007-10-25 11:19   ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).