diff --git a/CHANGELOG.md b/CHANGELOG.md index 177eeba7..de10cf2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Clixon Changelog +* [5.4.0](#540) Expected: November * [5.3.0](#530) 27 September 2021 * [5.2.0](#520) 1 July 2021 * [5.1.0](#510) 15 April 2021 @@ -30,6 +31,11 @@ * [3.3.2](#332) Aug 27 2017 * [3.3.1](#331) June 7 2017 +## 5.4.0 +Expected: November, 2021 + + + ## 5.3.0 27 September, 2021 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..0a362085 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,98 @@ +## Documentation + +How to document the code:: + + /*! This is a small comment on one line + * + * This is a detailed description + * spanning several lines. + * + * Example usage: + * @code + * fn(a, &b); + * @endcode + * + * @param[in] src This is a description of the first parameter + * @param[in,out] dest This is a description of the second parameter + * @retval TRUE This is a description of the return value + * @retval FALSE This is a description of another return value + * @see See also this function + */ + +## 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. diff --git a/apps/cli/Makefile.in b/apps/cli/Makefile.in index a8280f56..1bc4b106 100644 --- a/apps/cli/Makefile.in +++ b/apps/cli/Makefile.in @@ -96,10 +96,6 @@ APPL = clixon_cli APPSRC = cli_main.c APPOBJ = $(APPSRC:.c=.o) -# HACK -#EXTRAS += $(top_srcdir)/example/main/example_cli.o -#EXTRAS += $(top_srcdir)/example/main/test_cli.o - # Accessible from plugin LIBSRC = cli_common.c LIBSRC += cli_show.c diff --git a/configure b/configure index 348943b9..21f31f78 100755 --- a/configure +++ b/configure @@ -2264,7 +2264,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. CLIXON_VERSION_MAJOR="5" -CLIXON_VERSION_MINOR="3" +CLIXON_VERSION_MINOR="4" CLIXON_VERSION_PATCH="0" CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\"" diff --git a/configure.ac b/configure.ac index 590ebcbb..85212eb3 100644 --- a/configure.ac +++ b/configure.ac @@ -49,7 +49,7 @@ AC_INIT(lib/clixon/clixon.h.in) AC_CONFIG_AUX_DIR(config-aux) CLIXON_VERSION_MAJOR="5" -CLIXON_VERSION_MINOR="3" +CLIXON_VERSION_MINOR="4" CLIXON_VERSION_PATCH="0" CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\"" diff --git a/fuzz/README.md b/fuzz/README.md index 02374fdf..9a858c98 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -15,6 +15,7 @@ On ubuntu this may be enough: ``` sudo apt install afl ``` +Or get source: `https://github.com/google/AFL` You may have to change cpu frequency: ``` diff --git a/fuzz/cli/README.md b/fuzz/cli/README.md index 151c8281..107402fc 100644 --- a/fuzz/cli/README.md +++ b/fuzz/cli/README.md @@ -10,12 +10,17 @@ Install AFL, see [..](..) Build and install a clixon system (in particular the backend, the CLI will be replaced) +Build and install CLIgen statically: +``` + CC=/usr/bin/afl-clang-fast LINKAGE=static INSTALLFLAGS="" ./configure +``` + ## Build Build clixon cli statically with the afl-clang compiler: ``` - CC=/usr/bin/afl-clang-fast LINKAGE=static ./configure # Dont care about restconf + CC=/usr/bin/afl-clang-fast LINKAGE=static INSTALLFLAGS="" ./configure # Dont care about restconf make clean cd apps/cli make clixon_cli @@ -44,7 +49,7 @@ Below is an example of how to do this for the main example. You can replace the cd apps/cli # Compile and install clixon_cli with pre-compiled plugins rm clixon_cli - EXTRAS="../../example/main/example_cli.o ../../example/main/test_cli.o" make clixon_cli + EXTRAS="../../example/main/example_cli.o" make clixon_cli sudo make install ```