-
Notifications
You must be signed in to change notification settings - Fork 40
Coding style
Daniele Lacamera edited this page Nov 3, 2016
·
7 revisions
Please follow the following rules when coding in kernel:
-
Indentation and code arrangement
- Use 4-spaces indentation, no tabs.
- The opening bracket
{
at the beginning of the function must be put after a newline, and must not be in the same line as the function signature
-
Standard types usage
- Use standard types for integers (from
stdint.h
), so always preferuint8_t
tounsigned char
andint32_t
toint
whenever possible.
- Use standard types for integers (from
-
Custom data types definition and usage
-
typedef
is evil and should be avoided whenever possible. Some interfaces require an exception to this (e.g.heap.h
requires to define a custom type to be used). This is the only allowed case. - In no case ever use typedef to describe a function pointer type. Function pointer declarations must be explicit.
- Custom types cannot be anonymous (e.g. they must always be referred to using
enum foo
,struct bar
orunion foobar
)
-
Work in progress