Preparations for Clixon 6.0 release
Test: - netconf-monitoring using http-data disabled for restconf=fcgi - updated cicd.sh script with detail and change logfile
This commit is contained in:
parent
c94e9dad67
commit
67e6e5e5e1
7 changed files with 82 additions and 178 deletions
116
doc/DEVELOP.md
116
doc/DEVELOP.md
|
|
@ -1,7 +1,6 @@
|
|||
# README for Clixon developers
|
||||
|
||||
* [Code documentation](#documentation)
|
||||
* [C style](#c-style)
|
||||
* [How to work in git (how-to-work-in-git)](#how-to-work-in-git)
|
||||
* [How the meta-configure stuff works](#meta-configure)
|
||||
* [How to debug](#debug)
|
||||
|
|
@ -29,121 +28,6 @@ How to document the code
|
|||
*/
|
||||
```
|
||||
|
||||
## C style
|
||||
|
||||
Clixon uses 4-char indentation, a la emacs "cc-mode".
|
||||
|
||||
### Function declarations
|
||||
|
||||
Functions in C code are written as follows:
|
||||
```
|
||||
static int
|
||||
myfn(int par1,
|
||||
my_structure *par2)
|
||||
{
|
||||
int retval = -1;
|
||||
my_structure *ms;
|
||||
|
||||
ms = NULL;
|
||||
```
|
||||
Notes:
|
||||
1. The return type of the function and all qualifers on first line (`static int`)
|
||||
2. Function name and first parameter on second line, thereafter each parameter on own line
|
||||
3. Each parameter indented to match the "longest" (`my_structure`)
|
||||
4. Pointer declarations written: `type *p`, not: `type* p`.
|
||||
5. All local variables in a function declared at top of function, not inline with C-statements.
|
||||
6. Local variables can be initialized with scalars or constants, not eg malloc or functions with return values that need to be checked for errors
|
||||
7. There is a single empty line between local variable declarations and the first function statement.
|
||||
|
||||
Function signatures are declared in include files or in forward declaration using "one-line" syntax, unless very long:
|
||||
```
|
||||
static int myfn(int par1, my_structure *par2);
|
||||
```
|
||||
|
||||
### Errors
|
||||
|
||||
Errors are typically declared as follows:
|
||||
```
|
||||
if (myfn(0) < 0){
|
||||
clicon_err(OE_UNIX, EINVAL, "myfn");
|
||||
goto done;
|
||||
}
|
||||
```
|
||||
|
||||
All function returns that have return values must be checked
|
||||
|
||||
Default return values form a function are:
|
||||
- `0` OK
|
||||
- `-1` Fatal Error
|
||||
|
||||
In some cases, Clixon uses three-value returns as follows:
|
||||
- `1` OK
|
||||
- `0` Invalid
|
||||
- `-1` Fatal error
|
||||
|
||||
### Return values
|
||||
|
||||
Clixon uses goto:s only to get a single point of exit functions as follows:
|
||||
```
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
...
|
||||
retval = 0;
|
||||
done:
|
||||
return retval
|
||||
}
|
||||
```
|
||||
|
||||
Notes:
|
||||
1. Use only a single return statement in a function
|
||||
2. Do not use of goto:s in other ways
|
||||
|
||||
### Comments
|
||||
|
||||
Use `/* */`. Use `//` only for temporal comments.
|
||||
|
||||
Do not use "======", ">>>>>" or "<<<<<<" in comments since git merge conflict uses that.
|
||||
|
||||
### Format ints
|
||||
|
||||
Use:
|
||||
- %zu for size_t
|
||||
- PRIu64 for uint64
|
||||
- %p for pointers
|
||||
|
||||
### Include files
|
||||
|
||||
Avoid include statements in .h files, place them in .c files whenever possible.
|
||||
|
||||
The reason is to avoid deep include chains where file dependencies are
|
||||
difficult to analyze and understand. If include statements are only placed in .c
|
||||
files, there is only a single level of include file dependencies.
|
||||
|
||||
The drawback is that the same include file may need to be repeated in many .c files.
|
||||
|
||||
### Structs
|
||||
|
||||
Struct fields should have a prefix to distinguish them from other struct fields. The prefix should use an abbreviation of the struct name.
|
||||
|
||||
Example:
|
||||
```
|
||||
struct my_struct{
|
||||
int ms_foo;
|
||||
char *ms_string[42];
|
||||
}
|
||||
```
|
||||
where `ms_` is the prefix and is an abbreviation of `my_struct`.
|
||||
|
||||
### Global variables
|
||||
|
||||
Try to avoid global variables.
|
||||
|
||||
If you absolutely need one, try to contain it as static within a
|
||||
single C-file, ie do not declare it extern and use it elsewhere.
|
||||
|
||||
Also, always prepend a global variable with `_`, underscore.
|
||||
|
||||
## How to work in git
|
||||
|
||||
Clixon uses semantic versioning (https://semver.org).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue