| | 41 | |
| | 42 | === Some Hints === |
| | 43 | |
| | 44 | A snippet cut out of a mail from Christian Franke on developers list.. |
| | 45 | |
| | 46 | Due to its long history, many contributors and late move from C to C++, smartmontools is in fact a mixture of different coding styles. |
| | 47 | |
| | 48 | In my recent additions I used (or tried to use) the following for new code: |
| | 49 | |
| | 50 | {{{ |
| | 51 | Naming: |
| | 52 | lowercase_underline_lowercase (like C++ std::) |
| | 53 | |
| | 54 | Indentation: |
| | 55 | 2 Blanks, no tab characters |
| | 56 | |
| | 57 | No extra indentation level for {...} blocks |
| | 58 | |
| | 59 | No extra line for '{' except for the function body. |
| | 60 | |
| | 61 | Lokal variables: |
| | 62 | C++/C99 declaration statements: First use=declaration=initialization |
| | 63 | (I really dislike traditional C style with all decls at the beginning of a block :-) |
| | 64 | |
| | 65 | Null pointers: |
| | 66 | "Stroustrup Style": 0 instead of NULL, |
| | 67 | (T *)0 if needed or compiler check is desired. |
| | 68 | |
| | 69 | Checks in boolean style: if (p) ; if (!p) ; |
| | 70 | |
| | 71 | In comments: "nullptr" (forward compatible to C++0x :-) |
| | 72 | |
| | 73 | Exceptions: |
| | 74 | Avoid any try/catch blocks if possible, use RAII instead |
| | 75 | }}} |