Skip to content
Adam Dunkels edited this page Oct 28, 2012 · 1 revision

Code Contributions

Do you have a new cool feature that you'd like to contribute to Contiki? Or a fix for a bug? Great! The Contiki project loves code contributions, improvements, and bugfixes, but we require that they follow a set of guidelines and that they are contributed in a specific way.

Code Formatting

We require that all code contributed to the Contiki tree follows the same code formatting as the existing Contiki code. We are very strict on this.

Code must be formatted according to contiki/doc/code-style.c. To help with formatting, the GNU Indent tool can be used. The Contiki source tree contains a GNU Indent configuration file, tools/indent.pro along with a small script to make it easier to use, tools/contiki-indent. Note that while the output from this tool is pretty good, manual formatting might also be needed.

Naming

We require that all code contributed to the Contiki tree follow the Contiki source code naming standard:

  • File names are composed of lower-case characters and dashes. Like this: simple-udp.c
  • Variable and function names are composed of lower-case characters and underscores. Like this: simple_udp_send();
  • Variable and function names that are visible outside of their module must begin with the name of the module. Like this: simple_udp_send(), which is in the simple-udp module, declared in simple-udp.h, and implemented in simple-udp.c.
  • C macros are composed of upper-case characters and underscores. Like this: PROCESS_THREAD().
  • Configuration definitions begin with the module name and CONF_. Like this: PROCESS_CONF_NUMEVENTS.

How to Contribute Code

When your code is formatted according to the Contiki code style and follows the Contiki naming standard, it is time to send it to the Contiki maintainers to look at!

All code contributions to Contiki are submitted as Github pull requests. Pull requests will be reviewed and accepted according to the guidelines found in the Pull Request Policy