add an index page to preview the diagrams
[openafs-wiki.git] / CodingStyle.mdwn
index d8c809b..0793c1e 100644 (file)
@@ -103,8 +103,8 @@ For example:
 
     static int
     ValueOfNothing(afs_int32 nothing) {
-    ...
-     }
+        ...
+    }
 
 Prototypes for functions which are shared within a module should go into the a header file named _module_ \_internal.h
 
@@ -139,21 +139,21 @@ Header files should not contain macros or other definitions unless they are used
 - Use braces where it aids readability.
 - Closing and opening braces go on the same line as the control statement
 
-    if (foo) {
-    ...
-    } else {
-    ...
-    }
+        if (foo) {
+            ...
+        } else {
+            ...
+        }
 
 - Code surrounded by brackets should have its continuation lines lined up with the relevant opening brace
 
-    value = CostOfEverything(ValueOfNothing(0),
-                             fudge);
+        value = CostOfEverything(ValueOfNothing(0),
+                                 fudge);
 
 - Loops with an empty body should have their trailing semicolon on the following line, to make the empty body explicit, and suppress a compiler warning
 
-    for (...; ...; ...)
-        ;
+        for (...; ...; ...)
+            ;
 
 - Lines should be wrapped within 80 characters
 
@@ -185,7 +185,7 @@ All new code must compile cleanly when configured with --enable-warnings
 - Always use size\_t for sizes of objects, not int or unsigned long, even if they're small objects. Exception: wire protocol objects should instead use types with explicit sizes, such as afs\_int32.
 - Always use either size\_t or ptrdiff\_t for offsets into data structures or memory blocks, not int or long.
 - All new APIs that take buffers should also take the length of the buffer as an additional parameter.
-- Where possible, move assignments outside of conditionals. In general, write code = function(); if (code = 0) not if ((code = function()) = 0).
+- Where possible, move assignments outside of conditionals. In general, write code = function(); if (code == 0) not if ((code = function()) == 0).
 - Don't write new functions which take arrays as arguments
 
 ## <a name="Unix kernel module"></a> Unix kernel module