qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH] migration/rdma: clang compilation fix
Date: Mon, 4 Mar 2019 12:11:10 -0600	[thread overview]
Message-ID: <550bead8-a9a5-d9f4-1204-a6130f8c8e14@redhat.com> (raw)
In-Reply-To: <20190304084238.13481-1-marcel.apfelbaum@gmail.com>

On 3/4/19 2:42 AM, Marcel Apfelbaum 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,
>                                                           ^~~~~~~~~~~~~~~~
> 
> This is a false warning; even if RDMARegisterResult is "packed", rkey
> is the first field so is guaranteed to be aligned.

Not so. If you packed struct, gcc is free to abut that struct next to 
some other unaligned field in a larger struct:

https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg06743.html

> 
> Fix it by disabling the warning only for this instance.

Ignoring the bug is not the same as fixing the bug.  You need to rework 
this, as the compiler warning is not a false negative.

> 
> Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> ---
>   migration/rdma.c | 3 +++
>   1 file changed, 3 insertions(+)
-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04  8:42 [Qemu-devel] [PATCH] migration/rdma: clang compilation fix Marcel Apfelbaum
2019-03-04 18:11 ` Eric Blake [this message]
2019-03-04 18:18   ` Dr. David Alan Gilbert
2019-03-04 18:27     ` Marcel Apfelbaum
2019-03-04 18:30   ` Marcel Apfelbaum

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=550bead8-a9a5-d9f4-1204-a6130f8c8e14@redhat.com \
    --to=eblake@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).