public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* iscsi_add_session() warning
@ 2009-02-04  0:09 Andrew Morton
  2009-02-04  0:12 ` Kyle McMartin
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2009-02-04  0:09 UTC (permalink / raw)
  To: Mike Christie; +Cc: linux-scsi


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;
: }


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

end of thread, other threads:[~2009-02-04 17:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-04  0:09 iscsi_add_session() warning Andrew Morton
2009-02-04  0:12 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox