migration/rdma: clang compilation fix
PATCH v2 1/1 migration/rdma: clang compilation fix
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, ®_result->rkey,
^~~~~~~~~~~~~~~~Fix it by using a temp local variable.
---
v1 -> v2:
- Use a temp local variable (Dave)
migration/rdma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
migration/rdma.c +4 -1
@@ -3611,13 +3611,16 @@ 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); +/* avoid "-Waddress-of-packed-member" warning */ +uint32_t tmp_rkey =0 ;if (qemu_rdma_register_and_get_keys (rdma, block, - (uintptr_t )host_addr,NULL , ®_result->rkey, + (uintptr_t )host_addr,NULL , &tmp_rkey, chunk, chunk_start, chunk_end)) {error_report ("cannot get rkey" ); ret = -EINVAL ; goto out; } + reg_result->rkey = tmp_rkey; reg_result->host_addr = (uintptr_t )block->local_host_addr;
Signature · 1 line
2.17.1
Quoted 8 lines · * Marcel Apfelbaum ([email protected]) wrote:
Configuring QEMU with:
../configure --cc=clang --enable-rdmaLeads to compilation error:
CC
migration/rdma.o
CCmigration/block.o
qemu/migration/rdma.c:3615:58: error: taking address of packed member 'rkey' of class or structure
Quoted 6 lines
'RDMARegisterResult' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] (uintptr_t)host_addr, NULL, ®_result->rkey, ^~~~~~~~~~~~~~~~Fix it by using a temp local variable.
Signed-off-by Marcel Apfelbaum <[email protected]>
Quoted 33 lines
---
v1 -> v2:
- Use a temp local variable (Dave)migration/rdma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)migration/rdma.c +4
-1@@ -3611,13 +3611,16 @@ 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); +/* avoid "-Waddress-of-packed-member" warning */ +uint32_t tmp_rkey =0 ;if (qemu_rdma_register_and_get_keys (rdma, block, - (uintptr_t )host_addr,NULL , ®_result->rkey, + (uintptr_t )host_addr,NULL , &tmp_rkey, chunk, chunk_start, chunk_end)) {error_report ("cannot get rkey" ); ret = -EINVAL ; goto out; } + reg_result->rkey = tmp_rkey; reg_result->host_addr = (uintptr_t )block->local_host_addr;Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 11 lines · Marcel Apfelbaum
Configuring QEMU with:
../configure --cc=clang --enable-rdmaLeads to compilation error:
CC
migration/rdma.o
CCmigration/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, ®_result->rkey, ^~~~~~~~~~~~~~~~
Quoted 7 lines
Fix it by using a temp local variable.
Signed-off-by Marcel Apfelbaum <[email protected]>---
v1 -> v2:
- Use a temp local variable (Dave)
Way cleaner than your v1 :)
migration/rdma.c static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque) · line 3614
Quoted 13 lines
migration/rdma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)migration/rdma.c +1
-0@@ -3611,13 +3611,16 @@ 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); +/* avoid "-Waddress-of-packed-member" warning */
No sure the comment is helpful.
migration/rdma.c static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque) · line 3615
Quoted 1 line
migration/rdma.c +1
-0+uint32_t tmp_rkey =0 ;
Probably no need to zero-initialize.
Anyway:
Quoted 13 lines
migration/rdma.c +2
-1if (qemu_rdma_register_and_get_keys (rdma, block, - (uintptr_t )host_addr,NULL , ®_result->rkey, + (uintptr_t )host_addr,NULL , &tmp_rkey, chunk, chunk_start, chunk_end)) {error_report ("cannot get rkey" ); ret = -EINVAL ; goto out; } + reg_result->rkey = tmp_rkey; reg_result->host_addr = (uintptr_t )block->local_host_addr;
Quoted 8 lines · * Marcel Apfelbaum ([email protected]) wrote:
Configuring QEMU with:
../configure --cc=clang --enable-rdmaLeads to compilation error:
CC
migration/rdma.o
CCmigration/block.o
qemu/migration/rdma.c:3615:58: error: taking address of packed member 'rkey' of class or structure
Quoted 6 lines
'RDMARegisterResult' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] (uintptr_t)host_addr, NULL, ®_result->rkey, ^~~~~~~~~~~~~~~~Fix it by using a temp local variable.
Signed-off-by Marcel Apfelbaum <[email protected]>
Queued
Quoted 34 lines
---
v1 -> v2:
- Use a temp local variable (Dave)migration/rdma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)migration/rdma.c +4
-1@@ -3611,13 +3611,16 @@ 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); +/* avoid "-Waddress-of-packed-member" warning */ +uint32_t tmp_rkey =0 ;if (qemu_rdma_register_and_get_keys (rdma, block, - (uintptr_t )host_addr,NULL , ®_result->rkey, + (uintptr_t )host_addr,NULL , &tmp_rkey, chunk, chunk_start, chunk_end)) {error_report ("cannot get rkey" ); ret = -EINVAL ; goto out; } + reg_result->rkey = tmp_rkey; reg_result->host_addr = (uintptr_t )block->local_host_addr;Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK