From mboxrd@z Thu Jan 1 00:00:00 1970 In-reply-to: (message from Jan Engelhardt on Wed, 1 Aug 2007 13:44:13 +0200 (CEST)) Subject: Re: [RFC PATCH] type safe allocator References: Message-Id: From: Miklos Szeredi Date: Wed, 01 Aug 2007 13:56:22 +0200 Sender: owner-linux-mm@kvack.org Return-Path: To: jengelh@computergmbh.de Cc: miklos@szeredi.hu, andi@firstfloor.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, torvalds@linux-foundation.org List-ID: > >> > > >> > #define k_new(type, flags) ((type *) kmalloc(sizeof(type), flags)) > >> > >> The cast doesn't make it more safe in any way > > > >I does, since a warning will be issued, if the type of the assigned > >pointer doesn't match the requested allocation. > > > >And yes, warnings are _very_ useful in C for enforcing type safety. > > void *p; > p = (struct foo *)kmalloc(sizeof(struct foo), GFP_KERNEL); Using void pointers is _obviously_ not type safe. What has that got to do with k_new()? Miklos -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org