A few words on coding style
While we're very liberal when it comes to coding style, there are a few rules you ought to stick to. They're mostly obvious, but I don't write this down because I'm bored either..
Please note that these are more guidelines than a fixed set of rules. If you have a good reason for breaking one of these points, go ahead. But you may be bothered to explain why you did so.
Function and variable names
- Names should follow the normal C naming scheme, e. g.:
"
submit_value", "temperature_current". Mixed-case names, as popular with Java developers, will not be accepted. So "submitValue" is evil. Not quite as bad but still bad is "submitvalue". Naturally, using non-ASCII characters is off-limits. - Names should be as long as necessary - not longer, but not shorter either. If in doubt, use the longer name.
- All-capital names are reserved for, and must be used by, defines, macros and
enum-members. - If several variables or functions with similar meaning exist, such as minimum, average and
maximum temperature, the common part should be in front, e. g.
"
temp_max", "temp_min" and so on.
Plugins
- All functions within a plugin must be declared
static. The obvious exception is the "module_register" function. - The behavior of a plugin should not depend on a compile time settings.
Standard functions
- Only reentrant- and threadsafe functions may be used.
Fixed size buffers
- When using a buffer with a fixed length,
strncpy,snprintfand friends must be used. We don't care how obvious it is that whatever you do will fit into the buffer; if you don't use the n-variants we won't accept it. - Only explicitly give the size of the buffer when declaring it. Use the
sizeofoperator or theSTATIC_ARRAY_SIZEmacro after that. Please don't hide the actual size of the buffer in some define.
C99 features
- All variables must be declared at the beginning of a block.
- Please do not use C++-style comments.
- Please do not use FAMs.
- Please use the integer types found in
<stdint.h>if you need a fixed size integer, e. g. for parsing binary network packets and the like.
