From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyiZj-0003sU-Fl for qemu-devel@nongnu.org; Mon, 15 Jul 2013 09:12:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyiZi-0003cW-96 for qemu-devel@nongnu.org; Mon, 15 Jul 2013 09:12:23 -0400 Message-ID: <51E3F514.2070306@redhat.com> Date: Mon, 15 Jul 2013 15:11:48 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1372315560-5478-1-git-send-email-aik@ozlabs.ru> <1372315560-5478-10-git-send-email-aik@ozlabs.ru> <87ppuszyeb.fsf@codemonkey.ws> In-Reply-To: <87ppuszyeb.fsf@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 09/17] pseries: rework PAPR virtual SCSI List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paul Mackerras , David Gibson 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