public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Combined APM patch
@ 2002-01-11 15:22 Thomas Hood
  2002-01-11 15:40 ` Russell King
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Hood @ 2002-01-11 15:22 UTC (permalink / raw)
  To: linux-kernel

>> Is it not good practice to note when the code _assumes_ zero-
>> initialization?  I have seen comments like these elsewhere in
>> the kernel sources.
>
> Comments should _not_ echo code.  One should assumes that the reader
> knows the language.  Instead, comments should explain _what the
> purpose_  of that line of code or section of code is if it is not
> obvious to those that the comments are written to.

I agree that comments should not try to explain C to the
reader.  Comments should provide additional information,
such as telling the reader what the code is supposed to
do (as opposed to what it actually does, which may or may
not be the same thing).

In the line
    static int suspends_pending; /* = 0 */
the comment is not there to tell the reader that the variable
is initialized to zero.  It is there to tell the reader that
the variable _needs to be_ initialized to zero in order for
the code to work properly.  This is useful information,
because if someone later wants to modify the code to make
this variable non-static, the comment tells that person that
the variable will need an initializer.

--
Thomas






^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH] Combined APM patch
@ 2002-01-10 18:37 Bob Toxen
  0 siblings, 0 replies; 10+ messages in thread
From: Bob Toxen @ 2002-01-10 18:37 UTC (permalink / raw)
  To: jdthood, linux-kernel, linux-laptop

> Just browsing the diff between my patch and Stephen's, I have
> a couple of questions.

> < static int			suspends_pending; /* = 0 */
> ---
> > static int			suspends_pending;

> Is it not good practice to note when the code _assumes_ zero-
> initialization?  I have seen comments like these elsewhere in
> the kernel sources.

Comments should _not_ echo code.  One should assumes that the reader
knows the language.  Instead, comments should explain _what the purpose_
of that line of code or section of code is if it is not obvious to those
that the comments are written to.

Thus, the following should be considered correct:

static int			suspends_pending;

Both of the following lines have superfluous code or commants and should
be avoided:

static int			suspends_pending; /* = 0 */
static int			suspends_pending = 0;

Likewise, parentheses where none are needed just get in the way of useful
stuff and slows down understanding the program.  Some parentheses in
complex expressions or when the precedence of operator evaluation is
confusing, such as bitwise ops can be helpful.

Btw, I have been writing system-level c code for 26 years and learned by
reading and modifying Unix system code at Berkeley.

Best regards,

Bob Toxen, CTO
Fly-By-Day Consulting, Inc.           "Experts in Linux & network security"
bob@cavu.com
http://www.cavu.com                   [Linux/Unix & Network Security Consulting]
http://www.realworldlinuxsecurity.com [My 5* book: "Real World Linux Security"]
http://www.cavu.com/sunset.html       [Sunset Computer]
Quality Linux, UNIX and network security and software consulting since 1990.

GPG Public key available at http://www.cavu.com/pubkey.txt (book@cavu.com)
  and at http://pgp5.ai.mit.edu/pks-commands.html#extract
  and on the CD-ROM that comes sealed and attached to Real World Linux Security
pub  1024D/E3A1C540 2000-06-21 Bob Toxen <book@cavu.com>
     Key fingerprint = 30BA AA0A 31DD B68B 47C9  601E 96D3 533D E3A1 C540
sub  2048g/03FFCCB9 2000-06-21

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH] Combined APM patch
@ 2002-01-10 16:20 David Balazic
  0 siblings, 0 replies; 10+ messages in thread
From: David Balazic @ 2002-01-10 16:20 UTC (permalink / raw)
  To: sfr; +Cc: linux-kernel@vger.kernel.org

Why is the APM_IOC_REJECT ioctl functionality still not merged ?
Does somebody hate it that much or are there any technical reasons ?

Party on,
-- 
David Balazic
--------------
"Be excellent to each other." - Bill S. Preston, Esq., & "Ted" Theodore Logan
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH] Combined APM patch
@ 2002-01-07  4:52 Stephen Rothwell
  2002-01-10 12:51 ` Thomas Hood
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Stephen Rothwell @ 2002-01-07  4:52 UTC (permalink / raw)
  To: Thomas Hood
  Cc: Russell King, Andreas Steinmetz, Borsenkow Andrej, linux-laptop,
	laslo, linux-kernel

Hi All,

This is my version of the combined APM patches;

	Change notification order so that user mode is notified
		before drivers of impending suspends.
	Move the idling back into the idle loop.
	A couple of small tidy ups.

See header comments for attributions.

This works for me (including as a module).

Please test and let me know - it seems to lower my power requirements
by about 10% on my Thinkpad (over stock 2.4.17).

http://www.canb.auug.org.au/~sfr/2.4.17-APM.1.diff

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-01-27  8:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-11 15:22 [PATCH] Combined APM patch Thomas Hood
2002-01-11 15:40 ` Russell King
2002-01-18 10:43   ` Thomas Hood
2002-01-18 10:57     ` Russell King
  -- strict thread matches above, loose matches on Subject: below --
2002-01-10 18:37 Bob Toxen
2002-01-10 16:20 David Balazic
2002-01-07  4:52 Stephen Rothwell
2002-01-10 12:51 ` Thomas Hood
2002-01-12  9:43 ` Borsenkow Andrej
2002-01-27  8:39 ` Borsenkow Andrej

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox