Disclaimer
From the bug tracking page:
Patch format
The following are not official… These are place-holder suggestions! -JP
It is important that patches be easily applied and maintained so that people can test your code, and it can be easily merged into CVS once tested. Here are some suggestions:
- Patches should be made against a current, clean CVS checkout.
- Patches should be made recursively against the full CVS module that it patches.
- For instance, a patch that affects asterisk/apps/app_queues, and several files in asterisk/sound should be made against the whole asterisk/ tree.
So, in the above example:
Assuming that a user has their Asterisk source in /usr/src, this would be applied by:
cd /usr/src/asterisk
patch -p1 <../asterisk-my_descriptive_patch_name-my.patch.version.patch
Coding Guidelines
NB For the latest info on this, check the file doc/CODING-GUIDELINES in the distribution
- All code, filenames, function names and comments must be in ENGLISH.
- Do not declare variables mid-function (e.g. like GNU lets you) since it is harder to read and not portable to GCC 2.95 and others.
- Don’t annotate your changes with comments like “/* JMG 4/20/04 */”;
- Comments should explain what the code does, not when something was changed or who changed it.
- Don’t make unnecessary whitespace changes throughout the code.
- Don’t use C++ type (//) comments.
- Try to match the existing formatting of the file you are working on.
- Functions and variables that are not intended to be global must be declared static.
- Function calls and arguments should be spaced in a consistent way across the codebase.
Function Calls
GOOD: foo(arg1, arg2);
GOOD: foo(arg1,arg2); /* Acceptable but not preferred */
BAD: foo (arg1, arg2);
BAD: foo( arg1, arg2 );
BAD: foo(arg1, arg2,arg3);
Examples of how code should be formatted
Functions
int foo(int a, char *s)
{
return 0;
}
If statements
if (foo) {
bar();
} else {
blah();
}
Case statements
switch (foo) {
case BAR:
blah();
break;
case OTHER:
other();
break;
}
No nested statements without braces
e.g. no:
for (x=0;x<5;x++)
if (foo)
if (bar)
baz();
instead do:
for (x=0;x<5;x++) {
if (foo) {
if (bar)
baz();
}
}
- Asterisk | FAQ | Introduction | AGI