[Asterisk-cvs] asterisk/doc CODING-GUIDELINES,1.13,1.14
kpfleming at lists.digium.com
kpfleming at lists.digium.com
Tue Jun 7 17:26:36 CDT 2005
Update of /usr/cvsroot/asterisk/doc
In directory mongoose.digium.com:/tmp/cvs-serv17949/doc
Modified Files:
CODING-GUIDELINES
Log Message:
update guidelines to follow their own rules for whitespace (bug #4486)
Index: CODING-GUIDELINES
===================================================================
RCS file: /usr/cvsroot/asterisk/doc/CODING-GUIDELINES,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- CODING-GUIDELINES 2 Jun 2005 19:38:55 -0000 1.13
+++ CODING-GUIDELINES 7 Jun 2005 21:28:56 -0000 1.14
@@ -90,10 +90,10 @@
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 @@
statement, like so:
if !(foo) {
- result = 0;
- return;
+ result = 0;
+ return;
}
.... 50 lines of code ....
@@ -125,13 +125,14 @@
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 @@
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
More information about the svn-commits
mailing list