Skip to contentSkip to conversation

CodingStyle: mention bitfields/whitespace style, prefer (!foo) in examples

PATCH Pavel Machek 3 participants 4 messages Oct 4, 2007 – Oct 6, 2007 Documentation

lore
Share & tools
lore
#0 lore raw

Mention whitespace and bitfields style, prefer (!foo) to (foo == NULL) in examples.

Documentation/CodingStyle +10 -1
index 7f1730f..1595a45 100644
@@ -71,6 +71,15 @@ used for indentation, and the above exam
 
 Get a decent editor and don't leave whitespace at the end of lines.
 
+Bitfield variables should be indented like this:
+
+	unsigned int foo :1;
+
+Do not put whitespace between any of the unary operators and their operand.
+
+It is usually unnecessary to have whitespace around parentheses as
+part of expressions, around brackets, or around the operators . and
+->.
 
 		Chapter 2: Breaking long lines and strings
 
@@ -403,7 +412,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

Documentation/CodingStyle used for indentation, and the above exam · line 76

Quoted 11 lines · Pavel Machek
Documentation/CodingStyle +0 -0
index 7f1730f..1595a45 100644
@@ -71,6 +71,15 @@ used for indentation, and the above exam
 

Get a decent editor and don't leave whitespace at the end of lines.

Documentation/CodingStyle +3 -0
+Bitfield variables should be indented like this:
+
+	unsigned int foo :1;

Current code uses foo:1.

#2 lore raw
Quoted 8 lines · Jan Engelhardt
Quoted 6 lines · Pavel Machek
Documentation/CodingStyle +0 -0
index 7f1730f..1595a45 100644
@@ -71,6 +71,15 @@ used for indentation, and the above exam
 
Quoted 7 lines

Documentation/CodingStyle used for indentation, and the above exam · line 76

Quoted 5 lines

Get a decent editor and don't leave whitespace at the end of lines.

Documentation/CodingStyle +3 -0
+Bitfield variables should be indented like this:
+
+	unsigned int foo :1;

Current code uses foo:1.

I'm fine with foo :1 or foo:1. It just would be nice to have example specifying one way...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw
Quoted 1 line · Pavel Machek

It just would be nice to have example specifying one way...

I don't see a necessity.

Signature · 3 lines
Stefan Richter
-=====-=-=== =-=- --==-
http://arcgraph.de/sr/