From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5FPm-0003gu-LM for qemu-devel@nongnu.org; Fri, 02 Aug 2013 09:29:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V5FPe-0005T0-OJ for qemu-devel@nongnu.org; Fri, 02 Aug 2013 09:29:06 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:53423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5FPe-0005Qj-Hl for qemu-devel@nongnu.org; Fri, 02 Aug 2013 09:28:58 -0400 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Aug 2013 07:28:40 -0600 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id E2667C40002 for ; Fri, 2 Aug 2013 07:23:11 -0600 (MDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r72DSZ6h202370 for ; Fri, 2 Aug 2013 07:28:35 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r72DVHcx029546 for ; Fri, 2 Aug 2013 07:31:17 -0600 Message-ID: <51FBB402.1040108@linux.vnet.ibm.com> Date: Fri, 02 Aug 2013 09:28:34 -0400 From: "Michael R. Hines" MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/3] rdma: don't use negative index to array List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: owasserm@redhat.com, quintela@redhat.com, mrhines@us.ibm.com, qemu-devel@nongnu.org, pbonzini@redhat.com On 08/01/2013 11:56 PM, Isaku Yamahata wrote: > Cc: Michael R. Hines > Signed-off-by: Isaku Yamahata > --- > migration-rdma.c | 27 +++++++++++++++------------ > 1 file changed, 15 insertions(+), 12 deletions(-) > > diff --git a/migration-rdma.c b/migration-rdma.c > index 4828738..edbae9f 100644 > --- a/migration-rdma.c > +++ b/migration-rdma.c > @@ -1931,10 +1931,21 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMAContext *rdma) > static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma, > uint64_t offset, uint64_t len) > { > - RDMALocalBlock *block = > - &(rdma->local_ram_blocks.block[rdma->current_index]); > - uint8_t *host_addr = block->local_host_addr + (offset - block->offset); > - uint8_t *chunk_end = ram_chunk_end(block, rdma->current_chunk); > + RDMALocalBlock *block; > + uint8_t *host_addr; > + uint8_t *chunk_end; > + > + if (rdma->current_index < 0) { > + return 0; > + } > + > + if (rdma->current_chunk < 0) { > + return 0; > + } > + > + block = &(rdma->local_ram_blocks.block[rdma->current_index]); > + host_addr = block->local_host_addr + (offset - block->offset); > + chunk_end = ram_chunk_end(block, rdma->current_chunk); > > if (rdma->current_length == 0) { > return 0; > @@ -1947,10 +1958,6 @@ static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma, > return 0; > } > > - if (rdma->current_index < 0) { > - return 0; > - } > - > if (offset < block->offset) { > return 0; > } > @@ -1959,10 +1966,6 @@ static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma, > return 0; > } > > - if (rdma->current_chunk < 0) { > - return 0; > - } > - > if ((host_addr + len) > chunk_end) { > return 0; > } Reviewed-by: Michael R. Hines