From: "Daniel P. Berrange" <berrange@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Programmingkid <programmingkidx@gmail.com>,
qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] bug with io/channel-socket.c - variable-sized object may not be initialized
Date: Mon, 18 Jan 2016 09:54:04 +0000 [thread overview]
Message-ID: <20160118095404.GB13395@redhat.com> (raw)
In-Reply-To: <56998731.8080307@redhat.com>
On Fri, Jan 15, 2016 at 04:56:33PM -0700, Eric Blake wrote:
> On 01/13/2016 02:19 PM, Programmingkid wrote:
> > This code causes an error to occur during compiling:
> >
> > char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 };
> >
> > It is located at line 496 in io/channel-socket.c.
> >
> > Here is the full error message:
> > io/channel-socket.c: In function 'qio_channel_socket_writev':
> > io/channel-socket.c:496:18: error: variable-sized object may not be initialized
> > char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 };
> >
> > This is from gcc 4.9 running on Mac OS 10.6.8.
>
> Uggh. That sounds like a bug in the Mac OS headers, for making
> CMSG_SPACE() not be a compile-time constant. We do NOT want to be using
> variable-sized objects here, so we need a compile-time constant for the
> array size, even if we have to work around your platform's borked headers.
Note it only seems to be complaining about the initialization, not
the actual declaration. We already have similar code in QEMU elsewhere
eg
qemu-char.c: char control[CMSG_SPACE(sizeof(int) * TCP_MAX_FDS)];
which presumably works on OS-X
So the simple fix is to remove the '{ 0 }' initialization and just
memset instead eg
memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS));
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
prev parent reply other threads:[~2016-01-18 9:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-13 21:19 [Qemu-devel] bug with io/channel-socket.c - variable-sized object may not be initialized Programmingkid
2016-01-15 23:56 ` Eric Blake
2016-01-16 18:54 ` Programmingkid
2016-01-18 9:54 ` Daniel P. Berrange [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=20160118095404.GB13395@redhat.com \
--to=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=programmingkidx@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).