set showmode
set autoindent
set expandtab
-
+
filetype plugin on
let c_syntax_for_h = 1
autocmd FileType c,cc,cpp set cindent
autocmd FileType c,cc,cpp set fo=rotcq
autocmd FileType c,cc,cpp set noexpandtab ts=8
autocmd FileType python set ts=4 sw=4
-
+
filetype indent on
#### Vertical Whitespace
/*
* Private variables.
*/
-
+
static int a /* Description of 'a'. */
static int b /* Description of 'b'. */
static char * c /* Description of 'c'. */
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/
-
+
#pragma once
-
+
/*****
***** Module Info
*****/
-
+
/*
* (Module name here.)
*
* Standards:
* (Any standards relevant to the module are listed here.)
*/
-
+
/***
*** Imports
***/
-
+
/* #includes here. */
#include <isc/lang.h>
-
+
/***
*** Types
***/
-
+
/* (Type definitions here.) */
-
+
/***
*** Functions
***/
func1(int i) {
/* whatever */
}
-
+
int
func2(int first_argument, int next_argument,
int last_argument)
os_result_t result;
os_descriptor_t s;
-
+
result = os_socket_create(AF_INET, SOCK_STREAM, 0, &s);
if (result != OS_R_SUCCESS) {
/* Do something about the error. */
Not so good:
int s;
-
+
/*
* Obviously using interfaces like socket() (below) is allowed
* since otherwise you couldn't call operating system routines; the
/* Test if flag set. */
if ((flags & FOO) != 0) {
-
+
}
/* Test if flag clear. */
if ((flags & BAR) == 0) {
-
+
}
/* Test if both flags set. */
if ((flags & (FOO|BAR)) == (FOO|BAR)) {
-
+
}
Bad:
/* Test if flag set. */
if (flags & FOO) {
-
+
}
/* Test if flag clear. */
if (! (flags & BAR)) {
-
+
}
#### Testing for Zero or Non-zero
Good:
int i = 10;
-
+
/* ... */
-
+
if (i != 0) {
/* Do something. */
}
Bad:
int i = 10;
-
+
/* ... */
-
+
if (i) {
/* Do something. */
}
Good:
char *c = NULL;
-
+
/* ... */
-
+
if (c != NULL) {
/* Do something. */
}
Bad:
char *c = NULL;
-
+
/* ... */
-
+
if (c) {
/* Do something. */
}
Good:
char *text;
-
+
/* text is initialized here. */
-
+
isc_mem_free(mctx, text);
text = NULL;
int bar;
int baz;
};
-
+
struct example x = { .foo = -1 };
Bad:
int bar;
int baz;
};
-
+
struct example x;
-
+
x.foo = -1;
x.bar = 0;
x.baz = 0;
int bar;
int baz;
};
-
+
struct example *x = isc_mem_get(mctx, sizeof(*x));
-
+
*x = (struct example){ .foo = -1 };
Bad:
int bar;
int baz;
};
-
+
struct example *x = isc_mem_get(mctx, sizeof(*x));
-
+
x->foo = -1;
x->bar = 0;
x->baz = 0;
dns_zone_setfile(dns_zone_t *zone, const char *file) {
return (dns_zone_setfile2(zone, file, dns_masterformat_text);
}
-
+
isc_result_t
dns_zone_setfile2(dns_zone_t *zone, const char *file,
dns_masterformat_t format)