Update 'Coding Style'
parent
b58ac21058
commit
4a7c92aa40
1 changed files with 22 additions and 0 deletions
|
@ -282,6 +282,28 @@ Do eliminate trailing whitespace on any line, preferably as a separate patch or
|
|||
|
||||
### Conditions
|
||||
|
||||
Boolean values should not be checked for equality to make the code more readable:
|
||||
```c
|
||||
if (error)
|
||||
return 1;
|
||||
|
||||
if (!error)
|
||||
return 0;
|
||||
```
|
||||
|
||||
The check for 0 should refer to the specific way the 0 is used: `0` for a numeric value, `'\0'` for the end of a string, or `NULL` for a pointer. In this way, the variable type can be derived implicitly by reading the comparison. For the FALSE boolean we refer to the rule about boolean equations.
|
||||
```c
|
||||
if (buffer == NULL)
|
||||
return NULL;
|
||||
|
||||
if (get_bit (stream) == 0)
|
||||
node->value++;
|
||||
|
||||
if (bwc->info.file_ext [0] != '\0')
|
||||
return 0;
|
||||
```
|
||||
|
||||
|
||||
### Functions
|
||||
The following general rules should be followed when defining a function in BigWhoop:
|
||||
* Function name must be lowercase, optionally separated with underscore _ character
|
||||
|
|
Loading…
Reference in a new issue