Message ID | 20160118095855.GC13395@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Jan 18, 2016, at 4:58 AM, Daniel P. Berrange wrote: > On Sun, Jan 17, 2016 at 05:23:44PM -0500, Programmingkid wrote: >> I was wondering if you had problems compiling QEMU on Mac OS X recently. On my system, the channel-socket.c file causes this error: >> >> io/channel-socket.c: In function 'qio_channel_socket_writev': >> io/channel-socket.c:497:18: error: variable-sized object may not be initialized >> char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; > > Can you try applying this patch: > > diff --git a/io/channel-socket.c b/io/channel-socket.c > index eaa411f..bc117b1 100644 > --- a/io/channel-socket.c > +++ b/io/channel-socket.c > @@ -493,10 +495,12 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc, > QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc); > ssize_t ret; > struct msghdr msg = { NULL, }; > - char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; > + char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)]; > size_t fdsize = sizeof(int) * nfds; > struct cmsghdr *cmsg; > > + memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); > + > msg.msg_iov = (struct iovec *)iov; > msg.msg_iovlen = niov; > > > > 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 :| Your patch solves the problem. Good job! Reviewed-By: John Arbuckle <programmingkidx@gmail.com>
On Mon, Jan 18, 2016 at 09:36:08AM -0500, Programmingkid wrote: > > On Jan 18, 2016, at 4:58 AM, Daniel P. Berrange wrote: > > > On Sun, Jan 17, 2016 at 05:23:44PM -0500, Programmingkid wrote: > >> I was wondering if you had problems compiling QEMU on Mac OS X recently. On my system, the channel-socket.c file causes this error: > >> > >> io/channel-socket.c: In function 'qio_channel_socket_writev': > >> io/channel-socket.c:497:18: error: variable-sized object may not be initialized > >> char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; > > > > Can you try applying this patch: > > > > diff --git a/io/channel-socket.c b/io/channel-socket.c > > index eaa411f..bc117b1 100644 > > --- a/io/channel-socket.c > > +++ b/io/channel-socket.c > > @@ -493,10 +495,12 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc, > > QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc); > > ssize_t ret; > > struct msghdr msg = { NULL, }; > > - char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; > > + char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)]; > > size_t fdsize = sizeof(int) * nfds; > > struct cmsghdr *cmsg; > > > > + memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); > > + > > msg.msg_iov = (struct iovec *)iov; > > msg.msg_iovlen = niov; > > > > Your patch solves the problem. Good job! > > Reviewed-By: John Arbuckle <programmingkidx@gmail.com> Thanks, I'll include this fix in my next PULL request for the io/ layer Regards, Daniel
diff --git a/io/channel-socket.c b/io/channel-socket.c index eaa411f..bc117b1 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -493,10 +495,12 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc, QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc); ssize_t ret; struct msghdr msg = { NULL, }; - char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; + char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)]; size_t fdsize = sizeof(int) * nfds; struct cmsghdr *cmsg; + memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); + msg.msg_iov = (struct iovec *)iov; msg.msg_iovlen = niov;