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