Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2946489ybl; Sun, 1 Sep 2019 03:28:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiRbk0Env6rQFYqFeXMmyjT5JRsacub4jQ+HcVfl7lXI+Ns3RWhXHKaiODxrT63UO5Wn3A X-Received: by 2002:a63:6d8d:: with SMTP id i135mr20374569pgc.303.1567333727816; Sun, 01 Sep 2019 03:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567333727; cv=none; d=google.com; s=arc-20160816; b=dKl/6ZXhOXTwOPZDk2Hw9y8jp7WILK2xTR8Ni9PwLFLfX06JgtDVhWg41xYXGlB/78 /A6uoLULMuo7PJtR3+jX6efV6ZPIi1lEOtb9iMbOws0gPxlREGVMh8YcdC3qkIqhyFZo hiSGnNFO3mcUY+UihGrw8H0YYmfSzG18Z2y2C4hgDBA6v3lIDYUT/+Y0Yw2VFwZYaaS2 Mw9SG6d1WehA1EKxjd1xHbtTPAclq+d+G4XQIj+G97cQnfB8Ou+SwQWKcUHexLpKETaA gguLwz35JaHCy4/Bk52vHV8fmn4EHXVvJ6YJJPoLkz9Ow1h/FLjL/oBh5XI0gt1/yAMY fgpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GHLIvHjnf4m6VJGPlCigLU2TO2rYIKNLxfQUgYM4HtA=; b=B9qoTF3TsZ84/MZ+M70gKZ8ZBYuq0UqidTIQ766Vsn6bd0Evm6JYPsrao7yWgbTd0Q YmbBUPw0/GKJEpePOzGkLyR6ES3DROVNkRyyjDLK7IboI6+ejIoKbzSpCN0nu1ViocFE aFQo8dlatr5Mp8YnJJWaddStBgQSALwguVwjiCBqgnkmIzEgbW7iGb7/IVhviEQsnkrZ lRWADiNuhug3bevbOYsZmwUZulbPUraqTlHeqBh7fHATH9KS10xIdJfFCyZlHfO+vyH1 cMc3qs/YghHwOw5jWtEDk+p6apRNSn8+QPRPc6KHPEKgpC8iyjoLw8+lUfAyAEU7X6WG SbIA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d63si9197302pld.139.2019.09.01.03.28.32; Sun, 01 Sep 2019 03:28:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728830AbfIAK0g (ORCPT + 99 others); Sun, 1 Sep 2019 06:26:36 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:47989 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728644AbfIAK0g (ORCPT ); Sun, 1 Sep 2019 06:26:36 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 7577382318; Sun, 1 Sep 2019 12:26:20 +0200 (CEST) Date: Sun, 1 Sep 2019 12:26:33 +0200 From: Pavel Machek To: "Gustavo A. R. Silva" Cc: Jacek Anaszewski , Dan Murphy , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [PATCH] leds: is31fl32xx: Use struct_size() helper Message-ID: <20190901102633.GB29681@amd> References: <20190830181448.GA24483@embeddedor> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3uo+9/B/ebqu+fSQ" Content-Disposition: inline In-Reply-To: <20190830181448.GA24483@embeddedor> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --3uo+9/B/ebqu+fSQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri 2019-08-30 13:14:48, Gustavo A. R. Silva wrote: > One of the more common cases of allocation size calculations is finding > the size of a structure that has a zero-sized array at the end, along > with memory for some number of elements for that array. For example: >=20 > struct is31fl32xx_priv { > ... > struct is31fl32xx_led_data leds[0]; > }; >=20 > Make use of the struct_size() helper instead of an open-coded version > in order to avoid any potential type mistakes. >=20 > So, replace the following function: >=20 > static inline size_t sizeof_is31fl32xx_priv(int num_leds) > { > return sizeof(struct is31fl32xx_priv) + > (sizeof(struct is31fl32xx_led_data) * num_leds); > } >=20 > with: >=20 > struct_size(priv, leds, count) >=20 > This code was detected with the help of Coccinelle. >=20 > Signed-off-by: Gustavo A. R. Silva Acked-by: Pavel Machek Pavel =09 --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --3uo+9/B/ebqu+fSQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl1rnNkACgkQMOfwapXb+vIPxgCgpsICdNpvVqiE62UuGfp0t9A8 QVQAn3e0reKEOTT22eUmr3FMkDGRBvUU =L98W -----END PGP SIGNATURE----- --3uo+9/B/ebqu+fSQ--