From: Michael Gerdau <mgerdau@tiscali.de>
To: Philippe Elie <phil.el@wanadoo.fr>
Cc: Russell Leighton <russ@elegant-software.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: OT: Does Linux have any "Perfect Code"
Date: Thu, 15 Nov 2007 14:16:42 +0100 [thread overview]
Message-ID: <200711151416.54570.mgerdau@tiscali.de> (raw)
In-Reply-To: <20071115082746.GA2885@zaniah>
[-- Attachment #1: Type: text/plain, Size: 2192 bytes --]
> This code is far to be perfect, some part is outdated, bcopy() use instead
> of memcpy() for example. More annoying are the comment, the file is 3306
> lines while there is only 1640 line of code, nothing bad per se but looking
> some comments:
>
> /*
> * Before we begin this operation, disable kernel preemption.
> */
> kpreempt_disable();
>
>
> uhh...
>
> or
>
> if (cyclic->cy_pend != 0) {
> /*
> * The pend is non-zero; ...
>
> I will never guessed that, w/o the comment :)
<disclaimer>
I'm not a kernel developer.
</disclaimer>
That having said:
I really do like such obvious (as in: for those knowing the stuff anyway)
comments when looking at code and probably concepts I'm not familiar with.
IMO there is no need to belittle this type of comment. IMO any casual
reader not familiar with the whole set of functions possibly involved
will be thankful for this type of comment - I certainly am.
> /*
> * We have both a left and a right child. We need to compare
> * the expiration times of the children to determine which
> * expires earlier.
> */
> if (cyclics[right].cy_expire < cyclics[left].cy_expire) {
>
> writing array[index] in C is already a promise than index is in
> [0-array size)
Yes. And ?
FWIW whenever I tried to look at kernel code I'm usually facing the
decision to
- either give up trying to understand what is intended or
- do a thorough search to learn everything required
I usually give up due to time constraints.
I mean, isn't the whole purpose of comments to help those not familiar
with the code to understand it's purpose and possibly the intention of
the author (just in case the author had coded a bug) ?
From my PoV this establishes a steep learning curve for "outsiders" to
start working on the kernel.
[just in case: don't give me anything along the line "this is an inherent
test as to the fitness of the potential hacker" ;]
Just my thoughts,
Michael
--
Vote against SPAM - see http://www.politik-digital.de/spam/
Michael Gerdau email: mgerdau@tiscali.de
GPG-keys available on request or at public keyserver
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
next prev parent reply other threads:[~2007-11-15 13:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-15 1:21 OT: Does Linux have any "Perfect Code" Russell Leighton
2007-11-15 1:33 ` David Miller
2007-11-15 6:29 ` Eric Dumazet
2007-11-15 7:11 ` David Miller
2007-11-15 7:43 ` Andi Kleen
2007-11-15 8:27 ` Philippe Elie
2007-11-15 13:16 ` Michael Gerdau [this message]
2007-11-15 15:10 ` Daniel Barkalow
2007-11-17 8:44 ` Geert Uytterhoeven
2007-11-15 17:05 ` Chris Friesen
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=200711151416.54570.mgerdau@tiscali.de \
--to=mgerdau@tiscali.de \
--cc=linux-kernel@vger.kernel.org \
--cc=phil.el@wanadoo.fr \
--cc=russ@elegant-software.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