Replies: 2 comments 3 replies
-
These are two already merged files using the proposed https://raw.githubusercontent.com/kubearmor/KubeArmor/event-auditor/KubeArmor/BPF/common.bpf.h Of course we can discuss the rules as nothing is defined yet. .clang-format
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I think the style should also account for very wordy |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When it comes to a Go project, this theme seems irrelevant, since the language tooling almost forces its idioms and formatting. However, KubeArmor has, at its heart, eBPF code programmed in C.
On the other hand, a code in C, to be read and accepted by the compiler, doesn't need to follow any idioms, formatting, much less style. It just needs to be syntactically correct [1].
Such freedom can be the birthplace of chaos.
Since KubeArmor's C code base is growing rapidly, I start this discussion by bringing some references, with the purpose of defining and adopting a coding style for the C language that can be practical, that can avoid errors and that it can maintain hygienic our work flow.
As a base reference, I propose a mix of the style used in the Linux Kernel [2] and the style used by the FreeBSD Kernel [3].
Because of the aforementioned freedom, both styles set a lot of rules in order to keep the house in order. So, there are many instructions to be memorized and followed.
To avoid the hassle of constantly worrying about formatting, which can get us off the rails, I suggest using the
clang-format
tool [4] that can import a list of predefined rules, automatically formatting the code for us.[1] - https://www.ioccc.org/2020/carlini/prog.c
[2] - https://www.kernel.org/doc/html/latest/process/coding-style.html
[3] - https://www.freebsd.org/cgi/man.cgi?query=style&sektion=9
[4] - https://clang.llvm.org/docs/ClangFormat.html
Further reading:
Kroah-Hartman, Greg, Documentation/CodingStyle and Beyond, https://landley.net/kdocs/ols/2002/ols2002-pages-250-259.pdf
Beta Was this translation helpful? Give feedback.
All reactions