forked from openucx/ucx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeStyle
More file actions
60 lines (44 loc) · 1.89 KB
/
Copy pathCodeStyle
File metadata and controls
60 lines (44 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
* Style
- 4 spaces, no tabs
- up to 80 columns
- single space around operators
- no spaces in the end-of-line
- indent function arguments on column
- indent structure fields on column
- scope: open on same line, except function body, which is on a new line.
- indent multiple consecutive assignments on the column
- 2 space lines between types and prototypes (header files)
- 1 space line between functions (source files)
* Naming convention:
- lower case, underscores
- names must begin with ucp_/uct_/ucs_/ucm_
- macro names must begin with UCP_/UCT_/UCS_/UCM_
- an output argument which is a pointer to a user variable has _p suffix
- value types (e.g struct types, integer types) have _t suffix
- pointer to structs, which are used as API handles, have _h suffix
- macro arguments begine with _ (e.g _value) to avoid confusion with variables
- no leading underscores in function names
* C++
- used only for unit testing
- lower-case class names (same as stl/boost)
* Include order:
1. config.h
2. specific internal header
3. ucx headers
4. system headers
* Doxygen
- all interface H/C files should have doxygen documentation.
* Error handling
- all internal error codes must be ucs_status_t
- a function which returns error should print a log message
- the function which prints the log message is the first one which decides which
error it is. If a functions returns an error because it's callee returned
erroneous ucs_status_t, it does not have to print a log message.
- destructors are not able to propagate error code to the caller because they
return void. also, users are not ready to handle errors during cleanup flow.
therefore a destructor should handle an error by printing a warning or an
error message.
* Testing
- every major feature or bugfix must be accompanied with a unit test. In case
of a fix, the test should fail without the fix.
* Logging