[lkml]   [2007]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 2/2] [condingstyle] Add chapter on tests

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.

>+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.

>+ v = (read_byte(register));
>+ if (v & mask)
>+ return;

well, yes.

>+ if (is_prime(number))


And I'd also like to mention one rather special case where I'd rather
like to see ==0 than ! for clarity (!strcmp looks like !streq, so
one needs to look twice to get it):

if (!strcmp(hay, needle))

At least don't force the '!' doctrine.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-05-26 21:33    [W:0.081 / U:12.292 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site