fp@2125: $Id$ fp@2125: fp@2125: vim: spelllang=en tw=78 fp@2125: fp@2125: This is a short introduction to the coding style that shall be used. The below fp@2125: rules are applicable for all C source files, except the Ethernet drivers, for fp@2125: which the Linux Kernel coding style shall be used to minimize the fp@2125: differences). fp@2125: fp@2128: 1) Line length fp@2125: fp@2128: - Lines shall not exceed 78 characters. fp@2125: fp@2128: 2) Whitespace fp@2125: fp@2128: - Indentation shall be done using 4 space characters fp@2125: fp@2128: - No whitespace shall be left at the end of a line. fp@2128: fp@2128: - After commas, colons and semicolons, a single space shall be fp@2128: placed (if not followed by a line break). fp@2128: fp@2128: - Binary operators (=, ==, ~=, |, ||, etc.) shall be enclosed by 2 spaces fp@2128: (except . and ->). fp@2128: fp@2128: 3) Placing braces fp@2128: fp@2128: - Braces shall be placed in the following way (K&R style): fp@2125: fp@2125: if (...) { fp@2125: ... fp@2125: } else if (...) { fp@2125: ... fp@2125: } else { fp@2125: ... fp@2125: } fp@2125: fp@2125: int function(...) fp@2125: { fp@2125: ... fp@2125: } fp@2125: fp@2128: 4) Defines and Macros fp@2128: fp@2128: - Defines and macros shall be named in CAPITAL letters. If a macro contains fp@2128: multiple statements, they should be enclosed by a 'do {} while (0)' loop. fp@2128: Macro parameters shall also be capital letters and shall be enclosed py fp@2128: parantheses if necessary. fp@2125: fp@2125: #define MACRO(A, B) \ fp@2125: do { \ fp@2125: if ((A) == 1) { \ fp@2125: statement(B); \ fp@2125: } while (0) fp@2125: