summaryrefslogtreecommitdiff
path: root/CODING_STYLE
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2015-07-08 08:38:11 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2015-07-08 09:19:05 +1000
commitbc17221570e7ef3a127370d29d851fecb71d7bce (patch)
treeb3c1128dd1eeb2c8c4b2f0f5540b7bf4d30c8d39 /CODING_STYLE
parent1309718c003ad9cd440fc03315e450ccb83ff51d (diff)
Add more rules to CODING_STYLE
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'CODING_STYLE')
-rw-r--r--CODING_STYLE26
1 files changed, 26 insertions, 0 deletions
diff --git a/CODING_STYLE b/CODING_STYLE
index 3648a4e..c5336cc 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -62,6 +62,26 @@
useit(c);
}
+- do not mix function invocations and variable definitions.
+
+ wrong:
+
+ {
+ int a = foo();
+ int b = 7;
+ }
+
+ right:
+ {
+ int a;
+ int b = 7;
+
+ a = foo();
+ }
+
+ There are exceptions here, e.g. tp_libinput_context(),
+ litest_current_device()
+
- if/else: { on the same line, no curly braces if both blocks are a single
statement. If either if or else block are multiple statements, both must
have curly braces.
@@ -88,3 +108,9 @@
#include <libevdev/libevdev.h>
#include "libinput-private.h"
+
+- goto jumps only to the end of the function, and only for good reasons
+ (usually cleanup). goto never jumps backwards
+
+- Use stdbool.h's bool for booleans within the library (instead of 'int').
+ Exception: the public API uses int, not bool.