From: Eric Blake <eblake@redhat.com>
To: 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: Fri, 15 Jan 2016 16:56:33 -0700 [thread overview]
Message-ID: <56998731.8080307@redhat.com> (raw)
In-Reply-To: <AABBEB04-CD75-48FB-AD9E-2CC2FA2ADCA2@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1300 bytes --]
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.
Can you capture what that line expands to after pre-processing, to see
if my guess is right?
>
> A quick fix to this problem is to replace everything in the parentheses with 1000.
Yeah, but that's probably wrong, unless we know for sure that
sizeof(int)*SOCKET_MAX_FDS will never exceed 1000; in that case, it's
probably over-allocating.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-01-15 23:56 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 [this message]
2016-01-16 18:54 ` Programmingkid
2016-01-18 9:54 ` Daniel P. Berrange
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=56998731.8080307@redhat.com \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.