Skip to content

Commit 56b0588

Browse files
author
yoe
committed
r176: Add CodingStyle document
1 parent 37dcbd8 commit 56b0588

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

CodingStyle

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
NBD Coding style.
2+
=================
3+
4+
The following expresses my opinion of what C code should look like. I'm
5+
not as strict as the Kernel maintainers on this one (NBD isn't even
6+
remotely as large anyway), but code that does not follow these rules
7+
needs to be updated so that it does, which is useless time wasted for
8+
me. Therefore, it's appreciated if you would follow these rules.
9+
10+
Thanks.
11+
12+
* Use a tab width of 8 characters. You may use tab or 8 spaces as you
13+
please, it doesn't really matter to me.
14+
* opening curly brackets occur on the same line as whatever they're
15+
curly brackets for, _in all cases_. This includes function
16+
definitions, if structures, loops, and so on; every code block appears
17+
like so:
18+
19+
int foo(int bar) {
20+
...
21+
}
22+
23+
* Variable declarations are separated from the rest of a function block
24+
by a line of whitespace. It's okay to assign a value to a variable
25+
when you're declaring it if you can do that on one line of code, but
26+
it must still be in the block of declarations at the top with a
27+
whiteline below.
28+
* Variables are declared one on each line. So no
29+
30+
int foo, bar;
31+
32+
use
33+
34+
int foo;
35+
int bar;
36+
37+
instead.
38+
* Try to fit everything in 80 columns. This goes especially for comment
39+
lines, but may be relaxed for function calls with 79 arguments, or so,
40+
if that's not feasible.
41+
* If your function block is more than three or so screenfulls, there's a
42+
hint that you should break it up.
43+
44+
It is true that not all of the code currently follows these rules; but
45+
that should not stop you from following them for new code, or from
46+
cleaning up if you can (i.e., you have commit rights).

Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ nbd_tester_client_LDADD = @GLIB_LIBS@
1010
nbd_server_LDADD = @GLIB_LIBS@
1111
nbd_tester_client_LDADD = @GLIB_LIBS@
1212
man_MANS = nbd-server.1 nbd-client.8
13-
EXTRA_DIST = nbd-client.8.sgml nbd-server.1.sgml gznbd winnbd lfs.h nbd-client.8 nbd-server.1
13+
EXTRA_DIST = nbd-client.8.sgml nbd-server.1.sgml gznbd winnbd lfs.h nbd-client.8 nbd-server.1 CodingStyle
1414
MAINTAINERCLEANFILES = nbd-client.8 nbd-server.1
1515
nbd-server.1: nbd-server.1.sgml
1616
docbook2man nbd-server.1.sgml

0 commit comments

Comments
 (0)