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