diff options
author | Isaku Yamahata <yamahata@private.email.ne.jp> | 2013-08-03 22:54:51 -0400 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-08-05 11:47:47 -0500 |
commit | 44b5949491a47043c4f7c4ff09f0191f82919a82 (patch) | |
tree | c7db0dc5dff5cf28bca437a17202359736886379 /migration-rdma.c | |
parent | 66988941251ef64044aa3b951ebd84162e5a4e3a (diff) | |
download | qemu-44b5949491a47043c4f7c4ff09f0191f82919a82.zip qemu-44b5949491a47043c4f7c4ff09f0191f82919a82.tar.gz qemu-44b5949491a47043c4f7c4ff09f0191f82919a82.tar.bz2 |
rdma: don't use negative index to array
Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Message-id: 1375584894-9917-5-git-send-email-mrhines@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'migration-rdma.c')
-rw-r--r-- | migration-rdma.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/migration-rdma.c b/migration-rdma.c index 48d6c19..ec0a7ae 100644 --- a/migration-rdma.c +++ b/migration-rdma.c @@ -1933,10 +1933,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; @@ -1949,10 +1960,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; } @@ -1961,10 +1968,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; } |