* [PATCH] scsi: Eliminate compile warning in ibmvfc.c
@ 2008-11-07 3:16 Paul Mackerras
2008-11-17 16:56 ` Brian King
0 siblings, 1 reply; 2+ messages in thread
From: Paul Mackerras @ 2008-11-07 3:16 UTC (permalink / raw)
To: Brian King; +Cc: linux-scsi, sfr
Recent gcc (4.3.2) gives this compile warning on
drivers/scsi/ibmvscsi/ibmvfc.o:
CC drivers/scsi/ibmvscsi/ibmvfc.o
.../drivers/scsi/ibmvscsi/ibmvfc.c: In function 'ibmvfc_reset_device':
.../drivers/scsi/ibmvscsi/ibmvfc.c:1630: warning: 'evt' may be used uninitialized in this function
This fixes it by rearranging the code a little. This makes no
semantic change to the code except that the error message in the
vhost->state != IBMVFC_ACTIVE case is a little more explicit.
Signed-off-by: Paul Mackerras <paulus@samba.org>
---
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 7650707..e6c149f 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1630,32 +1630,37 @@ static int ibmvfc_reset_device(struct scsi_device *sdev, int type, char *desc)
struct ibmvfc_event *evt;
union ibmvfc_iu rsp_iu;
struct ibmvfc_fcp_rsp *fc_rsp = &rsp_iu.cmd.rsp;
- int rsp_rc = -EBUSY;
+ int rsp_rc;
unsigned long flags;
int rsp_code = 0;
spin_lock_irqsave(vhost->host->host_lock, flags);
- if (vhost->state == IBMVFC_ACTIVE) {
- evt = ibmvfc_get_event(vhost);
- ibmvfc_init_event(evt, ibmvfc_sync_completion, IBMVFC_CMD_FORMAT);
-
- tmf = &evt->iu.cmd;
- memset(tmf, 0, sizeof(*tmf));
- tmf->resp.va = (u64)evt->crq.ioba + offsetof(struct ibmvfc_cmd, rsp);
- tmf->resp.len = sizeof(tmf->rsp);
- tmf->frame_type = IBMVFC_SCSI_FCP_TYPE;
- tmf->payload_len = sizeof(tmf->iu);
- tmf->resp_len = sizeof(tmf->rsp);
- tmf->cancel_key = (unsigned long)sdev->hostdata;
- tmf->tgt_scsi_id = rport->port_id;
- int_to_scsilun(sdev->lun, &tmf->iu.lun);
- tmf->flags = (IBMVFC_NO_MEM_DESC | IBMVFC_TMF);
- tmf->iu.tmf_flags = type;
- evt->sync_iu = &rsp_iu;
-
- init_completion(&evt->comp);
- rsp_rc = ibmvfc_send_event(evt, vhost, default_timeout);
+ if (vhost->state != IBMVFC_ACTIVE) {
+ spin_unlock_irqrestore(vhost->host->host_lock, flags);
+ sdev_printk(KERN_ERR, sdev,
+ "Failed to send %s reset event; not active\n", desc);
+ return -EIO;
}
+ evt = ibmvfc_get_event(vhost);
+ ibmvfc_init_event(evt, ibmvfc_sync_completion, IBMVFC_CMD_FORMAT);
+
+ tmf = &evt->iu.cmd;
+ memset(tmf, 0, sizeof(*tmf));
+ tmf->resp.va = (u64)evt->crq.ioba + offsetof(struct ibmvfc_cmd, rsp);
+ tmf->resp.len = sizeof(tmf->rsp);
+ tmf->frame_type = IBMVFC_SCSI_FCP_TYPE;
+ tmf->payload_len = sizeof(tmf->iu);
+ tmf->resp_len = sizeof(tmf->rsp);
+ tmf->cancel_key = (unsigned long)sdev->hostdata;
+ tmf->tgt_scsi_id = rport->port_id;
+ int_to_scsilun(sdev->lun, &tmf->iu.lun);
+ tmf->flags = (IBMVFC_NO_MEM_DESC | IBMVFC_TMF);
+ tmf->iu.tmf_flags = type;
+ evt->sync_iu = &rsp_iu;
+
+ init_completion(&evt->comp);
+ rsp_rc = ibmvfc_send_event(evt, vhost, default_timeout);
+
spin_unlock_irqrestore(vhost->host->host_lock, flags);
if (rsp_rc != 0) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: Eliminate compile warning in ibmvfc.c
2008-11-07 3:16 [PATCH] scsi: Eliminate compile warning in ibmvfc.c Paul Mackerras
@ 2008-11-17 16:56 ` Brian King
0 siblings, 0 replies; 2+ messages in thread
From: Brian King @ 2008-11-17 16:56 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linux-scsi, sfr
Paul Mackerras wrote:
> Recent gcc (4.3.2) gives this compile warning on
> drivers/scsi/ibmvscsi/ibmvfc.o:
>
> CC drivers/scsi/ibmvscsi/ibmvfc.o
> .../drivers/scsi/ibmvscsi/ibmvfc.c: In function 'ibmvfc_reset_device':
> .../drivers/scsi/ibmvscsi/ibmvfc.c:1630: warning: 'evt' may be used uninitialized in this function
There is a patch already queued up in scsi-misc to fix this as well:
http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/jejb/scsi-misc-2.6.git;a=commitdiff;h=eaf5d80a9e7fae4de7f899fd5efc8f3e9f49efa6
-Brian
--
Brian King
Linux on Power Virtualization
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-17 16:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-07 3:16 [PATCH] scsi: Eliminate compile warning in ibmvfc.c Paul Mackerras
2008-11-17 16:56 ` Brian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox