Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 1 | $Id$ |
| 2 | |
Robert Hak | 465ba3e | 2002-08-21 10:29:58 +0000 | [diff] [blame] | 3 | __________ __ ___. |
| 4 | Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 5 | Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 6 | Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 7 | Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 8 | \/ \/ \/ \/ \/ |
| 9 | Contribution Policies |
| 10 | |
| 11 | |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 12 | 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] | 13 | contributors adhere to a few simple source code conventions: |
| 14 | |
| 15 | Exceptions |
| 16 | ---------- |
| 17 | This project borrows and imports quite a lot of code from other free software |
| 18 | projects. We do not change style of such code unless we really have to, even |
| 19 | though they might be using style very different from others. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 20 | |
| 21 | Language |
| 22 | -------- |
| 23 | Write all code in C. Sometimes assembly is faster, but C is always more |
| 24 | readable and maintainable. |
| 25 | |
| 26 | Language features |
| 27 | ----------------- |
Björn Stenberg | ff8e9d9 | 2009-10-23 07:26:48 +0000 | [diff] [blame^] | 28 | Write normal C code. Keep it simple. Don't redefine the language. No new types |
| 29 | (structs are structs, not typedefs). No C++isms or Javaisms. No code in .h |
| 30 | files or #defines. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 31 | |
Linus Nielsen Feltzing | d5b0246 | 2007-10-24 13:08:00 +0000 | [diff] [blame] | 32 | Identifiers |
Frank Gevaerts | b411f5e | 2009-02-12 20:49:53 +0000 | [diff] [blame] | 33 | ----------- |
Linus Nielsen Feltzing | d5b0246 | 2007-10-24 13:08:00 +0000 | [diff] [blame] | 34 | We do not want mixed case identifiers. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 35 | Variables and function names should be all lower case. |
Linus Nielsen Feltzing | d5b0246 | 2007-10-24 13:08:00 +0000 | [diff] [blame] | 36 | Struct and enum names should be all lower case. |
| 37 | Preprocessor symbols and enum constants should be all upper case. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 38 | |
Daniel Stenberg | 071898e | 2003-03-04 15:06:53 +0000 | [diff] [blame] | 39 | Comments |
| 40 | -------- |
| 41 | We only use plain old /* C standard comments */. |
Tomas Salfischberger | abf975d | 2006-02-27 15:01:34 +0000 | [diff] [blame] | 42 | 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] | 43 | |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 44 | Style |
| 45 | ----- |
| 46 | When changing code, follow the code style of the file you are editing. |
| 47 | |
| 48 | When writing new files, you may use the brace placement style of your choice. |
| 49 | |
Daniel Stenberg | 8e75734 | 2007-09-06 11:08:23 +0000 | [diff] [blame] | 50 | Braces for function declarations are put in a new line under the name, as in: |
| 51 | |
| 52 | int foo(char *name) |
| 53 | { |
| 54 | return FOO_NAME: |
| 55 | } |
| 56 | |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 57 | Always indent your code with four spaces. Don't use TAB characters, as that |
| 58 | will mess up code display in CVS, printing, and a zillion other places. |
| 59 | |
| 60 | Keep lines below 80 columns length. Use whitespace and newlines to make the |
| 61 | code easy to browse/read. |
| 62 | |
| 63 | Text format |
| 64 | ----------- |
| 65 | Use "unix style" line feeds: "LF" only. Do not use "CR+LF". |
| 66 | |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 67 | 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] | 68 | letters as they will only appear weird in some camps no matter what. |
| 69 | |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 70 | Patches |
| 71 | ------- |
Peter D'Hoye | 9ae05c3 | 2007-01-10 21:25:59 +0000 | [diff] [blame] | 72 | Create a patch using 'svn diff > mychanges.patch |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 73 | Trim your patches so they only contain relevant changes. |
Robert Hak | 40bafc5 | 2002-08-21 10:19:23 +0000 | [diff] [blame] | 74 | |
Daniel Stenberg | 55da279 | 2006-02-26 23:28:15 +0000 | [diff] [blame] | 75 | Submit your patch to the project via our patch tracker: |
Dave Chapman | 2c3fd0c | 2006-08-11 00:21:42 +0000 | [diff] [blame] | 76 | http://www.rockbox.org/tracker/index.php?type=4 |
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 |
Nicolas Pennequin | 77bdacc | 2007-05-24 18:56:09 +0000 | [diff] [blame] | 81 | SVN, 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. |