[asterisk-commits] file: trunk r162542 - in /trunk: apps/ channels/ doc/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 9 19:09:07 CST 2008


Author: file
Date: Tue Dec  9 19:09:06 2008
New Revision: 162542

URL: http://svn.digium.com/view/asterisk?view=rev&rev=162542
Log:
Finish conversion to using ARRAY_LEN and remove it as a janitor project.
(closes issue #14032)
Reported by: bkruse
Patches:
      14032.patch uploaded by bkruse (license 132)

Modified:
    trunk/apps/app_voicemail.c
    trunk/channels/iax2-parser.c
    trunk/doc/janitor-projects.txt

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=162542&r1=162541&r2=162542
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Tue Dec  9 19:09:06 2008
@@ -1422,7 +1422,7 @@
 		"Deleted",
 		"Urgent"
 	};
-	return (id >= 0 && id < (sizeof(msgs)/sizeof(msgs[0]))) ? msgs[id] : "Unknown";
+	return (id >= 0 && id < ARRAY_LEN(msgs)) ? msgs[id] : "Unknown";
 }
 
 static void free_user(struct ast_vm_user *vmu)

Modified: trunk/channels/iax2-parser.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/iax2-parser.c?view=diff&rev=162542&r1=162541&r2=162542
==============================================================================
--- trunk/channels/iax2-parser.c (original)
+++ trunk/channels/iax2-parser.c Tue Dec  9 19:09:06 2008
@@ -533,14 +533,14 @@
 		sprintf(subclass2, "%c", fh->csub);
 		subclass = subclass2;
 	} else if (fh->type == AST_FRAME_IAX) {
-		if (fh->csub >= (int)sizeof(iaxs)/(int)sizeof(iaxs[0])) {
+		if (fh->csub >= ARRAY_LEN(iaxs)) {
 			snprintf(subclass2, sizeof(subclass2), "(%d?)", fh->csub);
 			subclass = subclass2;
 		} else {
 			subclass = iaxs[(int)fh->csub];
 		}
 	} else if (fh->type == AST_FRAME_CONTROL) {
-		if (fh->csub >= (int)sizeof(cmds)/(int)sizeof(cmds[0])) {
+		if (fh->csub >= ARRAY_LEN(cmds)) {
 			snprintf(subclass2, sizeof(subclass2), "(%d?)", fh->csub);
 			subclass = subclass2;
 		} else {

Modified: trunk/doc/janitor-projects.txt
URL: http://svn.digium.com/view/asterisk/trunk/doc/janitor-projects.txt?view=diff&rev=162542&r1=162541&r2=162542
==============================================================================
--- trunk/doc/janitor-projects.txt (original)
+++ trunk/doc/janitor-projects.txt Tue Dec  9 19:09:06 2008
@@ -32,11 +32,3 @@
  -- Audit all channel/res/app/etc. modules to ensure that they do not register any entrypoints with the Asterisk core until after they are ready to service requests; all config file reading/processing, structure allocation, etc. must be completed before Asterisk is made aware of any services the module offers.
 
  -- Ensure that Realtime-enabled modules do not depend on the order of columns returned by the database lookup (example: outboundproxy and host settings in chan_sip).
-
- -- There are several places in the code where the length of arrays is calculated in-line with sizeof() and division. A common place to find this is in for loops, like this:
-
- 	for (i = 0; i < sizeof(array)/sizeof(array[0]); i++)
-
-	There is a macro in utils.h called ARRAY_LEN which should be used instead for readability's sake.
-
-	for (i = 0; i < ARRAY_LEN(array); i++)




More information about the asterisk-commits mailing list