[asterisk-commits] qwell: trunk r94806 - in /trunk: apps/ pbx/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 26 14:02:27 CST 2007


Author: qwell
Date: Wed Dec 26 14:02:27 2007
New Revision: 94806

URL: http://svn.digium.com/view/asterisk?view=rev&rev=94806
Log:
Use defined return values in load_module in more places.

(closes issue #11096)
Patches:
      pbx_config.c.patch uploaded by moy (license 222)
      pbx_dundi.c.patch uploaded by moy (license 222)
      pbx_gtkconsole.c.patch uploaded by moy (license 222)
      pbx_loopback.c.patch uploaded by moy (license 222)
      pbx_realtime.c.patch uploaded by moy (license 222)
      pbx_spool.c.patch uploaded by moy (license 222)
      app_adsiprog.c.patch uploaded by moy (license 222)
      app_alarmreceiver.c.patch uploaded by moy (license 222)
      app_amd.c.patch uploaded by moy (license 222)
      app_authenticate.c.patch uploaded by moy (license 222)
      app_cdr.c.patch uploaded by moy (license 222)
      app_zapateller.c.patch uploaded by moy (license 222)
      app_zapbarge.c.patch uploaded by moy (license 222)
      app_zapras.c.patch uploaded by moy (license 222)
      app_zapscan.c.patch uploaded by moy (license 222)

Modified:
    trunk/apps/app_adsiprog.c
    trunk/apps/app_alarmreceiver.c
    trunk/apps/app_amd.c
    trunk/apps/app_authenticate.c
    trunk/apps/app_cdr.c
    trunk/apps/app_zapateller.c
    trunk/apps/app_zapbarge.c
    trunk/apps/app_zapras.c
    trunk/apps/app_zapscan.c
    trunk/pbx/pbx_config.c
    trunk/pbx/pbx_dundi.c
    trunk/pbx/pbx_gtkconsole.c
    trunk/pbx/pbx_loopback.c
    trunk/pbx/pbx_realtime.c
    trunk/pbx/pbx_spool.c

Modified: trunk/apps/app_adsiprog.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_adsiprog.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_adsiprog.c (original)
+++ trunk/apps/app_adsiprog.c Wed Dec 26 14:02:27 2007
@@ -1573,7 +1573,9 @@
 
 static int load_module(void)
 {
-	return ast_register_application(app, adsi_exec, synopsis, descrip);
+	if (ast_register_application(app, adsi_exec, synopsis, descrip))
+		return AST_MODULE_LOAD_FAILURE;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Asterisk ADSI Programming Application");

Modified: trunk/apps/app_alarmreceiver.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_alarmreceiver.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_alarmreceiver.c (original)
+++ trunk/apps/app_alarmreceiver.c Wed Dec 26 14:02:27 2007
@@ -801,8 +801,11 @@
 
 static int load_module(void)
 {
-	if(load_config())
-		return ast_register_application(app, alarmreceiver_exec, synopsis, descrip);
+	if(load_config()) {
+		if (ast_register_application(app, alarmreceiver_exec, synopsis, descrip))
+			return AST_MODULE_LOAD_FAILURE;
+		return AST_MODULE_LOAD_SUCCESS;
+	}	
 	else
 		return AST_MODULE_LOAD_DECLINE;
 }

Modified: trunk/apps/app_amd.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_amd.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_amd.c (original)
+++ trunk/apps/app_amd.c Wed Dec 26 14:02:27 2007
@@ -308,7 +308,7 @@
 	return 0;
 }
 
-static void load_config(int reload)
+static int load_config(int reload)
 {
 	struct ast_config *cfg = NULL;
 	char *cat = NULL;
@@ -317,9 +317,9 @@
 
 	if (!(cfg = ast_config_load("amd.conf", config_flags))) {
 		ast_log(LOG_ERROR, "Configuration file amd.conf missing.\n");
-		return;
+		return -1;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
-		return;
+		return 0;
 
 	cat = ast_category_browse(cfg, NULL);
 
@@ -360,7 +360,7 @@
 				dfltInitialSilence, dfltGreeting, dfltAfterGreetingSilence, dfltTotalAnalysisTime,
 				dfltMinimumWordLength, dfltBetweenWordsSilence, dfltMaximumNumberOfWords, dfltSilenceThreshold );
 
-	return;
+	return 0;
 }
 
 static int unload_module(void)
@@ -370,14 +370,18 @@
 
 static int load_module(void)
 {
-	load_config(0);
-	return ast_register_application(app, amd_exec, synopsis, descrip);
+	if (load_config(0))
+		return AST_MODULE_LOAD_DECLINE;
+	if (ast_register_application(app, amd_exec, synopsis, descrip))
+		return AST_MODULE_LOAD_FAILURE;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int reload(void)
 {
-	load_config(1);
-	return 0;
+	if (load_config(1))
+		return AST_MODULE_LOAD_DECLINE;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Answering Machine Detection Application",

Modified: trunk/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_authenticate.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_authenticate.c (original)
+++ trunk/apps/app_authenticate.c Wed Dec 26 14:02:27 2007
@@ -204,7 +204,9 @@
 
 static int load_module(void)
 {
-	return ast_register_application(app, auth_exec, synopsis, descrip);
+	if (ast_register_application(app, auth_exec, synopsis, descrip))
+		return AST_MODULE_LOAD_FAILURE;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Authentication Application");

Modified: trunk/apps/app_cdr.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_cdr.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_cdr.c (original)
+++ trunk/apps/app_cdr.c Wed Dec 26 14:02:27 2007
@@ -55,7 +55,9 @@
 
 static int load_module(void)
 {
-	return ast_register_application(nocdr_app, nocdr_exec, nocdr_synopsis, nocdr_descrip);
+	if (ast_register_application(nocdr_app, nocdr_exec, nocdr_synopsis, nocdr_descrip))
+		return AST_MODULE_LOAD_FAILURE;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Tell Asterisk to not maintain a CDR for the current call");

Modified: trunk/apps/app_zapateller.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_zapateller.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_zapateller.c (original)
+++ trunk/apps/app_zapateller.c Wed Dec 26 14:02:27 2007
@@ -107,7 +107,7 @@
 
 static int load_module(void)
 {
-	return ast_register_application(app, zapateller_exec, synopsis, descrip);
+	return ((ast_register_application(app, zapateller_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Block Telemarketers with Special Information Tone");

Modified: trunk/apps/app_zapbarge.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_zapbarge.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_zapbarge.c (original)
+++ trunk/apps/app_zapbarge.c Wed Dec 26 14:02:27 2007
@@ -293,7 +293,7 @@
 
 static int load_module(void)
 {
-	return ast_register_application(app, conf_exec, synopsis, descrip);
+	return ((ast_register_application(app, conf_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on Zap channel application");

Modified: trunk/apps/app_zapras.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_zapras.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_zapras.c (original)
+++ trunk/apps/app_zapras.c Wed Dec 26 14:02:27 2007
@@ -231,7 +231,7 @@
 
 static int load_module(void)
 {
-	return ast_register_application(app, zapras_exec, synopsis, descrip);
+	return ((ast_register_application(app, zapras_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Zaptel ISDN Remote Access Server");

Modified: trunk/apps/app_zapscan.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_zapscan.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/apps/app_zapscan.c (original)
+++ trunk/apps/app_zapscan.c Wed Dec 26 14:02:27 2007
@@ -356,7 +356,7 @@
 
 static int load_module(void)
 {
-	return ast_register_application(app, conf_exec, synopsis, descrip);
+	return ((ast_register_application(app, conf_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Scan Zap channels application");

Modified: trunk/pbx/pbx_config.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_config.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/pbx/pbx_config.c (original)
+++ trunk/pbx/pbx_config.c Wed Dec 26 14:02:27 2007
@@ -1639,7 +1639,7 @@
 	pbx_set_autofallthrough(autofallthrough_config);
 	pbx_set_extenpatternmatchnew(extenpatternmatchnew_config);
 
-	return 0;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int load_module(void)
@@ -1651,15 +1651,14 @@
 		ast_cli_register(&cli_dialplan_save);
 	ast_cli_register_multiple(cli_pbx_config, sizeof(cli_pbx_config) / sizeof(struct ast_cli_entry));
 
-	return 0;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int reload(void)
 {
 	if (clearglobalvars_config)
 		pbx_builtin_clear_globals();
-	pbx_load_module();
-	return 0;
+	return pbx_load_module();
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Text Extension Configuration",

Modified: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Wed Dec 26 14:02:27 2007
@@ -4779,9 +4779,9 @@
 	struct sockaddr_in sin;
 
 	if (set_config("dundi.conf", &sin, 1))
-		return -1;
-
-	return 0;
+		return AST_MODULE_LOAD_FAILURE;
+
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int load_module(void)

Modified: trunk/pbx/pbx_gtkconsole.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_gtkconsole.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/pbx/pbx_gtkconsole.c (original)
+++ trunk/pbx/pbx_gtkconsole.c Wed Dec 26 14:02:27 2007
@@ -230,7 +230,7 @@
 		}
 	}
 
-	return 0;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static void file_ok_sel(GtkWidget *w, GtkFileSelection *fs)
@@ -473,7 +473,7 @@
 {
 	if (pipe(clipipe)) {
 		ast_log(LOG_WARNING, "Unable to create CLI pipe\n");
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 	g_thread_init(NULL);
 	if (gtk_init_check(NULL, NULL))  {
@@ -489,7 +489,7 @@
 		else
 			ast_verb(2, "GTK is not available -- skipping monitor\n");
 	}
-	return 0;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static const char *description(void)

Modified: trunk/pbx/pbx_loopback.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_loopback.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/pbx/pbx_loopback.c (original)
+++ trunk/pbx/pbx_loopback.c Wed Dec 26 14:02:27 2007
@@ -168,8 +168,9 @@
 
 static int load_module(void)
 {
-	ast_register_switch(&loopback_switch);
-	return 0;
+	if (ast_register_switch(&loopback_switch))
+		return AST_MODULE_LOAD_FAILURE;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Loopback Switch");

Modified: trunk/pbx/pbx_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_realtime.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/pbx/pbx_realtime.c (original)
+++ trunk/pbx/pbx_realtime.c Wed Dec 26 14:02:27 2007
@@ -243,8 +243,9 @@
 
 static int load_module(void)
 {
-	ast_register_switch(&realtime_switch);
-	return 0;
+	if (ast_register_switch(&realtime_switch))
+		return AST_MODULE_LOAD_FAILURE;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Realtime Switch");

Modified: trunk/pbx/pbx_spool.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_spool.c?view=diff&rev=94806&r1=94805&r2=94806
==============================================================================
--- trunk/pbx/pbx_spool.c (original)
+++ trunk/pbx/pbx_spool.c Wed Dec 26 14:02:27 2007
@@ -494,16 +494,16 @@
 	snprintf(qdir, sizeof(qdir), "%s/%s", ast_config_AST_SPOOL_DIR, "outgoing");
 	if (ast_mkdir(qdir, 0777)) {
 		ast_log(LOG_WARNING, "Unable to create queue directory %s -- outgoing spool disabled\n", qdir);
-		return 0;
+		return AST_MODULE_LOAD_DECLINE;
 	}
 	snprintf(qdonedir, sizeof(qdir), "%s/%s", ast_config_AST_SPOOL_DIR, "outgoing_done");
 
 	if ((ret = ast_pthread_create_detached_background(&thread, NULL, scan_thread, NULL))) {
 		ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret);
-		return -1;
-	}
-
-	return 0;
+		return AST_MODULE_LOAD_FAILURE;
+	}
+
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Outgoing Spool Support");




More information about the asterisk-commits mailing list