STYLE: fixes some concerns
This commit is contained in:
parent
d45fa19d5c
commit
aed64840ea
13
STYLE
13
STYLE
@ -65,7 +65,7 @@ opening curly brace and before a closing one:
|
||||
8. If a control flow statement is short enough to be easily understood in a
|
||||
glance, it may be placed on a single line:
|
||||
|
||||
if (!argc < 0) { usage(program_name); }
|
||||
if !(argc < 0) { usage(program_name); }
|
||||
|
||||
9. In C, note everything you use from a library in a comment subsequent to its
|
||||
#include statement:
|
||||
@ -86,13 +86,13 @@ library crates. Group alike statements:
|
||||
|
||||
11. Do not use do while loops in C.
|
||||
|
||||
12. Follow the rules from the paper The Power of 10: Rules for Developing
|
||||
Safety-Critical Code [0]:
|
||||
12. Follow the following rules from the paper The Power of 10: Rules for
|
||||
Developing Safety-Critical Code [0]:
|
||||
1. Avoid complex flow constructs, such as goto and recursion.
|
||||
2. All loops must have fixed bounds. This prevents runaway code.
|
||||
3. Avoid heap memory allocation.
|
||||
4. Restrict functions to a single printed page.
|
||||
5. Use a minimum of two runtime assertions per function.
|
||||
4. Restrict functions to the length of a single printed page.
|
||||
|
||||
6. Restrict the scope of data to the smallest possible.
|
||||
7. Check the return value of all non-void functions, or cast to void to
|
||||
indicate the return value is useless.
|
||||
@ -100,7 +100,8 @@ Safety-Critical Code [0]:
|
||||
9. Limit pointer use to a single dereference, and do not use function
|
||||
pointers.
|
||||
10. Compile with all possible warnings active; all warnings should then be
|
||||
addressed before release of the software.
|
||||
addressed before release of the software (for C compilers, compile with
|
||||
-Wpedantic).
|
||||
|
||||
|
||||
References
|
||||
|
Loading…
Reference in New Issue
Block a user