@@ -48,7 +48,7 @@ are the highlights.
48
48
49
49
Add the follow to your $HOME/.emacs file:
50
50
51
- ```
51
+ ``` lisp
52
52
(add-hook 'c-mode-hook
53
53
(lambda ()
54
54
(c-set-style "linux")
@@ -63,15 +63,15 @@ Add the follow to your $HOME/.emacs file:
63
63
For the basic vi editor included with all variants of \* nix, add the
64
64
following to $HOME/.exrc:
65
65
66
- ```
66
+ ``` vim
67
67
set tabstop=8
68
68
set shiftwidth=8
69
69
```
70
70
71
71
For Vim, the following settings in $HOME/.vimrc will also deal with
72
72
displaying trailing whitespace:
73
73
74
- ```
74
+ ``` vim
75
75
if has("syntax") && (&t_Co > 2 || has("gui_running"))
76
76
syntax on
77
77
function! ActivateInvisibleCharIndicator()
@@ -113,7 +113,7 @@ of multiple following code blocks.
113
113
114
114
This is good:
115
115
116
- ```
116
+ ``` c
117
117
...
118
118
int i;
119
119
@@ -153,7 +153,7 @@ This is good:
153
153
154
154
This is bad:
155
155
156
- ```
156
+ ```c
157
157
...
158
158
int i;
159
159
/*
@@ -191,7 +191,7 @@ align the parameter list with the first parameter on the previous line.
191
191
Use tabs to get as close as possible and then fill in the final 7
192
192
characters or less with whitespace. For example,
193
193
194
- ```
194
+ ``` c
195
195
var1 = foo(arg1, arg2,
196
196
arg3);
197
197
```
@@ -214,13 +214,13 @@ Always follow an `if` keyword with a space but don't include additional
214
214
spaces following or preceding the parentheses in the conditional.
215
215
This is good:
216
216
217
- ```
217
+ ``` c
218
218
if (x == 1 )
219
219
```
220
220
221
221
This is bad:
222
222
223
- ```
223
+ ``` c
224
224
if ( x == 1 )
225
225
```
226
226
@@ -246,7 +246,7 @@ loop.
246
246
247
247
Good examples:
248
248
249
- ```
249
+ ``` c
250
250
if (x == 1 ) {
251
251
printf ("good\n");
252
252
}
@@ -269,7 +269,7 @@ Good examples:
269
269
270
270
Bad examples:
271
271
272
- ```
272
+ ```c
273
273
while (1)
274
274
{
275
275
print("I'm in a loop!\n"); }
@@ -296,7 +296,7 @@ idea.
296
296
297
297
Good Examples:
298
298
299
- ```
299
+ ``` c
300
300
int function foo (int y)
301
301
{
302
302
int * z = NULL;
@@ -338,7 +338,7 @@ lib/replace/, new code should adhere to the following conventions:
338
338
Most of the time a good name for a boolean variable is 'ok'. Here is an
339
339
example we often use:
340
340
341
- ```
341
+ ```c
342
342
bool ok;
343
343
344
344
ok = foo();
@@ -367,7 +367,7 @@ instructions sequence may change over time.
367
367
368
368
Good Example:
369
369
370
- ```
370
+ ``` c
371
371
char *pointer1 = NULL ;
372
372
char *pointer2 = NULL ;
373
373
@@ -380,7 +380,7 @@ Good Example:
380
380
381
381
Bad Example:
382
382
383
- ```
383
+ ``` c
384
384
char *pointer1;
385
385
char *pointer2;
386
386
@@ -441,7 +441,7 @@ it's also easier to use the "step" command within gdb.
441
441
442
442
Good Example:
443
443
444
- ```
444
+ ```c
445
445
char *name = NULL;
446
446
int ret;
447
447
@@ -457,7 +457,7 @@ Good Example:
457
457
458
458
Bad Example:
459
459
460
- ```
460
+ ``` c
461
461
ret = some_function_my_name(get_some_name());
462
462
...
463
463
```
@@ -468,7 +468,7 @@ debugger.
468
468
469
469
Good example:
470
470
471
- ```
471
+ ``` c
472
472
x = malloc(sizeof (short )*10 );
473
473
if (x == NULL ) {
474
474
fprintf (stderr, "Unable to alloc memory!\n");
@@ -477,7 +477,7 @@ Good example:
477
477
478
478
Bad example:
479
479
480
- ```
480
+ ```c
481
481
if ((x = malloc(sizeof(short)*10)) == NULL ) {
482
482
fprintf(stderr, "Unable to alloc memory!\n");
483
483
}
@@ -486,7 +486,7 @@ Bad example:
486
486
There are exceptions to this rule. One example is walking a data structure in
487
487
an iterator style:
488
488
489
- ```
489
+ ``` c
490
490
while ((opt = poptGetNextOpt(pc)) != -1 ) {
491
491
... do something with opt ...
492
492
}
@@ -499,7 +499,7 @@ rarely exists for this particular use case, and we gain some
499
499
efficiency because the DBG_ macros don't evaluate their arguments if
500
500
the debuglevel is not high enough.
501
501
502
- ```
502
+ ```c
503
503
if (!NT_STATUS_IS_OK(status)) {
504
504
struct dom_sid_buf sid_buf;
505
505
struct GUID_txt_buf guid_buf;
@@ -528,7 +528,7 @@ like `CHECK_STATUS`, `CHECK_VAL` and others.
528
528
529
529
Don't do this:
530
530
531
- ```
531
+ ``` c
532
532
frame = talloc_stackframe();
533
533
534
534
if (ret == LDB_SUCCESS) {
@@ -551,7 +551,7 @@ Don't do this:
551
551
552
552
It should be:
553
553
554
- ```
554
+ ```c
555
555
frame = talloc_stackframe();
556
556
557
557
if (ret != LDB_SUCCESS) {
@@ -580,7 +580,7 @@ It should be:
580
580
581
581
Use these following macros instead of DEBUG:
582
582
583
- ```
583
+ ``` c
584
584
DBG_ERR log level 0 error conditions
585
585
DBG_WARNING log level 1 warning conditions
586
586
DBG_NOTICE log level 3 normal, but significant, condition
@@ -590,7 +590,7 @@ DBG_DEBUG log level 10 debug-level message
590
590
591
591
Example usage:
592
592
593
- ```
593
+ ``` c
594
594
DBG_ERR ("Memory allocation failed\n");
595
595
DBG_DEBUG("Received %d bytes\n", count);
596
596
```
@@ -613,7 +613,7 @@ The PRIuxx specifiers are standard.
613
613
614
614
Example usage:
615
615
616
- ```
616
+ ```c
617
617
D_DEBUG("Resolving %"PRIu32" SID(s).\n", state->num_sids);
618
618
```
619
619
0 commit comments