[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] bug with io/channel-socket.c - variable-sized object ma
From: |
Eric Blake |
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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
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
signature.asc
Description: OpenPGP digital signature