Janitor, use ARRAY_LEN() when possible.
authorEliel C. Sardanons <eliels@gmail.com>
Fri, 5 Dec 2008 10:31:25 +0000 (10:31 +0000)
committerEliel C. Sardanons <eliels@gmail.com>
Fri, 5 Dec 2008 10:31:25 +0000 (10:31 +0000)
(closes issue #13990)
Reported by: eliel
Patches:
      array_len.diff uploaded by eliel (license 64)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@161218 65c4cc65-6c06-0410-ace0-fbb531ad65f3

42 files changed:
apps/app_minivm.c
apps/app_mixmonitor.c
apps/app_playback.c
apps/app_queue.c
apps/app_rpt.c
apps/app_voicemail.c
channels/chan_agent.c
channels/chan_alsa.c
channels/chan_dahdi.c
channels/chan_iax2.c
channels/chan_oss.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_usbradio.c
main/asterisk.c
main/astmm.c
main/cli.c
main/config.c
main/db.c
main/features.c
main/file.c
main/frame.c
main/http.c
main/logger.c
main/manager.c
main/pbx.c
main/translate.c
main/udptl.c
pbx/pbx_ael.c
pbx/pbx_config.c
pbx/pbx_dundi.c
res/res_agi.c
res/res_config_ldap.c
res/res_config_pgsql.c
res/res_config_sqlite.c
res/res_convert.c
res/res_crypto.c
res/res_indications.c
res/res_jabber.c
res/res_musiconhold.c
res/res_odbc.c
res/res_realtime.c

index e40befd..b153700 100644 (file)
@@ -3281,7 +3281,7 @@ static int load_module(void)
        if ((res = load_config(0)))
                return(res);
 
-       ast_cli_register_multiple(cli_minivm, sizeof(cli_minivm)/sizeof(cli_minivm[0]));
+       ast_cli_register_multiple(cli_minivm, ARRAY_LEN(cli_minivm));
 
        /* compute the location of the voicemail spool directory */
        snprintf(MVM_SPOOL_DIR, sizeof(MVM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR);
@@ -3325,7 +3325,7 @@ static int unload_module(void)
        res |= ast_unregister_application(app_minivm_notify);
        res |= ast_unregister_application(app_minivm_delete);
        res |= ast_unregister_application(app_minivm_accmess);
-       ast_cli_unregister_multiple(cli_minivm, sizeof(cli_minivm)/sizeof(cli_minivm[0]));
+       ast_cli_unregister_multiple(cli_minivm, ARRAY_LEN(cli_minivm));
        ast_custom_function_unregister(&minivm_account_function);
        ast_custom_function_unregister(&minivm_counter_function);
 
index 3cbaf92..c5a5e10 100644 (file)
@@ -452,7 +452,7 @@ static int unload_module(void)
 {
        int res;
 
-       ast_cli_unregister_multiple(cli_mixmonitor, sizeof(cli_mixmonitor) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_mixmonitor, ARRAY_LEN(cli_mixmonitor));
        res = ast_unregister_application(stop_app);
        res |= ast_unregister_application(app);
        
@@ -463,7 +463,7 @@ static int load_module(void)
 {
        int res;
 
-       ast_cli_register_multiple(cli_mixmonitor, sizeof(cli_mixmonitor) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_mixmonitor, ARRAY_LEN(cli_mixmonitor));
        res = ast_register_application_xml(app, mixmonitor_exec);
        res |= ast_register_application_xml(stop_app, stop_mixmonitor_exec);
 
index 5981fc5..c32fccc 100644 (file)
@@ -519,7 +519,7 @@ static int unload_module(void)
 
        res = ast_unregister_application(app);
 
-       ast_cli_unregister_multiple(cli_playback, sizeof(cli_playback) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_playback, ARRAY_LEN(cli_playback));
 
        if (say_cfg)
                ast_config_destroy(say_cfg);
@@ -542,7 +542,7 @@ static int load_module(void)
                }
        }
 
-       ast_cli_register_multiple(cli_playback, sizeof(cli_playback) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_playback, ARRAY_LEN(cli_playback));
        return ast_register_application_xml(app, playback_exec);
 }
 
index 7f538d8..f5160bd 100644 (file)
@@ -6608,7 +6608,7 @@ static int unload_module(void)
        struct ao2_iterator q_iter;
        struct call_queue *q = NULL;
 
-       ast_cli_unregister_multiple(cli_queue, sizeof(cli_queue) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_queue, ARRAY_LEN(cli_queue));
        res = ast_manager_unregister("QueueStatus");
        res |= ast_manager_unregister("Queues");
        res |= ast_manager_unregister("QueueRule");
@@ -6669,7 +6669,7 @@ static int load_module(void)
        if (queue_persistent_members)
                reload_queue_members();
 
-       ast_cli_register_multiple(cli_queue, sizeof(cli_queue) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_queue, ARRAY_LEN(cli_queue));
        res = ast_register_application_xml(app, queue_exec);
        res |= ast_register_application_xml(app_aqm, aqm_exec);
        res |= ast_register_application_xml(app_rqm, rqm_exec);
index cc02c48..381a15a 100644 (file)
@@ -15108,8 +15108,7 @@ static int unload_module(void)
        res = ast_unregister_application(app);
 
 #ifdef NEW_ASTERISK
-       ast_cli_unregister_multiple(rpt_cli,sizeof(rpt_cli) / 
-               sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(rpt_cli, ARRAY_LEN(rpt_cli));
 #else
        /* Unregister cli extensions */
        ast_cli_unregister(&cli_debug);
@@ -15141,8 +15140,7 @@ static int load_module(void)
        ast_pthread_create(&rpt_master_thread,NULL,rpt_master,NULL);
 
 #ifdef NEW_ASTERISK
-       ast_cli_register_multiple(rpt_cli,sizeof(rpt_cli) / 
-               sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(rpt_cli, ARRAY_LEN(rpt_cli));
        res = 0;
 #else
        /* Register cli extensions */
index ba8a7ab..5f2f9b2 100644 (file)
@@ -10793,7 +10793,7 @@ static int unload_module(void)
        res |= ast_unregister_application(app4);
        res |= ast_custom_function_unregister(&mailbox_exists_acf);
        res |= ast_manager_unregister("VoicemailUsersList");
-       ast_cli_unregister_multiple(cli_voicemail, sizeof(cli_voicemail) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
        ast_uninstall_vm_functions();
 
        if (poll_thread != AST_PTHREADT_NULL)
@@ -10833,7 +10833,7 @@ static int load_module(void)
        if (res)
                return res;
 
-       ast_cli_register_multiple(cli_voicemail, sizeof(cli_voicemail) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
 
        ast_install_vm_functions(has_voicemail, inboxcount, inboxcount2, messagecount, sayname);
        ast_realtime_require_field("voicemail", "uniqueid", RQ_UINTEGER3, 11, "password", RQ_CHAR, 10, SENTINEL);
index 78bdb5a..ded6225 100644 (file)
@@ -2600,7 +2600,7 @@ static int load_module(void)
        ast_manager_register2("AgentLogoff", EVENT_FLAG_AGENT, action_agent_logoff, "Sets an agent as no longer logged in", mandescr_agent_logoff);
 
        /* CLI Commands */
-       ast_cli_register_multiple(cli_agents, sizeof(cli_agents) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_agents, ARRAY_LEN(cli_agents));
 
        /* Dialplan Functions */
        ast_custom_function_register(&agent_function);
@@ -2632,7 +2632,7 @@ static int unload_module(void)
        /* Unregister dialplan functions */
        ast_custom_function_unregister(&agent_function);        
        /* Unregister CLI commands */
-       ast_cli_unregister_multiple(cli_agents, sizeof(cli_agents) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_agents, ARRAY_LEN(cli_agents));
        /* Unregister dialplan applications */
        ast_unregister_application(app);
        ast_unregister_application(app3);
index 30c728a..991f2c2 100644 (file)
@@ -902,7 +902,7 @@ static int load_module(void)
                return AST_MODULE_LOAD_FAILURE;
        }
 
-       ast_cli_register_multiple(cli_alsa, sizeof(cli_alsa) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
 
        return AST_MODULE_LOAD_SUCCESS;
 }
@@ -910,7 +910,7 @@ static int load_module(void)
 static int unload_module(void)
 {
        ast_channel_unregister(&alsa_tech);
-       ast_cli_unregister_multiple(cli_alsa, sizeof(cli_alsa) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
 
        if (alsa.icard)
                snd_pcm_close(alsa.icard);
index cbe4592..9e615e9 100644 (file)
@@ -13616,10 +13616,10 @@ static int __unload_module(void)
                if (linksets[i].master != AST_PTHREADT_NULL)
                        pthread_cancel(linksets[i].master);
                }
-       ast_cli_unregister_multiple(dahdi_ss7_cli, sizeof(dahdi_ss7_cli) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(dahdi_ss7_cli, ARRAY_LEN(dahdi_ss7_cli));
 #endif
 
-       ast_cli_unregister_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(dahdi_cli, ARRAY_LEN(dahdi_cli));
        ast_manager_unregister( "DAHDIDialOffhook" );
        ast_manager_unregister( "DAHDIHangup" );
        ast_manager_unregister( "DAHDITransfer" );
index 1c1888a..74c2599 100644 (file)
@@ -12437,7 +12437,7 @@ static int __unload_module(void)
        ast_manager_unregister( "IAXnetstats" );
        ast_manager_unregister( "IAXregistry" );
        ast_unregister_application(papp);
-       ast_cli_unregister_multiple(cli_iax2, sizeof(cli_iax2) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_iax2, ARRAY_LEN(cli_iax2));
        ast_unregister_switch(&iax2_switch);
        ast_channel_unregister(&iax2_tech);
        delete_users();
@@ -12564,7 +12564,7 @@ static int load_module(void)
        }
        ast_netsock_init(outsock);
 
-       ast_cli_register_multiple(cli_iax2, sizeof(cli_iax2) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_iax2, ARRAY_LEN(cli_iax2));
 
        ast_register_application_xml(papp, iax2_prov_app);
        
index 72ab78c..b3f0f71 100644 (file)
@@ -1464,7 +1464,7 @@ static int load_module(void)
                return AST_MODULE_LOAD_FAILURE;
        }
 
-       ast_cli_register_multiple(cli_oss, sizeof(cli_oss) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_oss, ARRAY_LEN(cli_oss));
 
        return AST_MODULE_LOAD_SUCCESS;
 }
@@ -1475,7 +1475,7 @@ static int unload_module(void)
        struct chan_oss_pvt *o, *next;
 
        ast_channel_unregister(&oss_tech);
-       ast_cli_unregister_multiple(cli_oss, sizeof(cli_oss) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_oss, ARRAY_LEN(cli_oss));
 
        o = oss_default.next;
        while (o) {
index a07cac2..a5ec482 100644 (file)
@@ -23864,7 +23864,7 @@ static int load_module(void)
        }
 
        /* Register all CLI functions for SIP */
-       ast_cli_register_multiple(cli_sip, sizeof(cli_sip)/ sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_sip, ARRAY_LEN(cli_sip));
 
        /* Tell the RTP subdriver that we're here */
        ast_rtp_proto_register(&sip_rtp);
@@ -23938,7 +23938,7 @@ static int unload_module(void)
        ast_unregister_application(app_sipaddheader);
 
        /* Unregister CLI commands */
-       ast_cli_unregister_multiple(cli_sip, sizeof(cli_sip) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_sip, ARRAY_LEN(cli_sip));
 
        /* Disconnect from the RTP subsystem */
        ast_rtp_proto_unregister(&sip_rtp);
index f61f1b0..9d6ba0b 100644 (file)
@@ -6803,7 +6803,7 @@ static int load_module(void)
        }
 
        ast_rtp_proto_register(&skinny_rtp);
-       ast_cli_register_multiple(cli_skinny, sizeof(cli_skinny) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_skinny, ARRAY_LEN(cli_skinny));
        sched = sched_context_create();
        if (!sched) {
                ast_log(LOG_WARNING, "Unable to create schedule context\n");
@@ -6828,7 +6828,7 @@ static int unload_module(void)
 
        ast_rtp_proto_unregister(&skinny_rtp);
        ast_channel_unregister(&skinny_tech);
-       ast_cli_unregister_multiple(cli_skinny, sizeof(cli_skinny) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_skinny, ARRAY_LEN(cli_skinny));
        
        AST_LIST_LOCK(&sessions);
        /* Destroy all the interfaces and free their memory */
index 2e55448..2a829a6 100644 (file)
@@ -3984,7 +3984,7 @@ static int load_module(void)
                return AST_MODULE_LOAD_FAILURE;
        }
 
-       ast_cli_register_multiple(cli_usbradio, sizeof(cli_usbradio) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_usbradio, ARRAY_LEN(cli_usbradio));
 
        return AST_MODULE_LOAD_SUCCESS;
 }
@@ -3997,7 +3997,7 @@ static int unload_module(void)
        ast_log(LOG_WARNING, "unload_module() called\n");
 
        ast_channel_unregister(&usbradio_tech);
-       ast_cli_unregister_multiple(cli_usbradio, sizeof(cli_usbradio) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_usbradio, ARRAY_LEN(cli_usbradio));
 
        for (o = usbradio_default.next; o; o = o->next) {
 
index bef3cba..250b552 100644 (file)
@@ -3443,7 +3443,7 @@ int main(int argc, char *argv[])
 #endif 
 
        ast_lastreloadtime = ast_startuptime = ast_tvnow();
-       ast_cli_register_multiple(cli_asterisk, sizeof(cli_asterisk) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_asterisk, ARRAY_LEN(cli_asterisk));
 
        run_startup_commands();
 
index b1d34dd..3b3a671 100644 (file)
@@ -487,7 +487,7 @@ void __ast_mm_init(void)
                ast_log(LOG_ERROR, "struct ast_region has %d bytes of padding! This must be eliminated for low-fence checking to work properly!\n", (int) pad);
        }
 
-       ast_cli_register_multiple(cli_memory, sizeof(cli_memory) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_memory, ARRAY_LEN(cli_memory));
        
        snprintf(filename, sizeof(filename), "%s/mmlog", ast_config_AST_LOG_DIR);
        
index a01b343..e590046 100644 (file)
@@ -1602,7 +1602,7 @@ int ast_cli_perms_init(int reload)
 /*! \brief initialize the _full_cmd string in * each of the builtins. */
 void ast_builtins_init(void)
 {
-       ast_cli_register_multiple(cli_cli, sizeof(cli_cli) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_cli, ARRAY_LEN(cli_cli));
 }
 
 /*!
index d6510df..5fad1c5 100644 (file)
@@ -2538,6 +2538,6 @@ static struct ast_cli_entry cli_config[] = {
 
 int register_config_cli() 
 {
-       ast_cli_register_multiple(cli_config, sizeof(cli_config) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_config, ARRAY_LEN(cli_config));
        return 0;
 }
index 94bf4f0..5d0a05a 100644 (file)
--- a/main/db.c
+++ b/main/db.c
@@ -662,7 +662,7 @@ static int manager_dbdeltree(struct mansession *s, const struct message *m)
 int astdb_init(void)
 {
        dbinit();
-       ast_cli_register_multiple(cli_database, sizeof(cli_database) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_database, ARRAY_LEN(cli_database));
        ast_manager_register("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget, "Get DB Entry");
        ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry");
        ast_manager_register("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel, "Delete DB Entry");
index 1df9982..68841f4 100644 (file)
@@ -4194,7 +4194,7 @@ int ast_features_init(void)
 
        if ((res = load_config()))
                return res;
-       ast_cli_register_multiple(cli_features, sizeof(cli_features) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_features, ARRAY_LEN(cli_features));
        ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL);
        res = ast_register_application2(parkedcall, park_exec, NULL, NULL, NULL);
        if (!res)
index 61d45fe..b2ebfd7 100644 (file)
@@ -1347,6 +1347,6 @@ struct ast_cli_entry cli_file[] = {
 
 int ast_file_init(void)
 {
-       ast_cli_register_multiple(cli_file, sizeof(cli_file) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_file, ARRAY_LEN(cli_file));
        return 0;
 }
index 8c0982b..8e96b19 100644 (file)
@@ -942,7 +942,7 @@ static struct ast_cli_entry my_clis[] = {
 
 int init_framer(void)
 {
-       ast_cli_register_multiple(my_clis, sizeof(my_clis) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(my_clis, ARRAY_LEN(my_clis));
        return 0;       
 }
 
index 0e59146..5c3aa78 100644 (file)
@@ -1024,7 +1024,7 @@ int ast_http_init(void)
 {
        ast_http_uri_link(&statusuri);
        ast_http_uri_link(&staticuri);
-       ast_cli_register_multiple(cli_http, sizeof(cli_http) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_http, ARRAY_LEN(cli_http));
 
        return __ast_http_load(0);
 }
index 58813ed..b42a21b 100644 (file)
@@ -1013,7 +1013,7 @@ int init_logger(void)
        }
 
        /* register the logger cli commands */
-       ast_cli_register_multiple(cli_logger, sizeof(cli_logger) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_logger, ARRAY_LEN(cli_logger));
 
        ast_mkdir(ast_config_AST_LOG_DIR, 0777);
   
index acb2fa6..945e369 100644 (file)
@@ -4014,7 +4014,7 @@ static int __init_manager(int reload)
                ast_manager_register2("ModuleLoad", EVENT_FLAG_SYSTEM, manager_moduleload, "Module management", mandescr_moduleload);
                ast_manager_register2("ModuleCheck", EVENT_FLAG_SYSTEM, manager_modulecheck, "Check if module is loaded", mandescr_modulecheck);
 
-               ast_cli_register_multiple(cli_manager, sizeof(cli_manager) / sizeof(struct ast_cli_entry));
+               ast_cli_register_multiple(cli_manager, ARRAY_LEN(cli_manager));
                ast_extension_state_add(NULL, NULL, manager_state_cb, NULL);
                registered = 1;
                /* Append placeholder event so master_eventq never runs dry */
index 1e6ce17..533c4dc 100644 (file)
@@ -9052,11 +9052,11 @@ int load_pbx(void)
        }
 
        ast_verb(1, "Registering builtin applications:\n");
