Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3059096ybb; Sun, 22 Mar 2020 14:24:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt1ITeZEnwZX2pqpxnmZfCigVwiV6S/uILGxUJX+10g9/nFHDIK3v7sKJ5NEM9ekWn4Tp7f X-Received: by 2002:a9d:65ca:: with SMTP id z10mr12404804oth.244.1584912286506; Sun, 22 Mar 2020 14:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584912286; cv=none; d=google.com; s=arc-20160816; b=dCa28LysbOYBBw/vgRx8GmEw7Pyj/v64jJFtCmIPXz/vDrgooRyj7C8Ut4e9BhMHVn S1pXswrBtBAGoQ8kcrj7uoWeYot2bO2V493GOlIVqyadNghSEPhGh1Ar5njXsO+ScStW YT0gWlUn1CBWV1JMdM3zFfwIuczDmkY/EaX9KHWCHW/wmgtOEu9Db5OapUQ3GbUKx2HG QiPZ/fwGNGiReKKoB/g79+G75hlGk89zXvl8FGGHOX8+2shpVyZ1UnIeruQVFB8I/4Sc jzXXd+6jkYEtxJe2ig44Ia+HkQeAaKO0ypNUYong3X6hTLP/udzwxwnSSwaYgrWPhDcC C+Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=bUOd79kua10Onh+VIXoo0C6cZz9n6dOIiMp8HUldlXs=; b=IU26p+KjIvkkm3//Q6cgME8QAgOmBRY4a4TjN/zmrITXHXBthalZywpJSCoLtNouOW 6D7NlGAVaFi14fVsfmjwATv7Qovb9se8+wvEkPiWPrcaAb5PL4pG9TsKhIKQRXY7sK75 e3OkB0LYfNDbKgD2n+UpZqHpooEh1UyiRsN3a6VwKFWbrI/5AwSS07pBFD3cFdTnVzjO yJDbqGqgM6ZzVcIH9WEdKVpxnxW/7pyhByxjdOs+DJfp8or61oyC6tbz4ttEeAhibTRM 1WleumKzW0RO3qxfVQoZw26PvwfveI4u+rENZQuaOF+UtfNU2/78Eu7Chrv94E6O4/gR eJVw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=etezian.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a23si3240120oid.145.2020.03.22.14.24.29; Sun, 22 Mar 2020 14:24:46 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=etezian.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbgCVVX0 (ORCPT + 99 others); Sun, 22 Mar 2020 17:23:26 -0400 Received: from 8.mo2.mail-out.ovh.net ([188.165.52.147]:33499 "EHLO 8.mo2.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726756AbgCVVX0 (ORCPT ); Sun, 22 Mar 2020 17:23:26 -0400 X-Greylist: delayed 2224 seconds by postgrey-1.27 at vger.kernel.org; Sun, 22 Mar 2020 17:23:26 EDT Received: from player787.ha.ovh.net (unknown [10.110.171.54]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 473B51CE32D for ; Sun, 22 Mar 2020 21:46:21 +0100 (CET) Received: from etezian.org (213-243-141-64.bb.dnainternet.fi [213.243.141.64]) (Authenticated sender: andi@etezian.org) by player787.ha.ovh.net (Postfix) with ESMTPSA id B249710DAEC38; Sun, 22 Mar 2020 20:46:03 +0000 (UTC) Date: Sun, 22 Mar 2020 22:46:02 +0200 From: Andi Shyti To: "Gustavo A. R. Silva" Cc: Kukjin Kim , Krzysztof Kozlowski , Andi Shyti , Mark Brown , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] spi: spi-s3c24xx: Replace zero-length array with flexible-array member Message-ID: <20200322204602.GA131880@jack.zhora.eu> References: <20200320232556.GA24989@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200320232556.GA24989@embeddedor.com> X-Ovh-Tracer-Id: 14887774468655923905 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrudegiedgudegfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughiucfuhhihthhiuceorghnughisegvthgviihirghnrdhorhhgqeenucffohhmrghinhepghhnuhdrohhrghdpghhithhhuhgsrdgtohhmnecukfhppedtrddtrddtrddtpddvudefrddvgeefrddugedurdeigeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrhejkeejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheprghnughisegvthgviihirghnrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gustavo, On Fri, Mar 20, 2020 at 06:25:56PM -0500, 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 yes, thank you! Reviewed-by: Andi Shyti Andi