Skip to contentSkip to conversation

CodingStyle: provide good example

PATCH Pavel Machek 3 participants 3 messages Feb 4, 2008 – Feb 5, 2008 Documentation

lore
Share & tools
lore
#0 lore raw

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

Pavel

Documentation/CodingStyle +1 -1
index 6caa146..9bb2d8a 100644
@@ -406,7 +415,7 @@ int fun(int a)
 	int result = 0;
 	char *buffer = kmalloc(SIZE);
 
-	if (buffer == NULL)
+	if (!buffer)
 		return -ENOMEM;
 
 	if (condition1) {
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#1 lore raw
Quoted 11 lines · 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

Documentation/CodingStyle +0 -0
index 6caa146..9bb2d8a 100644

Documentation/CodingStyle int fun(int a) · line 421

Quoted 8 lines
Documentation/CodingStyle +1 -1
@@ -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.

#2 lore raw
In reply to Pavel Machek
Quoted 3 lines · Pavel Machek

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!