-       ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(pbx_cli, ARRAY_LEN(pbx_cli));
        __ast_custom_function_register(&exception_function, NULL);
 
        /* Register builtin applications */
-       for (x = 0; x < sizeof(builtins) / sizeof(struct pbx_builtin); x++) {
+       for (x = 0; x < ARRAY_LEN(builtins); x++) {
                ast_verb(1, "[%s]\n", builtins[x].name);
                if (ast_register_application2(builtins[x].name, builtins[x].execute, NULL, NULL, NULL)) {
                        ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
index 226a950..35c1968 100644 (file)
@@ -676,7 +676,7 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
                            ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt), t->cost);
 
        if (!added_cli) {
-               ast_cli_register_multiple(cli_translate, sizeof(cli_translate) / sizeof(struct ast_cli_entry));
+               ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate));
                added_cli++;
        }
 
index 166e0da..52f7c99 100644 (file)
@@ -1245,6 +1245,6 @@ int ast_udptl_reload(void)
 
 void ast_udptl_init(void)
 {
-       ast_cli_register_multiple(cli_udptl, sizeof(cli_udptl) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_udptl, ARRAY_LEN(cli_udptl));
        __ast_udptl_reload(0);
 }
index 65569f5..e60fe25 100644 (file)
@@ -214,13 +214,13 @@ static struct ast_cli_entry cli_ael[] = {
 static int unload_module(void)
 {
        ast_context_destroy(NULL, registrar);
-       ast_cli_unregister_multiple(cli_ael, sizeof(cli_ael) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_ael, ARRAY_LEN(cli_ael));
        return 0;
 }
 
 static int load_module(void)
 {
-       ast_cli_register_multiple(cli_ael, sizeof(cli_ael) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_ael, ARRAY_LEN(cli_ael));
        return (pbx_load_module());
 }
 
index 4422557..dac6389 100644 (file)
@@ -1398,7 +1398,7 @@ static int unload_module(void)
        if (overrideswitch_config) {
                ast_free(overrideswitch_config);
        }
-       ast_cli_unregister_multiple(cli_pbx_config, sizeof(cli_pbx_config) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_pbx_config, ARRAY_LEN(cli_pbx_config));
        ast_context_destroy(NULL, registrar);
        return 0;
 }
