Chapter 6. Contributions Guide
(continued from previous page)
// NOT like this:
void function(int arg) {
}
• Within a function, place opening brace on the same line with conditional and loop statements:
if (condition) {
do_one();
} else if (other_condition) {
do_two();
}
Comments Use // for single line comments. For multi-line comments it is okay to use either // on each line or
a /* */ block.
Although not directly related to formatting, here are a few notes about using comments effectively.
• Don’t use single comments to disable some functionality:
void init_something()
{
setup_dma();
// load_resources(); // WHY is this thing commented, asks␣
,→the reader?
start_timer();
}
• If some code is no longer required, remove it completely. If you need it you can always look it up in git history
of this file. If you disable some call because of temporary reasons, with an intention to restore it in the future,
add explanation on the adjacent line:
void init_something()
{
setup_dma();
// TODO: we should load resources here, but loader is not fully integrated␣
,→yet.
// load_resources();
start_timer();
}
• Same goes for #if 0 ... #endif blocks. Remove code block completely if it is not used. Otherwise,
add comment explaining why the block is disabled. Don’t use #if 0 ... #endif or comments to store
code snippets which you may need in the future.
• Don’t add trivial comments about authorship and change date. You can always look up who modified any
given line using git. E.g. this comment adds clutter to the code without adding any useful information:
void init_something()
{
setup_dma();
// XXX add 2016-09-01
init_dma_list();
fill_dma_item(0);
// end XXX add
start_timer();
}
Line Endings Commits should only contain files with LF (Unix style) endings.
Windows users can configure git to check out CRLF (Windows style) endings locally and commit LF endings by set-
ting the core.autocrlf setting. Github has a document about setting this option <github-line-endings>. However
Espressif Systems 1570
Submit Document Feedback
Release v4.4