Robert Hak | 465ba3e | 2002-08-21 10:29:58 +0000 | [diff] [blame] | 1 | __________ __ ___. |
| 2 | Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 3 | Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 4 | Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 5 | Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 6 | \/ \/ \/ \/ \/ |
| 7 | Contribution Policies |
| 8 | |
| 9 | |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 10 | In order for the project to run as smoothly as possible, it's best if all |
Daniel Stenberg | e248eac | 2006-03-03 07:31:54 +0000 | [diff] [blame] | 11 | contributors adhere to a few simple source code conventions: |
| 12 | |
| 13 | Exceptions |
| 14 | ---------- |
| 15 | This project borrows and imports quite a lot of code from other free software |
| 16 | projects. We do not change style of such code unless we really have to, even |
| 17 | though they might be using style very different from others. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 18 | |
| 19 | Language |
| 20 | -------- |
| 21 | Write all code in C. Sometimes assembly is faster, but C is always more |
| 22 | readable and maintainable. |
| 23 | |
| 24 | Language features |
| 25 | ----------------- |
Björn Stenberg | ff8e9d9 | 2009-10-23 07:26:48 +0000 | [diff] [blame] | 26 | Write normal C code. Keep it simple. Don't redefine the language. No new types |
| 27 | (structs are structs, not typedefs). No C++isms or Javaisms. No code in .h |
| 28 | files or #defines. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 29 | |
Linus Nielsen Feltzing | d5b0246 | 2007-10-24 13:08:00 +0000 | [diff] [blame] | 30 | Identifiers |
Frank Gevaerts | b411f5e | 2009-02-12 20:49:53 +0000 | [diff] [blame] | 31 | ----------- |
Linus Nielsen Feltzing | d5b0246 | 2007-10-24 13:08:00 +0000 | [diff] [blame] | 32 | We do not want mixed case identifiers. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 33 | Variables and function names should be all lower case. |
Linus Nielsen Feltzing | d5b0246 | 2007-10-24 13:08:00 +0000 | [diff] [blame] | 34 | Struct and enum names should be all lower case. |
| 35 | Preprocessor symbols and enum constants should be all upper case. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 36 | |
Daniel Stenberg | 071898e | 2003-03-04 15:06:53 +0000 | [diff] [blame] | 37 | Comments |
| 38 | -------- |
| 39 | We only use plain old /* C standard comments */. |
Tomas Salfischberger | abf975d | 2006-02-27 15:01:34 +0000 | [diff] [blame] | 40 | If you want to comment out large blocks containing other comments, use #if 0. |
Daniel Stenberg | 071898e | 2003-03-04 15:06:53 +0000 | [diff] [blame] | 41 | |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 42 | Style |
| 43 | ----- |
| 44 | When changing code, follow the code style of the file you are editing. |
| 45 | |
| 46 | When writing new files, you may use the brace placement style of your choice. |
| 47 | |
Daniel Stenberg | 8e75734 | 2007-09-06 11:08:23 +0000 | [diff] [blame] | 48 | Braces for function declarations are put in a new line under the name, as in: |
| 49 | |
| 50 | int foo(char *name) |
| 51 | { |
Franklin Wei | 4f03c56 | 2017-03-21 21:35:21 -0400 | [diff] [blame^] | 52 | return FOO_NAME: |
Daniel Stenberg | 8e75734 | 2007-09-06 11:08:23 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 55 | Always indent your code with four spaces. Don't use TAB characters, as that |
Marcin Bukat | fee6f80 | 2012-01-24 13:05:25 +0100 | [diff] [blame] | 56 | will mess up code display, printing, and a zillion other places. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 57 | |
| 58 | Keep lines below 80 columns length. Use whitespace and newlines to make the |
| 59 | code easy to browse/read. |
| 60 | |
| 61 | Text format |
| 62 | ----------- |
| 63 | Use "unix style" line feeds: "LF" only. Do not use "CR+LF". |
| 64 | |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 65 | Use UTF-8 character set, but try to refrain from using any non-ascii |
Daniel Stenberg | 95cde0b | 2005-10-28 10:44:50 +0000 | [diff] [blame] | 66 | letters as they will only appear weird in some camps no matter what. |
| 67 | |
Marcin Bukat | fee6f80 | 2012-01-24 13:05:25 +0100 | [diff] [blame] | 68 | Contributing code |
Franklin Wei | 4f03c56 | 2017-03-21 21:35:21 -0400 | [diff] [blame^] | 69 | ----------------- |
Marcin Bukat | fee6f80 | 2012-01-24 13:05:25 +0100 | [diff] [blame] | 70 | We have a public code review system based on git, which is also how you can |
| 71 | check out the latest version of the Rockbox sources. |
| 72 | See http://www.rockbox.org/wiki/UsingGit for details on how to setup your |
| 73 | environment and how to upload a change you have made for review. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 74 | |
Marcin Bukat | fee6f80 | 2012-01-24 13:05:25 +0100 | [diff] [blame] | 75 | We'd prefer that you don't submit patches to the bug tracker any more, |
| 76 | as it's much harder to read and discuss them there. |
Björn Stenberg | 4a67c87 | 2006-03-09 14:58:15 +0000 | [diff] [blame] | 77 | |
| 78 | Credits |
| 79 | ------- |
| 80 | We believe in crediting all contributors by name. Before committing a patch to |
Marcin Bukat | fee6f80 | 2012-01-24 13:05:25 +0100 | [diff] [blame] | 81 | Git, we ask that you give us your full real name (no pseudonyms or nicknames) |
Björn Stenberg | 4a67c87 | 2006-03-09 14:58:15 +0000 | [diff] [blame] | 82 | for adding to the credits list. |