From patchwork Mon Jan 18 19:46:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 569655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 18903140C08 for ; Tue, 19 Jan 2016 06:47:10 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=GDv+WlJP; dkim-atps=neutral Received: from localhost ([::1]:33389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLFlb-0004mL-Qc for incoming@patchwork.ozlabs.org; Mon, 18 Jan 2016 14:47:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLFlL-0004VQ-4O for qemu-devel@nongnu.org; Mon, 18 Jan 2016 14:46:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLFlH-0001Wk-T0 for qemu-devel@nongnu.org; Mon, 18 Jan 2016 14:46:51 -0500 Received: from mail-ig0-x232.google.com ([2607:f8b0:4001:c05::232]:34178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLFlH-0001Wg-MB for qemu-devel@nongnu.org; Mon, 18 Jan 2016 14:46:47 -0500 Received: by mail-ig0-x232.google.com with SMTP id ik10so62393188igb.1 for ; Mon, 18 Jan 2016 11:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ozjbQaP21lR9j+rMLodThNKYnuosmK+siqIGjaOxLsI=; b=GDv+WlJPU5MyoqVCpIPCLkCNhGiATHFt0UhhjBWb9iRaVMhllg1rhPlPpsXeJpdpT4 q5G079F1ndxxoJNs4FLUQLZbE4Y5BIT08SUmyJz4k+LQyp658q3GQzGGuEt/ycpTqOzg 5gXHityOH2LYN14qyXn+p+Kc9BiMyZgzbxvTg3r8aV2v8hb72zishxqWb5W3MDrcPqHO 8zwSWXp52lBSqkhEqQzulZIHpuWm8fOwdv3Lh0HlOdC/7DfXLO9f3Kw67ytfYjtPHaS5 /oxJqAHaOQG1XjPght+siOVmXP8VcNJEEu9lv99zAhD/IHcni9jd21abfO/wZJAIbysV 6RLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=ozjbQaP21lR9j+rMLodThNKYnuosmK+siqIGjaOxLsI=; b=Tz5EsI4qV7kgEAAHsCnWYaNjzEzNrXdSrWezs/GIOvMuZE9GH5QnZEngRUQuxxNVK4 Dy3jX+WCWfiNxSbnw/RkMxwhsC7OVNrg6enONcjYMsBouBvI5SDm2L/Y7cj34/PFgair THIuEAvgXnlfLaHJt5iGKG+gRq2ZiuMNn+0LUmOxh1HspN+BdSJ2msN/dxyKNq4ATlen XaTccAG4rQwYbfhHLohFzVLwUfif0XM8QsPqlKFfHwk3uGxAWmqZO+0FZxalc7CeN52h c7KCHSc1+zKkExRcjkCSZGjdKUhxw/tLn/6qGiZ+hA+7hjsPNhi4BuYqvit2e8YxfhwF F4tA== X-Gm-Message-State: AG10YOTIzP3KVYG+4V27DZCeDcoKprqKDvuhEtw3vHvF8WsWSA+4UVFW+0RakyzTylMOyw== X-Received: by 10.50.92.99 with SMTP id cl3mr11316375igb.71.1453146407189; Mon, 18 Jan 2016 11:46:47 -0800 (PST) Received: from [192.168.0.3] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id d10sm1953053iod.23.2016.01.18.11.46.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jan 2016 11:46:45 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1084) From: Programmingkid In-Reply-To: Date: Mon, 18 Jan 2016 14:46:44 -0500 Message-Id: <3250EA09-DA61-41B2-A956-6CCE8D2C51F1@gmail.com> References: <5525054B-A7E2-4538-9F68-9E606B85B1B7@gmail.com> <569C224B.2040102@redhat.com> <1866CB23-7966-4F68-8925-2C3888753883@gmail.com> <569D24D2.3000800@redhat.com> To: Peter Maydell , Eric Blake X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c05::232 Cc: Paolo Bonzini , qemu-devel qemu-devel Subject: Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Jan 18, 2016, at 12:59 PM, Peter Maydell wrote: > On 18 January 2016 at 17:45, Eric Blake wrote: >> On 01/17/2016 04:45 PM, Programmingkid wrote: >>>> What's the definition of the CMSG_SPACE macro under OS X? >>>> >>>> Paolo >>> >>> #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) >> >> And the definition of __DARWIN_ALIGN32()? >> >> It looks like the definition is not properly resulting in a compile-time >> constant, and therefore the warning about the initializer is resulting >> because you can't initialize a dynamically-sized array. But you still >> haven't shown us why the headers are resulting in a non-constant size. > > FWIW, on my OSX system (OSX 10.10.5, Xcode 7.1), compiling the test > program with > > gcc -Wall -E -o /tmp/varray.S /tmp/varray.c > > shows that the array definition expands to > > char control[(((__darwin_size_t)((char > *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - > 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char > *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ > (sizeof(__uint32_t) - 1)))] = { 0 }; > > the relevant macro definitions being > #define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1) > #define __DARWIN_ALIGN32(p) ((__darwin_size_t)((char > *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ > __DARWIN_ALIGNBYTES32) > > > this is with a 'gcc' that gcc --version reports as > Configured with: > --prefix=/Applications/Xcode.app/Contents/Developer/usr > --with-gxx-include-dir=/usr/include/c++/4.2.1 > Apple LLVM version 7.0.0 (clang-700.1.76) > Target: x86_64-apple-darwin14.5.0 > Thread model: posix > > and which claims itself to be 4.2.1 by the printout from the test > program (ie it's clang under the hood). That is interesting. I would have thought Apple would have upgrade their GCC compatibility version by now. > > I don't get any compiler warnings from > gcc -Wall -O2 -o /tmp/varray /tmp/varray.c > > I don't know what the difference between my setup and John's is > (likely an older clang version). > > thanks > -- PMM A patch by Daniel P. Berrange successfully fixes this problem. http://patchwork.ozlabs.org/patch/569500/ + msg.msg_iov = (struct iovec *)iov; msg.msg_iovlen = niov; 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));