On 3 August 2011 09:49, Paolo Bonzini <pbonz...@redhat.com> 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