forked from freebsd/freebsd-src
-
Notifications
You must be signed in to change notification settings - Fork 0
style(99)
Mateusz Piotrowski edited this page Mar 30, 2017
·
5 revisions
The assertions checking the arguments should be the same as the order of the arguments themselves.
int
fun(void *p, void *q, struct rstruct *r)
{
assert(p != NULL);
assert(q != NULL);
assert(r != NULL);
assert(r->rs_val != 0);
}
Use tabs.
void *function_a(const struct verylong_struct_name_here *vsnh, int a,
int b);
int function_b(void);
Use spaces.
static void *function_a(const struct verylong_struct_name_here *vsnh, int a,
int b);
int function_b(void);
- Kernel header files.
- Standard C Library header files.
- Other libraries header files.
- Local header files.
- All the local variables should be declared at the beginning of the function.
char[1024]
struct linau_record
uintmax_t
uint64_t
void *
size_t
uint32_t
au_id_t
au_asid_t
uid_t
gid_t
pid_t
long
int
char
-
pid_t
isint32_t
. -
uid_t
is__uint32_t
.
-
Break lines as far as you can.
-
Good
PJDLOG_VERIFY(au_close_buffer_tm(aud, aueid, buf, buflenp, tm) == 0 &&
fun(aud));
- Bad
PJDLOG_VERIFY(
au_close_buffer_tm(aurecordd, aueventid, buf, buflenp, tm) == 0);
- Break before the last two arguments if it improves readability.
PJDLOG_VERIFY(au_close_buffer_tm(aurecordd, aueventid, buf,
buflenp, tm) == 0);
Generally, never enter two newlines one after another like this:
#define ABC 1
static void localfun(int a, int b);
Use i++
only. Never use it like this:
while (str2[j] != '\0')
str1[i++] = str2[j++]
I use 8 spaces instead of tabs in this documentsince Markdown can mess up the indenetaion.