Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2800509ybh; Mon, 9 Mar 2020 13:18:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu5rbFVgfKALOa8xglZVciwKt+d/PQe20w0lQM/FLQXn4QA3W/yEM1Jf2D/Hdux/Bmp5ryr X-Received: by 2002:aca:1101:: with SMTP id 1mr88179oir.30.1583785123619; Mon, 09 Mar 2020 13:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583785123; cv=none; d=google.com; s=arc-20160816; b=IkCb2m16WoJf3nVnfpLL08is11lZG7TlCnuE85WspvRGyW9W+wK8MougGtMb6lkrHL ufzp4NAquqNTmlFiCgQ+8yvZJ1adr6xrv6n+1s/BO/DOjHhvhS+nss6URVoyIX00sMVB 56V2Gs78qgIDvlwfvqRkuWBMgdl6oTW+0A0DHEZobPwfwbqq3BO0vYI6rYW+iVB22HWa zid1/CDA+zJfzVUjLEA1XHPjuRHBF111QKj2QCN4p5EfNERQYteypRYq/Yi7OEj/wAAW f5LsvUSrwS8plBXtJ9ganuy7kAt7LIvbYItjSb5T8n5YH7g4AoLbTqeHkQmRQlPq7aPT wVbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=BV2Jnn5mBU1Yoz/9sFxsLu4+VH7pPiDrzIggAJNSObA=; b=btRpWhp0gOrGfA6xv5hcKr2b6h4qWhTlzYp0gGie36JCjv1p1QOtEmSWnrxKG2Ki0z 57UDpRigjmqou49UcaPLo27Ix3jmyrgHMMucLYSw7eB6xCcocw+ybmQGmF4Fju8+5+6i pREX2hKDMP4rgMQqt7UeGT4a2J7e9MWGlEj3mPPVATlWcgse4jMacRJj6q2wicpFiqoy PuAJm45to5bNDaPt0NyAsGSYwkhkpL74v+OfGcNv9ej+c+H4LSjjzG/xghyChhOS1s1y pXhKCQE4VpD8dzAMipWajHqPTBKfzK/ho6G33vuC1CXBj4FOPp2DHn2SQHfysyHoVps+ reXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b="eyM/doeV"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o9si6399989otp.222.2020.03.09.13.18.31; Mon, 09 Mar 2020 13:18:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b="eyM/doeV"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726492AbgCIUQ2 (ORCPT + 99 others); Mon, 9 Mar 2020 16:16:28 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33454 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbgCIUQ1 (ORCPT ); Mon, 9 Mar 2020 16:16:27 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 029K8JTx141593; Mon, 9 Mar 2020 20:16:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=BV2Jnn5mBU1Yoz/9sFxsLu4+VH7pPiDrzIggAJNSObA=; b=eyM/doeVft43vVV18i6BOyBxMxTp3xE4b0pSWoGmli4URJruRKOwtj9V1+LQD4WLtPMt AyBlQnTXz5toahWngjKRrOgXHbeJzvY8V5zp2Q4GSJSl3R8R2EvI2keK4VT6okEAqOa1 pfOcFipFPv5vhp8lBlTL1orDD5p2QKkxRweI3xa7farnNYOm5cxuXu+T4MDpDi35gJiX p2PJAFqWc5kMj3xEmXlWy+xgXXXexd6M8OOYFM6U+1Y0DmB5N/oEuT8olds+4fE0RHm5 pzHZZxSevm9i+NXxJLrEwwCpgocJ9Vf6ogUlLrEotyq+USImKgp1UjlzCf3u3FbOf+42 nA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2ym3jqhdqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 20:16:02 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 029K76EW178158; Mon, 9 Mar 2020 20:16:01 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2ymn3grbe0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 20:16:01 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 029KG0mK006500; Mon, 9 Mar 2020 20:16:00 GMT Received: from [192.168.0.190] (/68.201.65.98) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 13:15:59 -0700 Subject: Re: [PATCH][next] jfs: Replace zero-length array with flexible-array member To: "Gustavo A. R. Silva" Cc: jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20200309182308.GA5087@embeddedor> From: Dave Kleikamp Autocrypt: addr=dave.kleikamp@oracle.com; prefer-encrypt=mutual; keydata= mQINBE7VCEMBEAC3kywrdIxxL/I9maTCxaWTBiHZFNhT5K8QZGLUfW3uFrW89PdAtloSEc1W ScC9O+D2Ygqwx46ZVA7qMXHxpNQ6IZp8he88gQ9lilWD8OJ/T3OKyT6ITdkmsgv6G08QdGCP 0+mCpETv79kcj+Z4pzKLN5QyKW40R3LGcJ6a+0AG5As5/ZkmhceSffdSyDS6zKff3c6cgfQH zl+ugygdKItr3UGIfxuzF3b9uYicsVStwIxyuyzY8i1yYYnnXZtWkI9ZwxT+00PqjCvfVioy xswoscukLQntlkfd4gwM8t56RIxqEo4iNmFwmBYHlSd7C+8SrvPAOgvOtr1vjzJhEsJ2uJNW O2pgZc8xMxe8vhyZK1Nih67hbtzSIpFij06zHwAt4AY3sCbWslOExb8JboINWhI89QcgNmMK uwLHag3D/zZQXQIBvC5H27T49NA6scA92j2qFO6Beks3n/HW6TJni/S9sUXRghRiGDdc/pFr 20R3ivRzKyYBoSWl/3Syo0JcWdEpqq6ti/5MTRFZ+HQjwgUGZ5w+Xu2ttq/q9MyjD4odfKuF WoXk3bF+9LozDNkRi+JxCNT9+D4lsm3kdFTUXHf/qU/iHTPjwYZd6UQeCHJPN6fpjiXolF+u qIwOed8g8nXEXKGafIl3zsAzXBeXKZwECi9VPOxT4vrGHnlTHwARAQABtDZEYXZpZCBLbGVp a2FtcCAoQUtBIFNoYWdneSkgPGRhdmUua2xlaWthbXBAb3JhY2xlLmNvbT6JAjgEEwECACIF Ak7VCEMCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEDaohF61QIxkpSsP/3DtjVT0 4vPPB7WWGWapnIb8INUvMJX84y4jziAk9dSESdPavYguES9KLOTXmAGIVwuZj5UtUNie4Q3V fZp7Mc7Lb3sf9r2fIlVJXVhQwMFjPYkPLbQBAtHlnt8TClkF2te47tVWuDqI4R0pwACKhUht lQRX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a1g3Ot6+HxgQM8LsZ5qq3BGUDB0DLHtMVu3r9x2327QSp/q2CgwPn2XzelQ0yNolAt 6wjbQwZXTGIGQGlpAFk7UOED/je8ANKYCkE0ZdqQigyoQFEZtyjYxzIzJRWLl4lJjhBSar1v TiSreQARAQABiQIfBBgBAgAJBQJO1QhDAhsMAAoJEDaohF61QIxk/DsP/RjCZHGEsiX0uHxu JzPglNp9mjgG5dGmgYn0ERSat4bcTQV5iJN2Qcn1hP5fJxKg55T8+cFYhFJ1dSvyBVvatee7 /A2IcNAIBBTYCPYcBC771KAU/JOokYu2lkrGM2SXq4XxpfDzohOS3LDGif47TYpEKWbP4AHq vcIl9CYvnhnbV+B/SxqhH7iYB6q2bqY6ki7fsk2lK65FFhlkkgsKyeOiuaVNEv3tmPCMAY/v oMAsCTLK63Wsd9pUY2SGt2ACIy7pTq+k1b09cqlTM2vux8/R0HNzQBXNcFiKKz+JNVObP30N /hsLs0+Ko9f/2OcixfkGjdih8I+FnRdS6wAO7k6g+tTBOj/sbSbH+eZbxWwANkiFkykOASGA /4RzIDie72NiM8lKzpyrlaruSFxuj9/wZuCT7jaYIaiOMPy7Y0Lpisy/hRhwDCNlKU6Hcr7k hQ1cIx4CB40fwqjbK61tWrqZR47pDKShl5DBRdeX/1a+WHXzDLVE4sfax5xL2wjiCUfEyH7x 9YJoKXbnOlKuzjsm9lZIwVwqw07Qi1uFmzJopHW0H3P6zUlujM0buDmaio+Q8znJchizOrQ3 58pn7BNKx3mmswoyZlDtukab9QGF7BZBMjwmafn1RuEVGdlSB52F8TShLgKUM+0dkFmI2yf/ rnNNL3zBkwD3nWcTxFnX Message-ID: <4e067af3-1996-8ab9-2135-ec49d4adcb96@oracle.com> Date: Mon, 9 Mar 2020 15:15:59 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200309182308.GA5087@embeddedor> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 mlxlogscore=960 phishscore=0 spamscore=0 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090123 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1011 priorityscore=1501 mlxscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090123 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Looks good. I'll queue this for linux-next. Shaggy On 3/9/20 1:23 PM, Gustavo A. R. Silva wrote: > The current codebase makes use of the zero-length array language > extension to the C90 standard, but the preferred mechanism to declare > variable-length types such as these ones is a flexible array member[1][2], > introduced in C99: > > struct foo { > int stuff; > struct boo array[]; > }; > > By making use of the mechanism above, we will get a compiler warning > in case the flexible array does not occur last in the structure, which > will help us prevent some kind of undefined behavior bugs from being > inadvertently introduced[3] to the codebase from now on. > > Also, notice that, dynamic memory allocations won't be affected by > this change: > > "Flexible array members have incomplete type, and so the sizeof operator > may not be applied. As a quirk of the original implementation of > zero-length arrays, sizeof evaluates to zero."[1] > > This issue was found with the help of Coccinelle. > > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > [2] https://github.com/KSPP/linux/issues/21 > [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") > > Signed-off-by: Gustavo A. R. Silva > --- > fs/jfs/jfs_dtree.c | 2 +- > fs/jfs/jfs_xattr.h | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c > index 3acc954f7c04..837d42f61464 100644 > --- a/fs/jfs/jfs_dtree.c > +++ b/fs/jfs/jfs_dtree.c > @@ -2964,7 +2964,7 @@ struct jfs_dirent { > loff_t position; > int ino; > u16 name_len; > - char name[0]; > + char name[]; > }; > > /* > diff --git a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h > index f0558b3348da..c50167a7bc50 100644 > --- a/fs/jfs/jfs_xattr.h > +++ b/fs/jfs/jfs_xattr.h > @@ -17,12 +17,12 @@ struct jfs_ea { > u8 flag; /* Unused? */ > u8 namelen; /* Length of name */ > __le16 valuelen; /* Length of value */ > - char name[0]; /* Attribute name (includes null-terminator) */ > + char name[]; /* Attribute name (includes null-terminator) */ > }; /* Value immediately follows name */ > > struct jfs_ea_list { > __le32 size; /* overall size */ > - struct jfs_ea ea[0]; /* Variable length list */ > + struct jfs_ea ea[]; /* Variable length list */ > }; > > /* Macros for defining maxiumum number of bytes supported for EAs */ >