From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKEES-0003TT-18 for qemu-devel@nongnu.org; Fri, 15 Jan 2016 18:56:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKEEM-0000EH-Vz for qemu-devel@nongnu.org; Fri, 15 Jan 2016 18:56:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKEEM-0000Dz-Pr for qemu-devel@nongnu.org; Fri, 15 Jan 2016 18:56:34 -0500 References: From: Eric Blake Message-ID: <56998731.8080307@redhat.com> Date: Fri, 15 Jan 2016 16:56:33 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BS4i1nS1eqKeM4rU2tXN8cSKq333gx0Nv" Subject: Re: [Qemu-devel] bug with io/channel-socket.c - variable-sized object may not be initialized List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Programmingkid , qemu-devel qemu-devel This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BS4i1nS1eqKeM4rU2tXN8cSKq333gx0Nv Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/13/2016 02:19 PM, Programmingkid wrote: > This code causes an error to occur during compiling:=20 >=20 > char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] =3D { 0 }; >=20 > It is located at line 496 in io/channel-socket.c.=20 >=20 > 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 ini= tialized > char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] =3D { 0 }; >=20 > This is from gcc 4.9 running on Mac OS 10.6.8.=20 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= =2E Can you capture what that line expands to after pre-processing, to see if my guess is right? >=20 > A quick fix to this problem is to replace everything in the parentheses= with 1000.=20 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --BS4i1nS1eqKeM4rU2tXN8cSKq333gx0Nv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWmYcxAAoJEKeha0olJ0Nqr5MH/0ugHe0qrVuQf0AsKWHX4hJg cNX+i67IFDm2IPBfbKi80FS8M715Z7iuzOdxjnZTP/wuYyl2DjC5eL3ZReU8WBpI CwiJha+d/OwccFXcmApX+/iE/p28+x+F4tFEZ0VXqW6sooma78UzgRiYKPtjNSKO kco0rW/AmX6TUXOZol+5ebwJDYyNmagj7Zw/kNJaaljVjAJE6n56t1BaOMTN2wMW 2s6yv5HvWukuYSK0HCE5Oi79ZiJWgUKHP+jZ+lKDQWulWO6ld1ceQLtH4KQctZM9 ymftAowf4QmK8eGL1ToFjdFIcBDqrV/QLgvlm+6GkWoQ0H0hnJs8KV3CghOIzI0= =/RQZ -----END PGP SIGNATURE----- --BS4i1nS1eqKeM4rU2tXN8cSKq333gx0Nv--