@@ -1738,7 +1738,7 @@ static int load_module(void)
  
        if (static_config && !write_protect_config)
                ast_cli_register(&cli_dialplan_save);
-       ast_cli_register_multiple(cli_pbx_config, sizeof(cli_pbx_config) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_pbx_config, ARRAY_LEN(cli_pbx_config));
 
        return AST_MODULE_LOAD_SUCCESS;
 }
index 0817772..294dd81 100644 (file)
@@ -4701,7 +4701,7 @@ static int unload_module(void)
                pthread_join(previous_precachethreadid, NULL);
        }
 
-       ast_cli_unregister_multiple(cli_dundi, sizeof(cli_dundi) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_dundi, ARRAY_LEN(cli_dundi));
        ast_unregister_switch(&dundi_switch);
        ast_custom_function_unregister(&dundi_function);
        ast_custom_function_unregister(&dundi_query_function);
@@ -4769,7 +4769,7 @@ static int load_module(void)
                return AST_MODULE_LOAD_FAILURE;
        }
        
-       ast_cli_register_multiple(cli_dundi, sizeof(cli_dundi) / sizeof(*cli_dundi));
+       ast_cli_register_multiple(cli_dundi, ARRAY_LEN(cli_dundi));
        if (ast_register_switch(&dundi_switch))
                ast_log(LOG_ERROR, "Unable to register DUNDi switch\n");
        ast_custom_function_register(&dundi_function);
