CodingStyle.txt
author Knud Baastrup <kba@deif.com>
Tue, 14 Apr 2015 10:12:55 -0400
changeset 2625 e25af8bd3957
parent 2127 0814802f5928
permissions -rw-r--r--
Eoe mac address now derived from unique mac.
The EoE MAC address is now derived from the NIC part of the first global
unique MAC address of the linked list of available network interfaces or
otherwise the MAC address used by the EtherCAT master. The EoE MAC address
will get the format 02:NIC:NIC:NIC:RP:RP where NIC comes from the unique MAC
address (if available) and RP is the ring position of the EoE slave.
$Id$

vim: spelllang=en tw=78

This is a short introduction to the coding style that shall be used. The below
rules are applicable for all C source files, except the Ethernet drivers, for
which the Linux Kernel coding style shall be used to minimize the
differences).

1) Line length

- Lines shall not exceed 78 characters.

2) Whitespace

- Indentation shall be done using 4 space characters

- No whitespace shall be left at the end of a line.

- After commas, colons and semicolons, a single space shall be
  placed (if not followed by a line break).

- Binary operators (=, ==, ~=, |, ||, etc.) shall be enclosed by 2 spaces
  (except . and ->).

3) Placing braces

- Braces shall be placed in the following way (K&R style):

    if (...) {
        ...
    } else if (...) {
        ...
    } else {
        ...
    }

    int function(...)
    {
        ...
    }

4) Defines and Macros

- Defines and macros shall be named in CAPITAL letters. If a macro contains
  multiple statements, they should be enclosed by a 'do {} while (0)' loop.
  Macro parameters shall also be capital letters and shall be enclosed py
  parantheses if necessary.

    #define MACRO(A, B) \
        do { \
            if ((A) == 1) { \
                statement(B); \
        } while (0)