[dm-crypt] Coding/style guidelines for cryptsetup?
"Schneider, Robert" <[email protected]> Thu, 6 May 2021 11:19:45 +0000
| Newsgroups | de.saout.dm-crypt |
|---|---|
| Message-ID | <AM0PR02MB558518FD785237C3B2D0A7618F589@AM0PR02MB5585.eurprd02.prod.outlook.com> |
Hi,
What are the coding and style guidelines when you want to propose a patch to cryptsetup?
I don't quite get a clear picture from the source code for some things, and I couldn't find documentation on it inside the repo.
I can write a clang-format ruleset if I know the rules...
Here are some things I've noticed while reading the source code, and some remaining questions:
- mostly restricted to C90, e.g. variable declarations at top of functions; but there some use of C99 features like designators in array initializations
-> do we have to declare variables at the top of functions?
-> are // style comments allowed?
- would adding -pedantic in GCC be acceptable? (not sure how that would work in autotools)
- tabs are used for indentation
- unclear if spaces for alignment are OK
-> tab == 8 spaces?
- how to indent when wrapping lines, e.g. for function parameters? 2 tabs? Align at ( with spaces?
-> sometimes, function declarations put every parameter on its own line
- top-level declarations like functions and structs have { on new line, if/loops/etc inside functions have { on same line, else on same line as }, if/else without braces is allowed
- one space between if/while/for/.. and the (
- documentation of API via doxygen (@ style, not \ style)
- internal documentation via plain comments, no text on first line and all lines starting with aligned *
- max line length?
- the * for pointers binds to the variable name (void *p instead of void* p)
- multiple declarations in the same statement are allowed
- functions with external linkage have a prefix like LUKS2_
- types are not typedef'ed -> struct crypt_device instead of crypt_device_t
- there are file comments with copyright notices
-> how to create a new file?
Thanks,
Robert
_______________________________________________
dm-crypt mailing list -- [email protected]
To unsubscribe send an email to [email protected]