Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964932AbVKGUsj (ORCPT ); Mon, 7 Nov 2005 15:48:39 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965055AbVKGUsj (ORCPT ); Mon, 7 Nov 2005 15:48:39 -0500 Received: from mail.kroah.org ([69.55.234.183]:26813 "EHLO perch.kroah.org") by vger.kernel.org with ESMTP id S964932AbVKGUsi (ORCPT ); Mon, 7 Nov 2005 15:48:38 -0500 Date: Mon, 7 Nov 2005 12:46:53 -0800 From: Greg KH To: linas Cc: Paul Mackerras , linuxppc64-dev@ozlabs.org, johnrose@austin.ibm.com, linux-pci@atrey.karlin.mff.cuni.cz, bluesmoke-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks] Message-ID: <20051107204653.GA23705@kroah.com> References: <20051104005035.GA26929@mail.gnucash.org> <20051105061114.GA27016@kroah.com> <17262.37107.857718.184055@cargo.ozlabs.ibm.com> <20051107175541.GB19593@austin.ibm.com> <20051107182727.GD18861@kroah.com> <20051107185621.GD19593@austin.ibm.com> <20051107190245.GA19707@kroah.com> <20051107193600.GE19593@austin.ibm.com> <20051107200257.GA22524@kroah.com> <20051107204136.GG19593@austin.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051107204136.GG19593@austin.ibm.com> User-Agent: Mutt/1.5.11 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2266 Lines: 64 On Mon, Nov 07, 2005 at 02:41:36PM -0600, linas wrote: > On Mon, Nov 07, 2005 at 12:02:57PM -0800, Greg KH was heard to remark: > > On Mon, Nov 07, 2005 at 01:36:00PM -0600, linas wrote: > > > On Mon, Nov 07, 2005 at 11:02:45AM -0800, Greg KH was heard to remark: > > > > > > > > No, never typedef a struct. That's just wrong. > > > > > > Its a defacto convention for most C-language apps, see, for > > > example Xlib, gtk and gnome. > > > > The kernel is not those projects. > > !! Yeah, anyone who thinks that Xlib is the paradigm for coding style... > > > Also, "grep typedef include/linux/*" shows that many kernel device > > > drivers use this convention. > > > > They are wrong and should be fixed. > > What, precisely, is wrong? > > > See my old OLS paper on all about the problems of using typedefs in > > kernel code. > > Is this on the web somewhere? Google is having trouble finding it. http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_paper/codingstyle.ps and the presentation is at: http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ > > > > gcc should warn you > > > > just the same if you pass the wrong struct pointer > > > > > > There were many cases where it did not warn (I don't remember > > > the case of subr calls). I beleive this had to do with ANSI-C spec > > > issues dating to the 1990's; traditional C is weakly typed. > > > > > > Its not just gcc; anyoe who coded for a while eventually discovered > > > that tyedefs where strongly typed, but "struct blah *" were not. > > > > Sorry, but you are using a broken compiler if it doesn't complain about > > this. > > Uhh, gcc? Try it in the kernel today. You will get a warning if you pass in a pointer to a different structure type than it was defined as. > I was simply stating a fact about gcc and about standard ANSI-C > type-checking that is "well known" to anyone who's been around the > block. I was not trying to start an argument. Then let's end it here... thanks, greg k-h - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/