oRFC: 2 Coding Style Guide¶
OSSEC Coding Style Guide
|Name||OSSEC Style Guide|
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 .
The OSSEC Style Guide is meant to provide framework and guide of formating code contributer to OSSEC. The overall goals are:
- Maximize Readability of code in OSSEC;
- Reduction in the number of bugs by removing ambiguity in code and logic flow;
- Be as minimally invasive as possible while achieving the stated goals;
- Trust the contributor.
- Artistic Style should be used to format the source code.
- Every code style should be achieved by a astyle command argument.
- 4 spaces shall be used per indentation level. –indent=spaces=4
- Switch and case blocks shall be indented. –indent-switches
- Preprocessor conditional statements shall be indeted to the same level as the source code. –indent-preproc-cond
- Every files shall end with a newline.
- Every files shall have linux like line endings (\n). –lineend=linux
Breaking long lines and strings¶
Placing Braces and Spaces¶
- Braces shall be placed accoriding to the stroustrup style. –style=stroustrup
- Operators shall be padded by a space. –pad-oper
- Every branch of conditional statements shall be surrounded by brackets. –add-brackets
- Pointer and reference operators shall be attached to the variable name. –align-pointer=name
Typedefs & Struct¶