public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Jaswinder Singh Rajput <jaswinder@kernel.org>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	Ingo Molnar <mingo@elte.hu>, x86 maintainers <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -tip][SCSI] scsi: scsi_transport_iscsi.c initialize the variable before it get used
Date: Tue, 26 May 2009 16:36:40 -0500	[thread overview]
Message-ID: <4A1C60E8.1070004@cs.wisc.edu> (raw)
In-Reply-To: <1243351161.31783.5.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 916 bytes --]

Jaswinder Singh Rajput wrote:
> I am watching this problem from long time in -tip.
> 
> Subject: [PATCH] scsi: scsi_transport_iscsi.c initialize the variable before it get used
> 
> In some cases, err will be used uninitialized.
> 

As you guys already discussed it will not get used uninitialized.

> Also fixed compilation warning :
> 
>  CC      drivers/scsi/scsi_transport_iscsi.o
> drivers/scsi/scsi_transport_iscsi.c: In function ‘iscsi_add_session’:
> drivers/scsi/scsi_transport_iscsi.c:678: warning: ‘err’ may be used uninitialized in this function
> 

I did the attached patch to silence the compile warning. I goofed and 
forgot to send it before, because I had change my compiler and was not 
seeing the error message. I was planning on sending the attached with 
some other changes for the next feature window. I am going to fix up the 
patch to use UINT_MAX like James mentioned in the thread.

[-- Attachment #2: 0001-iscsi-class-quiet-iscsi_add_session-compilation-war.patch --]
[-- Type: text/x-patch, Size: 1221 bytes --]

>From 32ffa5248bf11f4df76ebf3c4a023958a9131f9c Mon Sep 17 00:00:00 2001
From: Mike Christie <michaelc@cs.wisc.edu>
Date: Mon, 18 May 2009 11:54:37 -0500
Subject: [PATCH] iscsi class: quiet iscsi_add_session compilation warning.

If ISCSI_MAX_TARGET was zero then iscsi_add_session could return
success when it had failed. This will currently not happen because
ISCSI_MAX_TARGET is a macro and not a variable. But gcc likes to
complain about it and people keep reporting it. This patch
just initializes err to be -EINVAL so if we ever defined
ISCSI_MAX_TARGET incorrectly we would fail gracefully.
---
 drivers/scsi/scsi_transport_iscsi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 0a2ce7b..f508567 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -675,7 +675,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
 	struct iscsi_cls_host *ihost;
 	unsigned long flags;
 	unsigned int id = target_id;
-	int err;
+	int err = -EINVAL;
 
 	ihost = shost->shost_data;
 	session->sid = atomic_add_return(1, &iscsi_session_nr);
-- 
1.6.0.6


      parent reply	other threads:[~2009-05-26 21:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26 15:19 [PATCH -tip][SCSI] scsi: scsi_transport_iscsi.c initialize the variable before it get used Jaswinder Singh Rajput
2009-05-26 15:28 ` James Bottomley
2009-05-26 16:00   ` Jaswinder Singh Rajput
2009-05-26 16:06     ` James Bottomley
2009-05-26 16:21       ` Jaswinder Singh Rajput
2009-05-26 21:36 ` Mike Christie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A1C60E8.1070004@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=jaswinder@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox