thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
0a122b
From 64b612d6551f21f7c3e34fa522b5b9c13f2b4ed8 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <64b612d6551f21f7c3e34fa522b5b9c13f2b4ed8.1387382496.git.minovotn@redhat.com>
0a122b
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
From: Nigel Croxon <ncroxon@redhat.com>
0a122b
Date: Thu, 14 Nov 2013 22:52:59 +0100
0a122b
Subject: [PATCH 23/46] rdma: don't use negative index to array
0a122b
0a122b
RH-Author: Nigel Croxon <ncroxon@redhat.com>
0a122b
Message-id: <1384469598-13137-24-git-send-email-ncroxon@redhat.com>
0a122b
Patchwork-id: 55707
0a122b
O-Subject: [RHEL7.0 PATCH 23/42] rdma: don't use negative index to array
0a122b
Bugzilla: 1011720
0a122b
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
0a122b
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
0a122b
Bugzilla: 1011720
0a122b
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
0a122b
0a122b
>From commit ID:
0a122b
commit 44b5949491a47043c4f7c4ff09f0191f82919a82
0a122b
Author: Isaku Yamahata <yamahata@private.email.ne.jp>
0a122b
Date:   Sat Aug 3 22:54:51 2013 -0400
0a122b
0a122b
    rdma: don't use negative index to array
0a122b
0a122b
    Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
0a122b
    Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
0a122b
    Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
0a122b
    Message-id: 1375584894-9917-5-git-send-email-mrhines@linux.vnet.ibm.com
0a122b
    Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
0a122b
---
0a122b
 migration-rdma.c |   27 +++++++++++++++------------
0a122b
 1 files changed, 15 insertions(+), 12 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 migration-rdma.c | 27 +++++++++++++++------------
0a122b
 1 file changed, 15 insertions(+), 12 deletions(-)
0a122b
0a122b
diff --git a/migration-rdma.c b/migration-rdma.c
0a122b
index c958e5f..7266803 100644
0a122b
--- a/migration-rdma.c
0a122b
+++ b/migration-rdma.c
0a122b
@@ -1933,10 +1933,21 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMAContext *rdma)
0a122b
 static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
0a122b
                     uint64_t offset, uint64_t len)
0a122b
 {
0a122b
-    RDMALocalBlock *block =
0a122b
-        &(rdma->local_ram_blocks.block[rdma->current_index]);
0a122b
-    uint8_t *host_addr = block->local_host_addr + (offset - block->offset);
0a122b
-    uint8_t *chunk_end = ram_chunk_end(block, rdma->current_chunk);
0a122b
+    RDMALocalBlock *block;
0a122b
+    uint8_t *host_addr;
0a122b
+    uint8_t *chunk_end;
0a122b
+
0a122b
+    if (rdma->current_index < 0) {
0a122b
+        return 0;
0a122b
+    }
0a122b
+
0a122b
+    if (rdma->current_chunk < 0) {
0a122b
+        return 0;
0a122b
+    }
0a122b
+
0a122b
+    block = &(rdma->local_ram_blocks.block[rdma->current_index]);
0a122b
+    host_addr = block->local_host_addr + (offset - block->offset);
0a122b
+    chunk_end = ram_chunk_end(block, rdma->current_chunk);
0a122b
 
0a122b
     if (rdma->current_length == 0) {
0a122b
         return 0;
0a122b
@@ -1949,10 +1960,6 @@ static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
0a122b
         return 0;
0a122b
     }
0a122b
 
0a122b
-    if (rdma->current_index < 0) {
0a122b
-        return 0;
0a122b
-    }
0a122b
-
0a122b
     if (offset < block->offset) {
0a122b
         return 0;
0a122b
     }
0a122b
@@ -1961,10 +1968,6 @@ static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
0a122b
         return 0;
0a122b
     }
0a122b
 
0a122b
-    if (rdma->current_chunk < 0) {
0a122b
-        return 0;
0a122b
-    }
0a122b
-
0a122b
     if ((host_addr + len) > chunk_end) {
0a122b
         return 0;
0a122b
     }
0a122b
-- 
0a122b
1.7.11.7
0a122b