[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 10/16] scsi: move request parsing to common code
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 10/16] scsi: move request parsing to common code |
Date: |
Fri, 12 Aug 2011 17:12:25 +0100 |
On 3 August 2011 09:49, Paolo Bonzini <address@hidden> wrote:
> @@ -157,8 +172,22 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag,
> uint32_t lun,
> uint8_t *buf, void *hba_private)
> {
> SCSIRequest *req;
> - req = d->info->alloc_req(d, tag, lun, hba_private);
> - memcpy(req->cmd.buf, buf, 16);
> + SCSICommand cmd;
> +
> + if (scsi_req_parse(&cmd, d, buf) != 0) {
> + trace_scsi_req_parse_bad(d->id, lun, tag, buf[0]);
> + req = scsi_req_alloc(&reqops_invalid_opcode, d, tag, lun,
> hba_private);
> + } else {
> + trace_scsi_req_parsed(d->id, lun, tag, buf[0],
> + cmd.mode, cmd.xfer);
> + if (req->cmd.lba != -1) {
> + trace_scsi_req_parsed_lba(d->id, lun, tag, buf[0],
> + cmd.lba);
> + }
> + req = d->info->alloc_req(d, tag, lun, hba_private);
> + }
> +
> + req->cmd = cmd;
> return req;
> }
This patch makes current master fail to compile with optimisation on:
gcc complains:
hw/scsi-bus.c: In function ‘scsi_req_new’:
hw/scsi-bus.c:375: error: ‘req’ may be used uninitialized in this function
because in the 'else' clause we look at req->cmd.lba before we've
called alloc_req().
My guess is that the tracing should just be moved down to after the
allocation?
-- PMM
- Re: [Qemu-devel] [PATCH 01/16] scsi-disk: no need to call scsi_req_data on a short read, (continued)
- [Qemu-devel] [PATCH 08/16] scsi: introduce SCSICommand, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 07/16] scsi: pass cdb already to scsi_req_new, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 11/16] scsi: move handling of REPORT LUNS and invalid LUNs to common code, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 13/16] scsi: add a bunch more common sense codes, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 12/16] scsi: move handling of REQUEST SENSE to common code, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 14/16] scsi: add support for unit attention conditions, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 09/16] scsi: push lun field to SCSIDevice, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 15/16] scsi: report unit attention on reset, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 10/16] scsi: move request parsing to common code, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 04/16] scsi: move sense handling to generic code, Paolo Bonzini, 2011/08/03
- [Qemu-devel] [PATCH 16/16] scsi: add special traces for common commands, Paolo Bonzini, 2011/08/03
- Re: [Qemu-devel] [PATCH 00/16] SCSI sense and target request overhaul, Anthony Liguori, 2011/08/12