aboutsummaryrefslogtreecommitdiffstats
path: root/doc/CODING-GUIDELINES
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-07 21:28:56 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-07 21:28:56 +0000
commitea0c7ad984385be58674f40f355863774eb8b64d (patch)
tree26df5497d54acfe5f1cf4975586d374ee6ce30aa /doc/CODING-GUIDELINES
parentc1991c02764ca0a06a1249b9b3ba26031fbd0ee7 (diff)
update guidelines to follow their own rules for whitespace (bug #4486)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5880 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'doc/CODING-GUIDELINES')
-rwxr-xr-xdoc/CODING-GUIDELINES19
1 files changed, 10 insertions, 9 deletions
diff --git a/doc/CODING-GUIDELINES b/doc/CODING-GUIDELINES
index cc352f79f..cf97f68e6 100755
--- a/doc/CODING-GUIDELINES
+++ b/doc/CODING-GUIDELINES
@@ -90,10 +90,10 @@ for (x=0;x<5;x++) {
Don't build code like this:
if (foo) {
- .... 50 lines of code ...
+ /* .... 50 lines of code ... */
} else {
- result = 0;
- return;
+ result = 0;
+ return;
}
Instead, try to minimize the number of lines of code that need to be
@@ -101,8 +101,8 @@ indented, by only indenting the shortest case of the 'if'
statement, like so:
if !(foo) {
- result = 0;
- return;
+ result = 0;
+ return;
}
.... 50 lines of code ....
@@ -125,13 +125,14 @@ options that they are in fact intended to be global.
When making applications, always ast_strdupa(data) to a local pointer if
you intend to parse it.
- if(data)
- mydata = ast_strdupa(data);
+
+ if (data)
+ mydata = ast_strdupa(data);
Always derefrence or localize pointers to things that are not yours like
channel members in a channel that is not associated with the current
thread and for which you do not have a lock.
- channame = ast_strdupa(otherchan->name);
+ channame = ast_strdupa(otherchan->name);
If you do the same or a similar operation more than 1 time, make it a
function or macro.
@@ -200,7 +201,7 @@ struct foo *tmp;
tmp = malloc(sizeof(*tmp));
if (tmp)
- memset(tmp, 0, sizeof(*tmp));
+ memset(tmp, 0, sizeof(*tmp));
This eliminates duplication of the 'struct foo' identifier, which makes the
code easier to read and also ensures that if it is copy-and-pasted it won't