The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2887
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Christian Brauner <[email protected]>
From 874563c376dea07f0520c1a7088565c218775300 Mon Sep 17 00:00:00 2001 From: Christian Brauner <[email protected]> Date: Fri, 1 Mar 2019 21:24:31 +0100 Subject: [PATCH] CODING_STYLE: update Signed-off-by: Christian Brauner <[email protected]> --- CODING_STYLE.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 54ac6d4ad0..4599c4ed85 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -662,3 +662,35 @@ int lxc_attach_run_command(void *payload) return ret; } ``` + +## 24) Never use `fgets()` + +LXC does not allow the use of `fgets()`. Use `getline()` or other methods +instead. + +## 25) Never allocate memory on the stack + +This specifically forbids any usage of `alloca()` in the codebase. + +## 26) Use cleanup macros supported by `gcc` and `clang` + +LXC has switched from manually cleaning up resources to using cleanup macros +supported by `gcc` and `clang`: +```c +__attribute__((__cleanup__(<my-cleanup-function-wrapper>))) +``` +We do not allow manually cleanups anymore if there are appropriate macros. +Currently the following macros are supported: +```c +/* close file descriptor */ +#define __do_close_prot_errno + +/* free allocated memory */ +#define __do_free __attribute__((__cleanup__(__auto_free__))) + +/* close FILEs */ +#define __do_fclose __attribute__((__cleanup__(__auto_fclose__))) + +/* close DIRs */ +#define __do_closedir __attribute__((__cleanup__(__auto_closedir__))) +```
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
