Indentation

Variable declaration

/* wrong */
int AsdDroro;
/* correct */
int asd_droro;

Whitespace

/* wrong */
int* asd;
while(true){
}
/* correct */
int *asd;

while (true) {
}

Braces

/* wrong */
void test(a,b) {
	if (true)
	{
	}
	else
	{
	}
}
/* correct */
void test(a, b)
{
	if (true) {
	} else {
	}
}

Switch statements

/* wrong */
switch (input) {
	case 1:
		do_something();
	case 2:
	do_more();
	break;
	default:
		do_nothing();
		break;
}
/* correct */
switch (input) {
case 1:
	do_something();
	/* fall through */
case 2:
	do_more();
	break;
default:
	do_nothing();
	break;
}

Artistic Style (astyle) automatic code formatting

Parts of this guide can automatically be applied by Artistic Style

astyle --style=linux --indent=tab=8 \
        --suffix=none --convert-tabs --pad=oper --unpad=paren \
        `find -type f -name '*.c'` `find -type f -name '*.h'`

More...