From patchwork Tue Sep 29 04:30:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 523700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 1C7D814029C for ; Tue, 29 Sep 2015 14:30:17 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id AAC4910265; Mon, 28 Sep 2015 21:30:15 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 191831025E for ; Mon, 28 Sep 2015 21:30:14 -0700 (PDT) Received: from bar4.cudamail.com (bar2 [192.168.15.2]) by mx3v1.cudamail.com (Postfix) with ESMTP id 76134618240 for ; Mon, 28 Sep 2015 22:30:13 -0600 (MDT) X-ASG-Debug-ID: 1443501012-03dc21424800cc0001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar4.cudamail.com with ESMTP id kpJFzc998pKNoj4L (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 28 Sep 2015 22:30:12 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO mail-pa0-f50.google.com) (209.85.220.50) by mx3-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 29 Sep 2015 04:30:12 -0000 Received-SPF: unknown (mx3-pf1.cudamail.com: Multiple SPF records returned) X-Barracuda-Apparent-Source-IP: 209.85.220.50 X-Barracuda-RBL-IP: 209.85.220.50 Received: by padhy16 with SMTP id hy16so194009385pad.1 for ; Mon, 28 Sep 2015 21:30:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Zi5g6zs4Y6y28q7nBpJeIu7ZxZo+jsdhfXBX9U+XLRA=; b=ggPpz6f+ubT4cP/WI+eNSVPVxVbizrybmeR3LW8GhlqtvFvU6faA2yYp3e9kRjq42A niAmPeO0WTeKPtef+DgwR+T0aEeszejn1bqS1c1O2qNPZkbi4ggG8W/geJ0SZbAzsWcS G6o93wq4hcpExv0Zb43WZzRDhTCsZVyDYaJa32Wje97hOKSxk6aJ2JPvf6JXg3wrY+To ttJJsaokRnxYE/HU9PmDUzb+jRXgIxy/UXUYLU3D3O0upeJv2o/UcBtyhLvpRR4/xAkD Xt2EB4hQ2yGXzG60QN2+Le9adKoRf/C0yGiY1HU/3k9XyLnxHB/8vkm0MVYG8x4MpTaE kg7g== X-Gm-Message-State: ALoCoQm6eEDAW4WQxOlSSbHNTL+anO133hGVF3+RGsglyTH2FHTsQBQ320UfblHWdwcZZd07RNWS X-Received: by 10.66.190.41 with SMTP id gn9mr30458191pac.0.1443501012039; Mon, 28 Sep 2015 21:30:12 -0700 (PDT) Received: from sigabrt.gateway.sonic.net (173-228-112-165.dsl.dynamic.fusionbroadband.com. [173.228.112.165]) by smtp.gmail.com with ESMTPSA id rz9sm22447259pbb.61.2015.09.28.21.30.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Sep 2015 21:30:10 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V1-927084512 X-CudaMail-DTE: 092815 X-CudaMail-Originating-IP: 209.85.220.50 Date: Mon, 28 Sep 2015 21:30:05 -0700 X-ASG-Orig-Subj: [##CM-V1-927084512##][PATCH] tun-metadata: Avoid MSVC compile error on 64-bit builds for 0-length array. Message-Id: <1443501005-18192-1-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1443501012 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH] tun-metadata: Avoid MSVC compile error on 64-bit builds for 0-length array. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" MSVC does not support zero-size array unless it is the last member of a defined structure. The error is hit only on MSVC 64 bit because the size of uint64_t is equal with sizeof(struct tun_table *). Reported-by: Alin Gabriel Serdean Signed-off-by: Ben Pfaff Acked-by: Jesse Gross --- lib/tun-metadata.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tun-metadata.h b/lib/tun-metadata.h index 624c881..71842b7 100644 --- a/lib/tun-metadata.h +++ b/lib/tun-metadata.h @@ -63,12 +63,17 @@ struct tun_metadata { uint8_t len; /* Length of data in 'opts'. */ } present; struct tun_table *tab; /* Types & lengths for 'opts' and 'opt_map'. */ - uint8_t pad[sizeof(uint64_t) - sizeof(struct tun_table *)]; /* Make 8 bytes */ + +#if UINTPTR_MAX == UINT32_MAX + uint8_t pad[4]; /* Pad to 64-bit boundary. */ +#endif + union { uint8_t u8[TUN_METADATA_TOT_OPT_SIZE]; /* Values from tunnel TLVs. */ struct geneve_opt gnv[GENEVE_TOT_OPT_SIZE / sizeof(struct geneve_opt)]; } opts; }; +BUILD_ASSERT_DECL(offsetof(struct tun_metadata, opts) % 8 == 0); BUILD_ASSERT_DECL(sizeof(((struct tun_metadata *)0)->present.map) * 8 >= TUN_METADATA_NUM_OPTS);