public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kok, Auke" <auke-jan.h.kok@intel.com>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: randy.dunlap@oracle.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] [condingstyle] Add chapter on tests
Date: Sun, 27 May 2007 11:04:24 -0700	[thread overview]
Message-ID: <4659C828.80503@intel.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0705262121150.7344@yvahk01.tjqt.qr>

Jan Engelhardt wrote:
> On May 25 2007 10:25, Auke Kok wrote:
>> diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
>> index f518395..3635b38 100644
>> --- a/Documentation/CodingStyle
>> +++ b/Documentation/CodingStyle
>> @@ -393,7 +393,7 @@ int fun(int a)
>> 	int result = 0;
>> 	char *buffer = kmalloc(SIZE);
>>
>> -	if (buffer == NULL)
>> +	if (!buffer)
>> 		return -ENOMEM;
> 
> Please don't do this. With ==NULL/!=NULL, it is clear what
> <randomvariable> could be (integer or pointer) without needing
> to look it up. It also reads quite strange: "if not buffer".
> For bools ('adjectives' / 'is a'), it works, not so much for ptrs.
> Hence:
> 
>> +If you give your variables and pointers good names, there is never a need
>> +to compare the value stored in that variable to NULL or true/false, so
>> +omit all that and keep it short.
> 
>> +	ptr = s->next;
>> +	if (!ptr)
>> +		return;
> 
> Not agreed.

that piece is a copy of mm/slab.c, and all over the core components of the 
kernel (even fs/inode.c written by Linus). I strongly think that "== NULL" 
doesn't add anything and that well-written functions and well-named variables 
really do not need the extra fluff.

Auke

  parent reply	other threads:[~2007-05-27 18:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-25 17:25 [PATCH 1/2] [CodingStyle] Add comment to not put spaces before tabs Auke Kok
2007-05-25 17:25 ` [PATCH 2/2] [condingstyle] Add chapter on tests Auke Kok
2007-05-25 17:34   ` Stefan Richter
2007-05-25 17:40     ` Kok, Auke
2007-05-26 19:27   ` Jan Engelhardt
2007-05-26 20:13     ` [PATCH] " Jan Engelhardt
2007-05-26 22:35       ` Scott Preece
2007-05-27 14:37       ` Stefan Richter
2007-05-27 15:02         ` Jan Engelhardt
2007-05-27 15:23           ` Stefan Richter
2007-05-27 15:52             ` Jan Engelhardt
2007-05-27 21:01       ` Guennadi Liakhovetski
2007-05-27 18:04     ` Kok, Auke [this message]
2007-05-27 20:17       ` [PATCH 2/2] " Pekka Enberg
2007-05-27 16:08   ` Jesper Juhl
2007-05-25 17:32 ` [PATCH 1/2] [CodingStyle] Add comment to not put spaces before tabs Stefan Richter
2007-05-25 19:43   ` H. Peter Anvin
2007-05-25 20:29     ` Kok, Auke
2007-05-25 21:26       ` H. Peter Anvin

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=4659C828.80503@intel.com \
    --to=auke-jan.h.kok@intel.com \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=randy.dunlap@oracle.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