Skip to content

Commit 54027c0

Browse files
committed
CODING_CONVENTIONS: add doc and switch-case example
1 parent 9c3bbe3 commit 54027c0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

CODING_CONVENTIONS.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,20 @@ of recognised exceptions where we can (or even must) rely on extensions include:
194194
* Commas are always followed by a space.
195195
* For complex statements it is always good to use more parentheses - or split up
196196
the statement and simplify it.
197+
* Switch cases are an exception, the `case` statement is supposed to be on
198+
the same indentation level as the `switch`:
199+
```c
200+
switch(foo) {
201+
case BAR:
202+
printf("Hello");
203+
break;
204+
case PUB:
205+
printf("World");
206+
break;
207+
default:
208+
break;
209+
}
210+
```
197211

198212
## Indentation of Preprocessor Directives
199213

@@ -426,6 +440,19 @@ An exemplary doxygen documentation in a header file can look like this.
426440
* @return 1 if setting the state was successful, 0 otherwise.
427441
*/
428442
int set_foobar(int state, int *old_state);
443+
444+
/**
445+
* @brief Document multiple return values.
446+
*
447+
* You can use the `@return` command to specify the general kind of return
448+
* value and the `@retval` commands to specify distinct values that will be
449+
* returned by your function.
450+
*
451+
* @return Length of FOO on success or an error code on failure.
452+
* @retval -EIO on Input Output Errors
453+
* @retval -ENOMEM on small microcontrollers with little RAM
454+
*/
455+
int get_foolength(void);
429456
```
430457
431458
### SPDX

0 commit comments

Comments
 (0)