All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Mike Christie <michaelc@cs.wisc.edu>
Cc: linux-scsi@vger.kernel.org
Subject: iscsi_add_session() warning
Date: Tue, 3 Feb 2009 16:09:00 -0800	[thread overview]
Message-ID: <20090203160900.38506c47.akpm@linux-foundation.org> (raw)


Looking at this:

drivers/scsi/scsi_transport_iscsi.c: In function 'iscsi_add_session':
drivers/scsi/scsi_transport_iscsi.c:703: warning: 'err' may be used uninitialized in this function

the compiler is wrong - `err' will always have been initialised to
_something_.

But to what?

: int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
: {
: 	struct Scsi_Host *shost = iscsi_session_to_shost(session);
: 	struct iscsi_cls_host *ihost;
: 	unsigned long flags;
: 	unsigned int id = target_id;
: 	int err;
: 
: 	ihost = shost->shost_data;
: 	session->sid = atomic_add_return(1, &iscsi_session_nr);
: 
: 	if (id == ISCSI_MAX_TARGET) {
: 		for (id = 0; id < ISCSI_MAX_TARGET; id++) {
: 			err = device_for_each_child(&shost->shost_gendev, &id,
: 						    iscsi_get_next_target_id);
: 			if (!err)
: 				break;
: 		}
: 
: 		if (id == ISCSI_MAX_TARGET) {
: 			iscsi_cls_session_printk(KERN_ERR, session,
: 						 "Too many iscsi targets. Max "
: 						 "number of targets is %d.\n",
: 						 ISCSI_MAX_TARGET - 1);

At this point, err is probably zero.  Or it might be the return value
from the most recent call to
device_for_each_child(iscsi_get_next_target_id).

Should we not assign some error code to `err' here?

: 			goto release_host;
: 		}
: 	}
: 	session->target_id = id;
: 
: 	dev_set_name(&session->dev, "session%u", session->sid);
: 	err = device_add(&session->dev);
: 	if (err) {
: 		iscsi_cls_session_printk(KERN_ERR, session,
: 					 "could not register session's dev\n");
: 		goto release_host;
: 	}
: 	transport_register_device(&session->dev);
: 
: 	spin_lock_irqsave(&sesslock, flags);
: 	list_add(&session->sess_list, &sesslist);
: 	spin_unlock_irqrestore(&sesslock, flags);
: 
: 	iscsi_session_event(session, ISCSI_KEVENT_CREATE_SESSION);
: 	return 0;
: 
: release_host:
: 	scsi_host_put(shost);
: 	return err;
: }


             reply	other threads:[~2009-02-04  0:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-04  0:09 Andrew Morton [this message]
2009-02-04  0:12 ` iscsi_add_session() warning Kyle McMartin
2009-02-04  0:22   ` Andrew Morton
2009-02-04  7:40     ` Mike Christie
2009-02-04  7:50       ` Andrew Morton
2009-02-04 17:56   ` Grant Grundler

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=20090203160900.38506c47.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.