From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763390AbdEYLba (ORCPT ); Thu, 25 May 2017 07:31:30 -0400 Received: from esgaroth.petrovitsch.at ([78.47.184.11]:1287 "EHLO esgaroth.tuxoid.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758517AbdEYLb1 (ORCPT ); Thu, 25 May 2017 07:31:27 -0400 X-Greylist: delayed 2703 seconds by postgrey-1.27 at vger.kernel.org; Thu, 25 May 2017 07:31:26 EDT Message-ID: <1495709164.25090.23.camel@petrovitsch.priv.at> Subject: Re: [PATCH] CodingStyle: delete "kmalloc(sizeof(*var))" as preferred allocation form From: Bernd Petrovitsch To: Joe Perches , Alexey Dobriyan , Andrew Morton Cc: Linux Kernel Date: Thu, 25 May 2017 12:46:04 +0200 In-Reply-To: <1495708535.29207.1.camel@perches.com> References: <20170522213837.GA13861@avx2> <1495489398.2093.48.camel@perches.com> <20170522152227.52a9a7c48e8141056fc612c4@linux-foundation.org> <1495708535.29207.1.camel@perches.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-2.fc25) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-DCC-URT-Metrics: esgaroth.tuxoid.at 1060; Body=4 Fuz1=4 Fuz2=4 X-Spam-Report: * 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2017-05-25 at 03:35 -0700, Joe Perches wrote: > On Wed, 2017-05-24 at 13:18 +0300, Alexey Dobriyan wrote: > > Proper fix is to introduce typed allocation macros with the following > > signatures: > > > > T* lmalloc(T, gfp); Ack (FWIW). [...] > >     struct foo *x; > >     x = lmalloc(struct foo, GFP_KERNEL); > > Then code would be written > > x = lmalloc(typeof(*x), GFP_KERNEL); At least it is correct and changes automagically if x changes the type which struct bar *x; x = kmalloc(sizeof(struct foo), GFP_KERNEL); doesn't do and the compiler doesn't complain. And the typeof() version could be written that way today but I can't remember seeing it (in the kernel and elsewhere). MfG, Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at LUGA : http://www.luga.at