public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Aloni <da-x@gmx.net>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: "Thomas 'Dent' Mirlacher" <dent@cosy.sbg.ac.at>,
	Andreas Dilger <adilger@clusterfs.com>,
	Lightweight patch manager <patch@luckynet.dynu.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] 2.5.21 - list.h cleanup
Date: Mon, 10 Jun 2002 20:51:45 +0300	[thread overview]
Message-ID: <20020610175145.GA10827@callisto.yi.org> (raw)
In-Reply-To: <Pine.GSO.4.05.10206101846060.17299-100000@mausmaki.cosy.sbg.ac.at> <Pine.LNX.4.44.0206100954250.30535-100000@home.transmeta.com>

On Mon, Jun 10, 2002 at 10:02:21AM -0700, Linus Torvalds wrote:
> The linux coding style _tends_ to avoid using typedefs. It's not a hard
> rule (and I did in fact apply this patch, since it otherwise looked fine),
> but it's fairly common to use an explicit "struct xxxx" instead of
> "xxxx_t".

I agree. For a better future:

--- linux-2.5.21/Documentation/CodingStyle	Mon Jun 10 20:29:26 2002
+++ linux-2.5.21/Documentation/CodingStyle	Mon Jun 10 20:46:06 2002
@@ -264,3 +264,35 @@
 
 Remember: if another thread can find your data structure, and you don't
 have a reference count on it, you almost certainly have a bug.
+
+
+		Chapter 9: Typedefs
+
+You should avoid using typedefs. It's not a hard rule but it's fairly 
+common to use an explicit "struct xxxx" instead of "xxxx_t".
+
+Hiding the fact that it's a struct causes bad things if people don't
+realize it: allocating structs on the stack is something you should be
+aware of (and careful with), and passing them as parameters is is much
+better done explicitly as a "pointer to struct".
+
+There are _some_ exceptions. For example, "pte_t" etc might well be a
+struct on most architectures, and that's ok: it's expressly designed to be
+an opaque (and still fairly small) thing. This is an example of where
+there are clear _reasons_ for the abstraction, not just abstraction for
+its own sake.
+
+For example, some people like to do things like: 
+
+ /* BAD!!! */    typedef unsigned int counter_t;    /* BAD!!! */
+
+and then use "counter_t" all over the place. I think that's not just ugly,
+but stupid and counter-productive. It makes it much harder to do things
+like "printk()" portably, for example ("should I use %u, %l or just %d?"),
+and generally adds no value. It only _hides_ information, like whether the
+type is signed or not.
+
+There is nothing wrong with just using something like "unsigned long"
+directly, even if it is a few characters longer than you might like. And
+if you care about the number of bits, use "u32" or something. Don't make
+up useless types that have no added advantage.

-- 
Dan Aloni
da-x@gmx.net


P.S.
list_t was added between 2.5.1-pre9 and 2.5.1-pre10, when you applied 
Ingo's scalable scheduler code. Since then it gained a few users: device.h, 
fs.h, sched.h, and mm.h. It can be kicked out easily.

  parent reply	other threads:[~2002-06-10 17:53 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-09 11:09 [PATCH][2.5] introduce list_move macros Lightweight patch manager
2002-06-09 11:23 ` Mark Zealey
2002-06-10 14:17   ` Thunder from the hill
2002-06-09 11:48 ` OGAWA Hirofumi
2002-06-09 12:02   ` Thomas 'Dent' Mirlacher
2002-06-09 12:01 ` Russell King
2002-06-09 12:42 ` [PATCH][2.5] introduce list_move macros (revisited) Lightweight patch manager
2002-06-10 15:14   ` Dan Aloni
2002-06-10 15:28   ` [PATCH] 2.5.21 - list.h cleanup Dan Aloni
2002-06-10 15:45     ` Thunder from the hill
2002-06-10 16:37     ` Andreas Dilger
2002-06-10 16:50       ` Thomas 'Dent' Mirlacher
2002-06-10 17:02         ` Linus Torvalds
2002-06-10 17:07           ` Thomas 'Dent' Mirlacher
2002-06-10 17:21             ` Linus Torvalds
2002-06-11  8:00               ` Rusty Russell
2002-06-11  8:33                 ` Linus Torvalds
2002-06-11  8:48                   ` Martin Dalecki
2002-06-11  9:04                   ` Martin Dalecki
2002-06-11  9:14                   ` Rusty Russell
2002-06-12 19:45                     ` Ingo Molnar
2002-06-13  5:51                       ` Rusty Russell
2002-06-13 14:18                         ` Ingo Molnar
2002-06-11 14:52                   ` george anzinger
2002-06-11 16:03                     ` Daniel Phillips
2002-06-12  1:10                     ` Rusty Russell
2002-06-12  1:29                       ` Linus Torvalds
2002-06-12  6:02                         ` Rusty Russell
2002-06-12  7:11                         ` Martin Dalecki
2002-06-12  7:27                           ` Andrew Morton
2002-06-11 17:54                   ` Gerrit Huizenga
2002-06-12  3:49                     ` Rusty Russell
2002-06-12 17:30                       ` Gerrit Huizenga
2002-06-10 17:26           ` Manik Raina
2002-06-10 17:51           ` Dan Aloni [this message]
2002-06-10 21:28     ` Thunder from the hill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020610175145.GA10827@callisto.yi.org \
    --to=da-x@gmx.net \
    --cc=adilger@clusterfs.com \
    --cc=dent@cosy.sbg.ac.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patch@luckynet.dynu.com \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox