summaryrefslogtreecommitdiffstats
path: root/doc/coding-style.txt
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-07-29 13:08:40 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-07-30 17:19:55 -0500
commitc7b294717bfdf72d37a6f570525a882a1d4e1c9e (patch)
tree0726d7647b5ec2f75b8ca6d96f7691aa0bf222d4 /doc/coding-style.txt
parentb051f28dbe645cce7e4dc09449be91da54a12356 (diff)
downloadofono-c7b294717bfdf72d37a6f570525a882a1d4e1c9e.tar.bz2
doc: Update coding style
Diffstat (limited to 'doc/coding-style.txt')
-rw-r--r--doc/coding-style.txt45
1 files changed, 40 insertions, 5 deletions
diff --git a/doc/coding-style.txt b/doc/coding-style.txt
index a5d7799b..35b9f584 100644
--- a/doc/coding-style.txt
+++ b/doc/coding-style.txt
@@ -19,24 +19,41 @@ Besides the kernel coding style above, oFono has special flavors for its own.
Some of them are mandatory (marked as 'M'), while some others are optional
(marked as 'O'), but generally preferred.
-M1: Blank line before if statement
-==================================
+M1: Blank line before and after an if/while/do/for statement
+============================================================
There should be a blank line before if statement unless the if is nested and
not preceded by an expression or variable declaration.
Example:
1)
a = 1;
-if (a) { // correct
+if (b) { // wrong
2)
-a = 1;
-if (b) { // wrong
+a = 1
+
+if (b) {
+}
+a = 2; // wrong
3)
if (a) {
if (b) // correct
+4)
+b = 2;
+
+if (a) { // correct
+
+}
+
+b = 3;
+
+The only exception to this rule applies when a variable is being allocated:
+array = g_try_new0(int, 20);
+if (array == NULL) // Correct
+ return;
+
M2: Multiple line comment
=========================
@@ -114,6 +131,24 @@ if (additional == NULL)
return FALSE;
+M9: Follow the order of include header elements
+===============================================
+When writing an include header the various elements should be in the following
+order:
+ - #includes
+ - forward declarations
+ - #defines
+ - enums
+ - typedefs
+ - function declarations and inline function definitions
+
+
+M10: Internal headers must not use include guards
+=================================================
+Any time when creating a new header file with non-public API, that header
+must not contain include guards.
+
+
O1: Shorten the name
====================
Better to use abbreviation, rather than full name, to name a variable,