Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp808493rdb; Fri, 8 Sep 2023 18:17:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHk6DsGyRQCOEfZi8K+6N1huThbzmpIQVOJS1U1FBNxaLukvPNO93QBl6bT4ZLm+kvA81sc X-Received: by 2002:aa7:cfd9:0:b0:523:364b:e6a9 with SMTP id r25-20020aa7cfd9000000b00523364be6a9mr2926133edy.38.1694222232050; Fri, 08 Sep 2023 18:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694222232; cv=none; d=google.com; s=arc-20160816; b=iGl7TAohaSiHpf5JmvjYW1psWkZEPbemJEuTPCeycSshL0xhiF/i4Z3prkKoyU6U1m nSNBU+1ckv2Wn9+MLYR5iKsUkcaWT7NFVVQSCTvuxc30c9YeHpxBXSiLThacWTJGqbqv EJyfPNZEhdtpZT+zpiijOzlgXD6XUG/fBgLHJXD07Voxg3c0ylYOK8HrhwmiAEYg5/OM YPS3VvL9adI6OUluhynzqS66wzvpUfk0xxnv25n3/TSnAu1ApOgOajxPjIr5lLZ2i2Gw cEM2Q7HGyvmRZOWsGOq6YclWFAZjkRdq7RnjvWt3dLG+zvxeq2YD6iw6OJtlM7Cif4PZ lIeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=6PPorl9wVbuo1uuAa9GCQe4GH/N/mOgDSgRVOXiC4Xs=; fh=mYk0rn1iCNpFzlBr/qR7nhOonPTqScFGjijlC3Ef5CI=; b=O451AWVhfVLpkAGUzMlwnszRkzoffnbHFi/HTb0qL8el7pxPiHqZkz696Bba0qxnOz O4s4G9NQZw0azrhxuc6Ufl0wtkop5EkNs/yp0f7RNGDDVLwoxi2uxYOFrESlV47f1HEG 9N5E5N3AXYVX0UBeehkiGb/jG22JmjLaHwLx6zBTyfHe3rMzAdmkio4m7NvOjww6lAeC PextEPmWMyvZ5DmHc2XQlCEYGjOPxapgMI/np7Z8QrdiE7/uAIhx9nG5yKXtP2pE5kRL TfuoqkIwVGlgdyl5j8J3TtctcBgB5HZN4MKZb1wImEJMWWuR1mQVJr8+qGarFyb4s/Jx vqKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=A7smgSqU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u7-20020a056402064700b00523d2238264si2448399edx.255.2023.09.08.18.16.43; Fri, 08 Sep 2023 18:17:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=A7smgSqU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242670AbjIHLcm (ORCPT + 99 others); Fri, 8 Sep 2023 07:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231164AbjIHLcl (ORCPT ); Fri, 8 Sep 2023 07:32:41 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AAA61FC4; Fri, 8 Sep 2023 04:32:28 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-50091b91a83so3186488e87.3; Fri, 08 Sep 2023 04:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694172746; x=1694777546; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=6PPorl9wVbuo1uuAa9GCQe4GH/N/mOgDSgRVOXiC4Xs=; b=A7smgSqU4Vd386QnVTV4gVRiZrPnAOGPJOm/ioCkIRKcBoHfXLLows9ESUDmFm0cwA sqoNr1lrNek4DCTW3aGQiX4VtyVsgmWzeC7y+KzCnsU4jrsESy0A3N8i94OjZ+sVLkNf dwF5PUc1lLmnhaBv1TpSpLdPT083sb4iQbF/gx8IHxY1N5WhLNl52dEB6+L/nC9G//rA tSdJX3uapc1NfzVk41g8ERcFUJnKSclL60F4N6bwy0JMGGSVmGxOymEzB/UKSIZBlNaH bIZoBk6xHTH/pn+5NB9Y4KdG46K7uC28vR0kY/NlmAXcaRuwpJedFm3xcirQJ0ayphxt hL7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694172746; x=1694777546; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6PPorl9wVbuo1uuAa9GCQe4GH/N/mOgDSgRVOXiC4Xs=; b=Z0zM3U46h8Crk5kBhEGD+qOxJGHQMlcDq1H3VztuicERALwYxLlihUuR/t3UWWD6ND HlW0dlGLOg9I8baGU0WxtG4Kyej00gwssxvgKE+oPBfsc2znqA1ErxPC0P4pex1A6O01 i1H9Wi70iekKgIUyGf2WT1CHeolCPYo+EuOM45rtWqS8EkJ0NYgVPdTVJLDl8VT3UheL EUGqxqZN/6JUkEV/Ju8upj5laBxN0dqqIAPAuU0TTny2ro7UR5vwFWjASki+8uVw5+IM QT8j/5HPxu6b+Qpe0EcT/fO47233TQdsz0P61ieI05MjwSfeJvtmhQ7SoSiLbM4lM2Dt zYiA== X-Gm-Message-State: AOJu0Yz58OOEIiNkKCO8g54dkfiJ0z2kzHY7IO2N6OMkosZrG9zqJGfZ VPlLinoQM3h2yNMUbig4uQ== X-Received: by 2002:a19:6503:0:b0:500:8f65:c624 with SMTP id z3-20020a196503000000b005008f65c624mr1351524lfb.53.1694172746216; Fri, 08 Sep 2023 04:32:26 -0700 (PDT) Received: from p183 ([46.53.253.206]) by smtp.gmail.com with ESMTPSA id s6-20020aa7c546000000b00521953ce6e0sm906185edr.93.2023.09.08.04.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 04:32:25 -0700 (PDT) Date: Fri, 8 Sep 2023 14:32:24 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, keescook@chromium.org Subject: [PATCH] uapi: partially fix __DECLARE_FLEX_ARRAY for C++ Message-ID: <930c3ee5-1282-40f4-93e0-8ff894aabf3a@p183> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __DECLARE_FLEX_ARRAY(T, member) macro expands to struct { struct {} __empty_member; T member[]; }; which is subtly wrong in C++ because sizeof(struct{}) is 1 not 0, changing UAPI structures layouts. This can be fixed by expanding simply to T member[]; Most of the usages still be broken because of other C++ shenanigans but this fixes simplest usage: 1 flexible member at the end. Fix header guard while I'm at it. Signed-off-by: Alexey Dobriyan --- include/uapi/linux/stddef.h | 6 ++++++ 1 file changed, 6 insertions(+) --- a/include/uapi/linux/stddef.h +++ b/include/uapi/linux/stddef.h @@ -39,6 +39,10 @@ * struct, it needs to be wrapped in an anonymous struct with at least 1 * named member, but that member can be empty. */ +#ifdef __cplusplus +#define __DECLARE_FLEX_ARRAY(T, member) \ + T member[] +#else #define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ struct { \ struct { } __empty_ ## NAME; \ @@ -49,3 +53,5 @@ #ifndef __counted_by #define __counted_by(m) #endif + +#endif