-1. Function names
+1. Coding Style
+
+ You should follow the style of the file you're editing. In general, we
+ try to follow the rules below.
+
+ 1) indent with tabs, and a tab is always 8 characters wide
+ 2) opening braces are on the same line as the if statement
+ 3) no braces in an if-body with just one statement
+ 4) if one of the branches of an if-else codition has braces, than the
+ other branch should also have braces
+ 5) there is always an empty line between variable declarations and the code
+
+ static int
+ my_function(void)
+ {
+ int a = 0;
+ if (a)
+ b();
+ else
+ c();
+ if (a) {
+ b();
+ c();
+ } else {
+ d();
+ }
+ }
+
+ 6) lines should be less than 80 characters wide
+ 7) when breaking lines with functions calls, the parameters are aligned
+ with the opening parenthesis
+ 8) when assigning a variable with the result of a function call, if the
+ line would be longer we break it around the equal '=' sign if it makes sense
+
+ long_variable_name =
+ function_with_a_really_long_name(parameter1, parameter2,
+ parameter3, parameter4);
+ x = function_with_a_really_long_name(parameter1, parameter2,
+ parameter3, parameter4);
+
+2. Function names
1) all internal function names should start with '__tpl'
2) externally exposed function names should start with 'tpl'
-2. Input argument checking
+3. Input argument checking
1) internal functions should TPL_ASSERT on non-null for all pointer type
argumentxs
Exception:
4) when externally exposed function is return due to error, TPL_ERR
should be called with appropriate error message
-3. Function calling
+4. Function calling
1) before calling internal function, caller function *MUST* check for
value validity before passing it to the callee
(internal functions do not check for input validity)
-4. Return value
+5. Return value
1) functions should return a value
Exception:
- failure is ignorable
4) other functions which return values useful to other callee may return
that value
-5. Documentation
+6. Documentation
1) *ALL* functions in libtpl-egl *MUST* be documented in Doxygen format
2) functions *MUST* have at least brief, param, and return sections
-6. Enumeration type
+7. Enumeration type
1) *ALL* enums *MUST* start with error code, 'xxx_ERROR' and assigned
value of -1
2) *ALL* enums *MUST* have identifier named 'xxx_MAX' to signify the end