From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F13CC282C3 for ; Tue, 22 Jan 2019 10:57:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A27520870 for ; Tue, 22 Jan 2019 10:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727945AbfAVK5X (ORCPT ); Tue, 22 Jan 2019 05:57:23 -0500 Received: from mga03.intel.com ([134.134.136.65]:63201 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726095AbfAVK5X (ORCPT ); Tue, 22 Jan 2019 05:57:23 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2019 02:57:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,505,1539673200"; d="scan'208";a="312370289" Received: from cmicsa-mobl1.ti.intel.com ([10.252.18.12]) by fmsmga006.fm.intel.com with ESMTP; 22 Jan 2019 02:57:20 -0800 Message-ID: <22f42ab6d50058356adef00007dc96ff75d2e77e.camel@intel.com> Subject: Re: [PATCH][next] iwlwifi: mvm: use struct_size() in kzalloc() From: Luciano Coelho To: "Gustavo A. R. Silva" , Johannes Berg , Emmanuel Grumbach , Intel Linux Wireless , Kalle Valo , "David S. Miller" Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 22 Jan 2019 12:57:19 +0200 In-Reply-To: <20190115220246.GA23339@embeddedor> References: <20190115220246.GA23339@embeddedor> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.3-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-01-15 at 16:02 -0600, 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: > > struct foo { > int stuff; > struct boo entry[]; > }; > > instance = kzalloc(sizeof(struct foo) + count * sizeof(struct boo), > GFP_KERNEL); > > Instead of leaving these open-coded and prone to type mistakes, we > can now > use the new struct_size() helper: > > instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL); > > This code was detected with the help of Coccinelle. > > Signed-off-by: Gustavo A. R. Silva > --- Dropped. This is a duplicate. -- Luca.