Il 08/07/2013 20:42, Anthony Liguori ha scritto:
>> > +static int vscsi_fetch_desc(VSCSIState *s, struct vscsi_req *req,
>> > +                            unsigned n, unsigned buf_offset,
>> > +                            struct srp_direct_buf *ret)
>> > +{
>> > +    struct srp_cmd *cmd = &req->iu.srp.cmd;
>> > +
>> > +    switch (req->dma_fmt) {
>> > +    case SRP_NO_DATA_DESC: {
>> > +        dprintf("VSCSI: no data descriptor\n");
>> > +        return 0;
>> > +    }
>> > +    case SRP_DATA_DESC_DIRECT: {
>> > +        *ret = *(struct srp_direct_buf *)(cmd->add_data +
>> > req->cdb_offset);
> If you're reworking this code, you should remove these casts.  It's not
> safe to assume that cdb_offset is aligned properly.  memcpy()'ing would
> be much safer.

Or simply declare struct srp_direct_buf as packed (even better, use a
typedef as in the coding conventions).

Paolo

Reply via email to