qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] migration/rdma: clang compilation fix


From: Marcel Apfelbaum
Subject: [Qemu-devel] [PATCH] migration/rdma: clang compilation fix
Date: Mon, 4 Mar 2019 10:42:38 +0200

Configuring QEMU with:
        ../configure --cc=clang --enable-rdma

Leads to compilation error:

  CC      migration/rdma.o
  CC      migration/block.o
  qemu/migration/rdma.c:3615:58: error: taking address of packed member 'rkey' 
of class or structure
      'RDMARegisterResult' may result in an unaligned pointer value 
[-Werror,-Waddress-of-packed-member]
                            (uintptr_t)host_addr, NULL, &reg_result->rkey,
                                                         ^~~~~~~~~~~~~~~~

This is a false warning; even if RDMARegisterResult is "packed", rkey
is the first field so is guaranteed to be aligned.

Fix it by disabling the warning only for this instance.

Signed-off-by: Marcel Apfelbaum <address@hidden>
---
 migration/rdma.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/migration/rdma.c b/migration/rdma.c
index 54a3c11540..e0f66a4717 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -3611,6 +3611,8 @@ static int qemu_rdma_registration_handle(QEMUFile *f, 
void *opaque)
                 }
                 chunk_start = ram_chunk_start(block, chunk);
                 chunk_end = ram_chunk_end(block, chunk + reg->chunks);
+                #pragma clang diagnostic push
+                #pragma clang diagnostic ignored "-Waddress-of-packed-member"
                 if (qemu_rdma_register_and_get_keys(rdma, block,
                             (uintptr_t)host_addr, NULL, &reg_result->rkey,
                             chunk, chunk_start, chunk_end)) {
@@ -3618,6 +3620,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f, 
void *opaque)
                     ret = -EINVAL;
                     goto out;
                 }
+                #pragma clang diagnostic pop
 
                 reg_result->host_addr = (uintptr_t)block->local_host_addr;
 
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]