Fetching contributors…
Cannot retrieve contributors at this time
58 lines (35 sloc) 1.49 KB
Here is a description of the prevailing coding style in beanstalkd. Overall,
our style is pretty close to K&R style, but there are a few differences.
Really the only important rule is to follow the style of existing code. This
document is just to help you out by describing some aspects of that style
If in doubt, ask the list at
* Use no tabs, only spaces.
* Limit lines to 80 columns.
* Indent by four spaces.
* Do not include trailing spaces.
* Surround binary operators (indluding boolean, arithmetic, and assignment)
with a space on each side.
* Put the name of a function definition on the line after the function's
return type.
* Put the opening curly brace of a function on a line by itself in the first
* Put a blank line after a block of declarations.
* Put a blank line after each function.
* Put the opening curly brace of an "if" or "for" statement on the same line
as the "if" or "for" keyword.
* If the body of an "if" or "for" statement fits on the same line, you can
leave off the braces. For example, write
if (x) return;
instead of
if (x) {
However, always include the braces when there is an "else" clause.
* Put the "else" keyword on the same line as the preceding closing curly
* When testing pointers, don't compare them to NULL; instead test the value
directly. For example, write
if (x && !y)
instead of
if (x != NULL && y == NULL)