|
Packit |
e9ba0d |
Coding standards
|
|
Packit |
e9ba0d |
----------------
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
Contributed code should roughly follow [OpenBSD style][1]. For Emacs,
|
|
Packit |
e9ba0d |
I am using the following snippet to get the appropriate indentation:
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
(c-add-style
|
|
Packit |
e9ba0d |
"openbsd"
|
|
Packit |
e9ba0d |
'("bsd"
|
|
Packit |
e9ba0d |
(c-basic-offset . 8)
|
|
Packit |
e9ba0d |
(c-tab-width . 8)
|
|
Packit |
e9ba0d |
(fill-column . 80)
|
|
Packit |
e9ba0d |
(indent-tabs-mode . t)
|
|
Packit |
e9ba0d |
(c-offsets-alist . ((defun-block-intro . +)
|
|
Packit |
e9ba0d |
(statement-block-intro . +)
|
|
Packit |
e9ba0d |
(statement-case-intro . +)
|
|
Packit |
e9ba0d |
(statement-cont . *)
|
|
Packit |
e9ba0d |
(substatement-open . *)
|
|
Packit |
e9ba0d |
(substatement . +)
|
|
Packit |
e9ba0d |
(arglist-cont-nonempty . *)
|
|
Packit |
e9ba0d |
(inclass . +)
|
|
Packit |
e9ba0d |
(inextern-lang . 0)
|
|
Packit |
e9ba0d |
(knr-argdecl-intro . +)))))
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
Important stuff is to use tabulations. Each tabulation has a width of
|
|
Packit |
e9ba0d |
8 characters. This limits excessive nesting. Try to respect the 80
|
|
Packit |
e9ba0d |
columns limit if possible.
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
Opening braces are on the same line, except for functions where they
|
|
Packit |
e9ba0d |
are on their own lines. Closing braces are always on their own
|
|
Packit |
e9ba0d |
lives. Return type for functions are on their own lines too:
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
int
|
|
Packit |
e9ba0d |
main(int argc, char *argv[])
|
|
Packit |
e9ba0d |
{
|
|
Packit |
e9ba0d |
/* [...] */
|
|
Packit |
e9ba0d |
}
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
[1]: http://www.openbsd.org/cgi-bin/man.cgi?query=style&sektion=9
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
Submitting patches
|
|
Packit |
e9ba0d |
------------------
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
Patches against git tip are preferred. Please, clone the repository:
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
git clone https://github.com/vincentbernat/lldpd.git
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
Do any modification you need. Commit the modifications with a
|
|
Packit |
e9ba0d |
meaningful message:
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
1. Use a descriptive first-line.
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
2. Prepend the first line with the name of the subsystem modified
|
|
Packit |
e9ba0d |
(`lldpd`, `lib`, `client`) or something a bit more precise.
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
3. Don't be afraid to put a lot of details in the commit message.
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
Use `git format-patch` to get patches to submit:
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
git format-patch origin/master
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
Feel free to use `git send-email` which is like `git format-patch` but
|
|
Packit |
e9ba0d |
will propose to directly send patches by email. You can also open a
|
|
Packit |
e9ba0d |
[pull request][2] on Github.
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
[2]: https://help.github.com/articles/using-pull-requests
|