summaryrefslogtreecommitdiff
path: root/STYLE
blob: f1ae5c1e8559ddc9abcb9d508fc8b4b640227fb4 (plain)
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
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;
}