Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp9014290ybi; Fri, 7 Jun 2019 02:00:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiFriuR92Mttrh6F2hN3fYpDQIEN7FDhraEiBH4fncLlJRWJZRpt8+SorgpAds7q4Ky5oc X-Received: by 2002:a65:51c7:: with SMTP id i7mr1799113pgq.211.1559898051469; Fri, 07 Jun 2019 02:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559898051; cv=none; d=google.com; s=arc-20160816; b=mpKjAzF3FaSOGcTnSKq+3/0reMttjyo/e5/Ves4ZAnqYzJTBLW8VEcMeU+LqKHzgQc U86yJLJugqBsK/zjOzUdiv4mSZFBTNclXbDQvcVyC4ecQxr8GzL61zpo7miqhjABUVYK srjXnlcUU43ldlWbyMXRr2x0MyN1pBcs1vaDayvlJ5H2JjZZqFu7g5fpcgzOPwHoldT9 6XDdnoHJ1qtuXgK4iv8bRnonrVOqsdbM+PSZx0V+JMQRvV22zmFOaiHh0+TMBcProh1q r5ZvViahirSyXW+S1/OKlLfsSxEsxCMnkHb1ZEZf6LDAfPE35rjF55HfNftvEuPf/cn4 PpoQ== 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:dkim-signature; bh=Kw+WMThRk3TWC+nW86vaJo45xiiZ2Qa2pRvveVD6G2M=; b=r/wEeMNrEi8pHkVYzkMRq2vzPsoyxNf6YfS+xkc0eaqMklbOnya3b/05b6eo2olNJP g3NC1CR9Z5t5WxMjpezGbQYK/HRU44K/wprSu8ePgogZ+37axaCHzFyZxzeLzZMGGVBs mrGj1uKqpBg9Hrrq7c2r+bbv2jF68s0Hv1JlzTfbnhYa/TjCtkydcE1FpJ4USL0m1pls aLZ7B1FM5TrDugyYFQwzpoScMHQutAh9w76oOXNelVydrESF+jI77dnOXZOWWxxecm46 ueNCYqHPs+Xmp4Kn/aUYAwFITKkTStr0Udn9Hk0xdJk8qEfjf6iocH6qmLCGrzf0vPDd 2/GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HWHBaSZi; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id co12si1343693plb.384.2019.06.07.02.00.34; Fri, 07 Jun 2019 02:00:51 -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=@kernel.org header.s=default header.b=HWHBaSZi; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbfFGI5u (ORCPT + 99 others); Fri, 7 Jun 2019 04:57:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:57326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727057AbfFGI5u (ORCPT ); Fri, 7 Jun 2019 04:57:50 -0400 Received: from linux-8ccs (nat.nue.novell.com [195.135.221.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F1060208E3; Fri, 7 Jun 2019 08:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559897869; bh=GDQQkIPrp8fJsI5KojkhANtLnK4mw4SxKGgTPey7gwU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HWHBaSZifG1cQfkXr8gDeMR0NJAzbaUI+dY2nr/6PTBUl4SR4pbrcTL6MzgsR0j8j DUnT2KYRWnk+4Vpf2jMfe4cVrIlUAESlfuPi/HSomg8E1LMd+2RuScYWkCSV4ENFBk w+mjDmVxgK4aYyPD+f4EIixPt8ErWYRIGdpqgy6c= Date: Fri, 7 Jun 2019 10:57:46 +0200 From: Jessica Yu To: "Gustavo A. R. Silva" Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] kernel: module: Use struct_size() helper Message-ID: <20190607085746.GA4211@linux-8ccs> References: <20190606181853.GA29960@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190606181853.GA29960@embeddedor> X-OS: Linux linux-8ccs 5.1.0-rc1-lp150.12.28-default+ x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Gustavo A. R. Silva [06/06/19 13:18 -0500]: >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: > >struct module_sect_attrs { > ... > struct module_sect_attr attrs[0]; >}; > >Make use of the struct_size() helper instead of an open-coded version >in order to avoid any potential type mistakes. > >So, replace the following form: > >sizeof(*sect_attrs) + nloaded * sizeof(sect_attrs->attrs[0] > >with: > >struct_size(sect_attrs, attrs, nloaded) > >This code was detected with the help of Coccinelle. > >Signed-off-by: Gustavo A. R. Silva >--- >Changes in v2: > - Update changelog text by adding a better description for > the motivation and usage of the struct_size() helper. Applied. Thanks a lot! Jessica