Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp131812ybj; Fri, 8 May 2020 08:06:41 -0700 (PDT) X-Google-Smtp-Source: APiQypKxLJ1DKQMAc6Q2F9h98kNwXh3BRGkTZKBNHSAT+Rt8bMgj6uRL93pMyEzlgmRx3VYLhr85 X-Received: by 2002:a05:6402:3121:: with SMTP id dd1mr2559797edb.168.1588950400917; Fri, 08 May 2020 08:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588950400; cv=none; d=google.com; s=arc-20160816; b=OEbfR5zwTPqQd5gPUjUJsyHKaG9nAN6Y5kIcWI3WlA6wWPS2Ul1KSzaH4WOKYOWsy2 ppSd0rBGCzFqyuziljomqjADXHC3SEgqok0mTM0xat2t89DA33K4YcICc2BvXvvBrr93 M6zz2EuD+iyOhyvthJN3NiI4oDbyzv/DC814XQepjAcIK44eResLZHIG4AG5Gfwz8L51 YWBpxrpdRBGVKg4sR8cLWCPoBUeioUq8Vv4YCSloQLRXzzDVXZFBSByAg8I3cAk/mtYb pkIOuRIMOskqXIl6EyZ0wPDgjAkAQqg3m8YuOZn3xbBa3Pwc2XkJa33choJZb3vsd77y 64uA== 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=ak+KS6cmfHXjY6qcAVO3aGp10fSQOuF6YLLnnfnHRtM=; b=bwHcGE2yytZc3mdetVia/9hlAbVPXI/+nAB85cD0XoyZpBuxlbYMHF3WkWg5Pb7OUC PiYTMCylCa2UQjLWcfUExK55/LqNgzXB0g6zLvbUMcEUY47KCoMYWAN7335bnjpd2Px3 O2jll0Jdbrbp+CUtxueZBx46Hu4O13H76XrHgLkFneR+GE54nNjQZ65cplryUjW/OA5a hvwCu6Bmh1ZKauHUY4jODBEWkkvDRGdSf+uWxUgs+41WLKTw67lNVhzuDMuLIJtByRrv 4mDj6FWTJUuhdwckn1sApnHGHoHWoQ4Itemcr0ckG++2vCHFMVM37ftfOVYH8i90G2I5 y7hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=YYBbcw9n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id cm24si991546edb.586.2020.05.08.08.06.16; Fri, 08 May 2020 08:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=YYBbcw9n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727925AbgEHPEE (ORCPT + 99 others); Fri, 8 May 2020 11:04:04 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:44076 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbgEHPEE (ORCPT ); Fri, 8 May 2020 11:04:04 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 048F3oTu122021; Fri, 8 May 2020 15:03:52 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=ak+KS6cmfHXjY6qcAVO3aGp10fSQOuF6YLLnnfnHRtM=; b=YYBbcw9nkzniiFX/z/kJ6hUg0596KLR4N6Sng4tfllHuxeU6JbSlEBO3ojO4dI5/wV+z hIa2AlOzb6Mecytdbepfp4LjqjJgPBAH8ZBPdh6yRgpg62OawOdvyVwBYNmJJ2ZfZ9aO qwr7EJUSKpcax/4VCZTVSKLpCENdIRFdtovSm0mPJaUA2gpn638J85CzTq7/sCqTjKxr js6Fdrqb07IHA9z5HXas2rOANFx8h+XMZvY/QDY4gDnF56MFdU7heEfG+9M4IdkGSbPJ oMLO7TFGj0HoXco3qG8j1Jn7cs/eI+Rt/7MZfIJsuK4svyblQ7XPJcaMDDPoiyAqmKSS Wg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30vtexufcr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 08 May 2020 15:03:50 +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 048F1tew021973; Fri, 8 May 2020 15:03:46 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 30vtecqgae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 08 May 2020 15:03:44 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 048F3gAv009790; Fri, 8 May 2020 15:03:42 GMT Received: from [192.168.0.190] (/68.201.65.98) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 08 May 2020 08:03:42 -0700 Subject: Re: [Jfs-discussion] [PATCH] JFS: Replace zero-length array with flexible-array To: "Gustavo A. R. Silva" Cc: jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20200507185550.GA14715@embeddedor> From: Dave Kleikamp Autocryp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LHtMVu3r9x2327QSp/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: <141a7573-bd2a-4b89-e62b-8e18464071ae@oracle.com> Date: Fri, 8 May 2020 10:03:41 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200507185550.GA14715@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=9614 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080134 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9614 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 mlxlogscore=999 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080134 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks Gustavo. I have already merged this into jfs-next. It was all I had queued up and I failed to push it in the last merge window to Linus. I'll make sure I get it in the next one. https://github.com/kleikamp/linux-shaggy/commits/jfs-next Shaggy On 5/7/20 1:55 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] > > sizeof(flexible-array-member) triggers a warning because flexible array > members have incomplete type[1]. There are some instances of code in > which the sizeof operator is being incorrectly/erroneously applied to > zero-length arrays and the result is zero. Such instances may be hiding > some bugs. So, this work (flexible-array member conversions) will also > help to get completely rid of those sorts of issues. > > 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 */ > > > > _______________________________________________ > Jfs-discussion mailing list > Jfs-discussion@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jfs-discussion >