4 This document sets the coding style for Jailhouse code contributions.
5 In general, Jailhouse coding style for C is the same as for Linux kernel
6 (checkable with scripts/checkpatch.pl and detailed in
7 Documentation/CodingStyle), but with some notable variations and clarifications
8 described here (in random order):
10 * Align function arguments vertically when wrapping over line breaks:
12 void rather_long_function_name(struct another_rather_long_name *argument1,
13 struct yet_another_long_name *argument2);
15 * Avoid conditional compilation (#ifdefs) where possible (and it's almost
16 always possible). Variations should be resolved during link time, or
17 (if absolutely necessary) in the runtime (but think about performance).
19 * Do not explicitly initialize static variables you want zeroed. C standard
20 ensures this by default.
22 * Do not insert blank lines in #include list, except to separate include blocks
23 where the second depends on the first one, e.g.
25 #include <jailhouse/types.h>
27 #include <jailhouse/cell-config.h>
29 * Always include generic headers ("jailhouse/*.h") before architecture
32 * Header files must be self-standing, i.e. must not rely on other headers being
33 included prior to them. Use scripts/header_check to validate.
35 * Spaces in brackets are permitted for designated initializers in order to
36 improve readability via vertical alignment:
38 [ 0/8 ... 0x1f/8] = 0, /* floppy DMA controller */
39 [ 0x20/8 ... 0x3f/8] = -1,
40 [ 0x40/8 ... 0x47/8] = 0xf0, /* PIT */
42 For Python code, stick to PEP-8.