qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Samuel Thibault" <samuel.thibault@gnu.org>,
	"Peter Maydell" <peter.maydell@linaro.org>
Cc: Programmingkid <programmingkidx@gmail.com>,
	"qemu-devel@nongnu.org qemu-devel" <qemu-devel@nongnu.org>,
	Jan Kiszka <jan.kiszka@siemens.com>
Subject: Re: [Qemu-devel] SLIRP warning messages displayed while compiling
Date: Mon, 14 Aug 2017 11:05:14 -0500	[thread overview]
Message-ID: <0ff38a6f-f310-887d-dddb-f45e00f367cd@redhat.com> (raw)
In-Reply-To: <52a8c2c0-5d51-9c92-3dbe-3c25bd09e16e@amsat.org>

[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]

On 08/12/2017 10:38 AM, Philippe Mathieu-Daudé wrote:
> Hi Eric,
> 
> On 08/12/2017 08:41 AM, Eric Blake wrote:
>> Here's an idea:  Instead of using struct ip6 { ... } QEMU_PACKED, use
>>
>> struct ip6 {
>> ...
>> };
>> QEMU_BUG_ON(sizeof(struct ip6) != 32);
>>
>> so that the compiler explicitly chokes if it introduced any padding, and
>> then we know all our accesses are naturally aligned which shuts up the
>> warning.
> 
> Following your suggestion I tried:
> 
> #define QEMU_BUG_STRUCT_UNALIGNED(s) \
>         QEMU_BUILD_BUG_ON(sizeof(s) != sizeof(s QEMU_PACKED))

I don't think gcc likes that (you can't just add attribute packed in
arbitrary places, but only where the type is declared).

> 
> QEMU_BUG_STRUCT_UNALIGNED(struct ip6);
> 
> but this gives:
> 
> qemu/slirp/ip6.h:157:1: warning: 'packed' attribute ignored when parsing
> type [-Wignored-attributes]
> QEMU_BUG_STRUCT_UNALIGNED(struct ip6);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Indeed, there's the evidence that your attempt at a shortcut didn't
work. My proposal was to put in a hard-coded number, rather than try to
make the compiler compute two variants of the type and check that they
occupy the same space (although I agree with your idea that if you CAN
get the compiler to do that, it's nicer than hand-computing the number
to compare against).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

      reply	other threads:[~2017-08-14 16:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-10 20:44 [Qemu-devel] SLIRP warning messages displayed while compiling Programmingkid
2017-08-11 21:58 ` Samuel Thibault
2017-08-12 10:53   ` Peter Maydell
2017-08-12 11:04     ` Samuel Thibault
2017-08-12 11:18       ` Peter Maydell
2017-08-12 11:29         ` Samuel Thibault
2017-08-12 11:41           ` Eric Blake
2017-08-12 11:47             ` Samuel Thibault
2017-08-12 12:09               ` Eric Blake
2017-08-12 15:38             ` Philippe Mathieu-Daudé
2017-08-14 16:05               ` Eric Blake [this message]

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=0ff38a6f-f310-887d-dddb-f45e00f367cd@redhat.com \
    --to=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=jan.kiszka@siemens.com \
    --cc=peter.maydell@linaro.org \
    --cc=programmingkidx@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@gnu.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).