From 8b5e391afbc5befa47cf62a925defd5a9b5b31e8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 17 Jan 2011 04:23:09 -0500 Subject: start a STYLE file Signed-off-by: Mike Frysinger --- STYLE | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 STYLE diff --git a/STYLE b/STYLE new file mode 100644 index 00000000..f1ae5c1e --- /dev/null +++ b/STYLE @@ -0,0 +1,34 @@ +This is the openrc style manual. It governs the coding style of all code +in this repository. Follow it. Contact openrc@gentoo.org for any questions +or fixes you might notice. + +########## +# C CODE # +########## + +The BSD Kernel Normal Form (KNF) style is used: + http://en.wikipedia.org/wiki/Indent_style#BSD_KNF_style +Basically, it's like K&R/LKML, but wrapped lines that are indented use 4 spaces. + +Highlights: + - no trailing whitespace + - indented code use tabs (not line wrapped) + - cuddle the braces (except for functions) + - space after native statements and before paren (for/if/while/...) + - no space between function and paren + - pointer asterisk cuddles the variable, not the type + +void foo(int c) +{ + int ret = 0; + + if (c > 1000) + return; + + while (c--) { + bar(c); + ret++; + } + + return ret; +} -- cgit v1.2.3