lkml.org 
[lkml]   [2007]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: OT: Does Linux have any "Perfect Code"
Date
> 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
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2007-11-15 14:41    [from the cache]
©2003-2011 Jasper Spaans