index c563aef..89c23cb 100644 (file)
@@ -3257,7 +3257,7 @@ static struct ast_cli_entry cli_agi[] = {
 
 static int unload_module(void)
 {
-       ast_cli_unregister_multiple(cli_agi, sizeof(cli_agi) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_agi, ARRAY_LEN(cli_agi));
        /* we can safely ignore the result of ast_agi_unregister_multiple() here, since it cannot fail, as
           we know that these commands were registered by this module and are still registered
        */
@@ -3270,7 +3270,7 @@ static int unload_module(void)
 
 static int load_module(void)
 {
-       ast_cli_register_multiple(cli_agi, sizeof(cli_agi) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_agi, ARRAY_LEN(cli_agi));
        /* we can safely ignore the result of ast_agi_register_multiple() here, since it cannot fail, as
           no other commands have been registered yet
        */
index b5690b7..8fbfef8 100644 (file)
@@ -1515,7 +1515,7 @@ static int load_module(void)
 
        ast_config_engine_register(&ldap_engine);
        ast_verb(1, "LDAP RealTime driver loaded.\n");
-       ast_cli_register_multiple(ldap_cli, sizeof(ldap_cli) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(ldap_cli, ARRAY_LEN(ldap_cli));
 
        ast_mutex_unlock(&ldap_lock);
 
@@ -1533,7 +1533,7 @@ static int unload_module(void)
                ldap_unbind_ext_s(ldapConn, NULL, NULL);
                ldapConn = NULL;
        }
-       ast_cli_unregister_multiple(ldap_cli, sizeof(ldap_cli) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(ldap_cli, ARRAY_LEN(ldap_cli));
        ast_config_engine_deregister(&ldap_engine);
        ast_verb(1, "LDAP RealTime unloaded.\n");
 
index fe672bf..a22f03a 100644 (file)
@@ -1227,7 +1227,7 @@ static int load_module(void)
 
        ast_config_engine_register(&pgsql_engine);
        ast_verb(1, "PostgreSQL RealTime driver loaded.\n");
-       ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_realtime, ARRAY_LEN(cli_realtime));
 
        return 0;
 }
@@ -1242,7 +1242,7 @@ static int unload_module(void)
                PQfinish(pgsqlConn);
                pgsqlConn = NULL;
        }
-       ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_realtime, ARRAY_LEN(cli_realtime));
        ast_config_engine_deregister(&pgsql_engine);
        ast_verb(1, "PostgreSQL RealTime unloaded.\n");
 
