STYLE: fixes some concerns

This commit is contained in:
Emma Tebibyte 2024-07-28 00:12:34 -06:00
parent d45fa19d5c
commit aed64840ea
Signed by: emma
GPG Key ID: 06FA419A1698C270

13
STYLE
View File

@ -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 8. If a control flow statement is short enough to be easily understood in a
glance, it may be placed on a single line: 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 9. In C, note everything you use from a library in a comment subsequent to its
#include statement: #include statement:
@ -86,13 +86,13 @@ library crates. Group alike statements:
11. Do not use do while loops in C. 11. Do not use do while loops in C.
12. Follow the rules from the paper The Power of 10: Rules for Developing 12. Follow the following rules from the paper The Power of 10: Rules for
Safety-Critical Code [0]: Developing Safety-Critical Code [0]:
1. Avoid complex flow constructs, such as goto and recursion. 1. Avoid complex flow constructs, such as goto and recursion.
2. All loops must have fixed bounds. This prevents runaway code. 2. All loops must have fixed bounds. This prevents runaway code.
3. Avoid heap memory allocation. 3. Avoid heap memory allocation.
4. Restrict functions to a single printed page. 4. Restrict functions to the length of a single printed page.
5. Use a minimum of two runtime assertions per function.
6. Restrict the scope of data to the smallest possible. 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 7. Check the return value of all non-void functions, or cast to void to
indicate the return value is useless. 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 9. Limit pointer use to a single dereference, and do not use function
pointers. pointers.
10. Compile with all possible warnings active; all warnings should then be 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 References