2008-02-04 23:43:32

by Pavel Machek

[permalink] [raw]
Subject: CodingStyle: provide good example

if (!buffer) is actually prefered style, so lets use it in example.

Pavel

Signed-off-by: Pavel Machek <[email protected]>

diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index 6caa146..9bb2d8a 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -406,7 +415,7 @@ int fun(int a)
int result = 0;
char *buffer = kmalloc(SIZE);

- if (buffer == NULL)
+ if (!buffer)
return -ENOMEM;

if (condition1) {

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


2008-02-04 23:51:23

by Andrew Morton

[permalink] [raw]
Subject: Re: CodingStyle: provide good example

On Tue, 5 Feb 2008 00:43:43 +0100
Pavel Machek <[email protected]> wrote:

> if (!buffer) is actually prefered style, so lets use it in example.
>
> Pavel
>
> Signed-off-by: Pavel Machek <[email protected]>
>
> diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
> index 6caa146..9bb2d8a 100644
> --- a/Documentation/CodingStyle
> +++ b/Documentation/CodingStyle
> @@ -406,7 +415,7 @@ int fun(int a)
> int result = 0;
> char *buffer = kmalloc(SIZE);
>
> - if (buffer == NULL)
> + if (!buffer)
> return -ENOMEM;
>
> if (condition1) {

I tend to avoid preferring one over the other unless the extra seven
columns is needed to prevent wraparound nasties.

2008-02-05 00:21:33

by Jan Engelhardt

[permalink] [raw]
Subject: Re: CodingStyle: provide good example


On Feb 5 2008 00:43, Pavel Machek wrote:
>Subject: CodingStyle: provide good example
>
>if (!buffer) is actually prefered style, so lets use it in example.

Just because it is "preferred" by some does not mean it is bad.
I vote for diversity!