qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: qemu-devel@nongnu.org, eblake@redhat.com
Subject: Re: [Qemu-devel] [PATCH V2] migration/rdma: clang compilation fix
Date: Mon, 4 Mar 2019 18:53:39 +0000	[thread overview]
Message-ID: <20190304185339.GF2596@work-vm> (raw)
In-Reply-To: <20190304184923.24215-1-marcel.apfelbaum@gmail.com>

* Marcel Apfelbaum (marcel.apfelbaum@gmail.com) wrote:
> 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,
>                                                          ^~~~~~~~~~~~~~~~
> Fix it by using a temp local variable.
> 
> Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
> 
> v1 -> v2: 
>  - Use a temp local variable (Dave)
> 
>  migration/rdma.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/migration/rdma.c b/migration/rdma.c
> index 54a3c11540..e39ee77558 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -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, &reg_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;
>  
> -- 
> 2.17.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2019-03-04 18:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 18:49 [Qemu-devel] [PATCH V2] migration/rdma: clang compilation fix Marcel Apfelbaum
2019-03-04 18:53 ` Dr. David Alan Gilbert [this message]
2019-03-04 23:25 ` Philippe Mathieu-Daudé
2019-03-05 13:25 ` Dr. David Alan Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190304185339.GF2596@work-vm \
    --to=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).