index 5f72abc..756de0c 100644 (file)
@@ -1735,7 +1735,7 @@ static char *handle_cli_sqlite_show_tables(struct ast_cli_entry *e, int cmd, str
 static int unload_module(void)
 {
        if (cli_status_registered)
-               ast_cli_unregister_multiple(cli_status, sizeof(cli_status) / sizeof(struct ast_cli_entry));
+               ast_cli_unregister_multiple(cli_status, ARRAY_LEN(cli_status));
 
        if (cdr_registered)
                ast_cdr_unregister(RES_CONFIG_SQLITE_NAME);
@@ -1850,7 +1850,7 @@ static int load_module(void)
                cdr_registered = 1;
        }
 
-       error = ast_cli_register_multiple(cli_status, sizeof(cli_status) / sizeof(struct ast_cli_entry));
+       error = ast_cli_register_multiple(cli_status, ARRAY_LEN(cli_status));
 
        if (error) {
                unload_module();
index 0b4d664..ddcd01a 100644 (file)
@@ -147,13 +147,13 @@ static struct ast_cli_entry cli_convert[] = {
 
 static int unload_module(void)
 {
-       ast_cli_unregister_multiple(cli_convert, sizeof(cli_convert) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_convert, ARRAY_LEN(cli_convert));
        return 0;
 }
 
 static int load_module(void)
 {
-       ast_cli_register_multiple(cli_convert, sizeof(cli_convert) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_convert, ARRAY_LEN(cli_convert));
        return AST_MODULE_LOAD_SUCCESS;
 }
 
index 5d2d286..d8bf1da 100644 (file)
@@ -587,7 +587,7 @@ static int crypto_init(void)
 {
        SSL_library_init();
        ERR_load_crypto_strings();
-       ast_cli_register_multiple(cli_crypto, sizeof(cli_crypto) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_crypto, ARRAY_LEN(cli_crypto));
 
        /* Install ourselves into stubs */
        ast_key_get = __ast_key_get;
index 3419341..eb61a02 100644 (file)
@@ -420,7 +420,7 @@ static int unload_module(void)
        ast_unregister_indication_country(NULL);
 
        /* and the functions */
-       ast_cli_unregister_multiple(cli_indications, sizeof(cli_indications) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_indications, ARRAY_LEN(cli_indications));
        ast_unregister_application("PlayTones");
        ast_unregister_application("StopPlayTones");
        return 0;
@@ -432,7 +432,7 @@ static int load_module(void)
 {
        if (ind_load_module(0))
                return AST_MODULE_LOAD_DECLINE; 
-       ast_cli_register_multiple(cli_indications, sizeof(cli_indications) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_indications, ARRAY_LEN(cli_indications));
        ast_register_application_xml("PlayTones", handle_playtones);
        ast_register_application_xml("StopPlayTones", handle_stopplaytones);
 
index 8287aa6..010d669 100644 (file)
@@ -2973,7 +2973,7 @@ static int aji_reload(int reload)
 static int unload_module(void)
 {
 
-       ast_cli_unregister_multiple(aji_cli, sizeof(aji_cli) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(aji_cli, ARRAY_LEN(aji_cli));
        ast_unregister_application(app_ajisend);
        ast_unregister_application(app_ajistatus);
        ast_manager_unregister("JabberSend");
@@ -3003,7 +3003,7 @@ static int load_module(void)
                        "Sends a message to a Jabber Client", mandescr_jabber_send);
        ast_register_application(app_ajisend, aji_send_exec, ajisend_synopsis, ajisend_descrip);
        ast_register_application(app_ajistatus, aji_status_exec, ajistatus_synopsis, ajistatus_descrip);
-       ast_cli_register_multiple(aji_cli, sizeof(aji_cli) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(aji_cli, ARRAY_LEN(aji_cli));
        ast_custom_function_register(&jabberstatus_function);
 
        return 0;
index 4507411..344f0e2 100644 (file)
@@ -1619,7 +1619,7 @@ static int load_module(void)
 
        res = ast_register_application(play_moh, play_moh_exec, play_moh_syn, play_moh_desc);
        ast_register_atexit(ast_moh_destroy);
-       ast_cli_register_multiple(cli_moh, sizeof(cli_moh) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_moh, ARRAY_LEN(cli_moh));
        if (!res)
                res = ast_register_application(wait_moh, wait_moh_exec, wait_moh_syn, wait_moh_desc);
        if (!res)
@@ -1671,7 +1671,7 @@ static int unload_module(void)
        res |= ast_unregister_application(set_moh);
        res |= ast_unregister_application(start_moh);
        res |= ast_unregister_application(stop_moh);
-       ast_cli_unregister_multiple(cli_moh, sizeof(cli_moh) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_moh, ARRAY_LEN(cli_moh));
        ast_unregister_atexit(ast_moh_destroy);
        return res;
 }
index 67089a9..c017f0c 100644 (file)
@@ -924,7 +924,7 @@ static int load_module(void)
                return AST_MODULE_LOAD_DECLINE;
        if (load_odbc_config() == -1)
                return AST_MODULE_LOAD_DECLINE;
-       ast_cli_register_multiple(cli_odbc, sizeof(cli_odbc) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_odbc, ARRAY_LEN(cli_odbc));
        ast_log(LOG_NOTICE, "res_odbc loaded.\n");
        return 0;
 }
index 45ebcc6..ffc8c00 100644 (file)
@@ -251,13 +251,13 @@ static struct ast_cli_entry cli_realtime[] = {
 
 static int unload_module(void)
 {
-       ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
+       ast_cli_unregister_multiple(cli_realtime, ARRAY_LEN(cli_realtime));
        return 0;
 }
 
 static int load_module(void)
 {
-       ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_realtime, ARRAY_LEN(cli_realtime));
        return AST_MODULE_LOAD_SUCCESS;
 }