[svn-commits] mvanbaak: trunk r124127 - in /trunk: apps/ channels/ doc/ funcs/ include/aste...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 19 15:48:34 CDT 2008


Author: mvanbaak
Date: Thu Jun 19 15:48:33 2008
New Revision: 124127

URL: http://svn.digium.com/view/asterisk?view=rev&rev=124127
Log:
Older versions of GNU gcc do not allow 'NULL' as sentinel.
They want (char *)NULL as sentinel.
An example is OpenBSD (confirmed on 4.3) that ships with gcc 3.3.4

This commit introduces a contstant SENTINEL which is declared as:
#define SENTINEL ((char *)NULL)

All places I could test compile on my openbsd system are converted.
Update CODING-GUIDELINES to tell about this constant.

Modified:
    trunk/apps/app_directory.c
    trunk/apps/app_minivm.c
    trunk/apps/app_queue.c
    trunk/apps/app_voicemail.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/doc/CODING-GUIDELINES
    trunk/funcs/func_realtime.c
    trunk/include/asterisk/compiler.h
    trunk/main/logger.c
    trunk/pbx/pbx_realtime.c
    trunk/res/res_musiconhold.c
    trunk/res/res_realtime.c

Modified: trunk/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_directory.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/apps/app_directory.c (original)
+++ trunk/apps/app_directory.c Thu Jun 19 15:48:33 2008
@@ -366,7 +366,7 @@
 
 	/* Get realtime entries, categorized by their mailbox number
 	   and present in the requested context */
-	rtdata = ast_load_realtime_multientry("voicemail", "mailbox LIKE", "%", "context", context, NULL);
+	rtdata = ast_load_realtime_multientry("voicemail", "mailbox LIKE", "%", "context", context, SENTINEL);
 
 	/* if there are no results, just return the entries from the config file */
 	if (!rtdata)

Modified: trunk/apps/app_minivm.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_minivm.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/apps/app_minivm.c (original)
+++ trunk/apps/app_minivm.c Thu Jun 19 15:48:33 2008
@@ -863,7 +863,7 @@
 		ast_copy_string(retval->username, username, sizeof(retval->username));
 
 	populate_defaults(retval);
-	var = ast_load_realtime("minivm", "username", username, "domain", domain, NULL);
+	var = ast_load_realtime("minivm", "username", username, "domain", domain, SENTINEL);
 
 	if (!var) {
 		ast_free(retval);

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu Jun 19 15:48:33 2008
@@ -1578,9 +1578,9 @@
 		   Thus we might see an empty member list when a queue is
 		   deleted. In practise, this is unlikely to cause a problem. */
 
-		queue_vars = ast_load_realtime("queues", "name", queuename, NULL);
+		queue_vars = ast_load_realtime("queues", "name", queuename, SENTINEL);
 		if (queue_vars) {
-			member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", queuename, NULL);
+			member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", queuename, SENTINEL);
 			if (!member_config) {
 				ast_log(LOG_ERROR, "no queue_members defined in your config (extconfig.conf).\n");
 				ast_variables_destroy(queue_vars);
@@ -1609,7 +1609,7 @@
 	if (ast_strlen_zero(mem->rt_uniqueid))
  		return ret;
 
-	if ((ast_update_realtime("queue_members", "uniqueid", mem->rt_uniqueid, field, value, NULL)) > 0)
+	if ((ast_update_realtime("queue_members", "uniqueid", mem->rt_uniqueid, field, value, SENTINEL)) > 0)
 		ret = 0;
 
 	return ret;
@@ -1623,7 +1623,7 @@
 	char *interface = NULL;
 	struct ao2_iterator mem_iter;
 
-	if (!(member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", q->name , NULL))) {
+	if (!(member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", q->name , SENTINEL))) {
 		/*This queue doesn't have realtime members*/
 		ast_debug(3, "Queue %s has no realtime members defined. No need for update\n", q->name);
 		return;
@@ -1982,7 +1982,7 @@
 
 	/*If the queue is a realtime queue, check to see if it's still defined in real time*/
 	if (q->realtime) {
-		if (!ast_load_realtime("queues", "name", q->name, NULL))
+		if (!ast_load_realtime("queues", "name", q->name, SENTINEL))
 			q->dead = 1;
 	}
 
@@ -4949,7 +4949,7 @@
 		count = q->count;
 		ao2_unlock(q);
 		queue_unref(q);
-	} else if ((var = ast_load_realtime("queues", "name", data, NULL))) {
+	} else if ((var = ast_load_realtime("queues", "name", data, SENTINEL))) {
 		/* if the queue is realtime but was not found in memory, this
 		 * means that the queue had been deleted from memory since it was 
 		 * "dead." This means it has a 0 waiting count
@@ -6436,7 +6436,7 @@
 		res = -1;
 	}
 
-	ast_realtime_require_field("queue_members", "paused", RQ_INTEGER1, 1, "uniqueid", RQ_UINTEGER2, 5, NULL);
+	ast_realtime_require_field("queue_members", "paused", RQ_INTEGER1, 1, "uniqueid", RQ_UINTEGER2, 5, SENTINEL);
 
 	return res ? AST_MODULE_LOAD_DECLINE : 0;
 }

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Jun 19 15:48:33 2008
@@ -930,9 +930,9 @@
 	int res;
 	if (!ast_strlen_zero(vmu->uniqueid)) {
 		if (strlen(password) > 10) {
-			ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), NULL);
-		}
-		res = ast_update_realtime("voicemail", "uniqueid", vmu->uniqueid, "password", password, NULL);
+			ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), SENTINEL);
+		}
+		res = ast_update_realtime("voicemail", "uniqueid", vmu->uniqueid, "password", password, SENTINEL);
 		if (res > 0) {
 			ast_copy_string(vmu->password, password, sizeof(vmu->password));
 			res = 0;
@@ -1044,9 +1044,9 @@
 			ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox));
 		populate_defaults(retval);
 		if (!context && ast_test_flag((&globalflags), VM_SEARCH))
-			var = ast_load_realtime("voicemail", "mailbox", mailbox, NULL);
+			var = ast_load_realtime("voicemail", "mailbox", mailbox, SENTINEL);
 		else
-			var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, NULL);
+			var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, SENTINEL);
 		if (var) {
 			apply_options_full(retval, var);
 			ast_variables_destroy(var);
@@ -1520,7 +1520,7 @@
 		ast_copy_string(fn, dir, sizeof(fn));
 	ast_filedelete(fn, NULL);	
 	if (ast_check_realtime("voicemail_data")) {
-		ast_destroy_realtime("voicemail_data", "filename", fn, NULL);
+		ast_destroy_realtime("voicemail_data", "filename", fn, SENTINEL);
 	}
 	snprintf(full_fn, sizeof(full_fn), "%s.txt", fn);
 	unlink(full_fn);
@@ -1986,7 +1986,7 @@
 	snprintf(stxt, sizeof(stxt), "%s.txt", sfn);
 	snprintf(dtxt, sizeof(dtxt), "%s.txt", dfn);
 	if (ast_check_realtime("voicemail_data")) {
-		ast_update_realtime("voicemail_data", "filename", sfn, "filename", dfn, NULL);
+		ast_update_realtime("voicemail_data", "filename", sfn, "filename", dfn, SENTINEL);
 	}
 	rename(stxt, dtxt);
 }
@@ -2108,7 +2108,7 @@
 	snprintf(frompath2, sizeof(frompath2), "%s.txt", frompath);
 	snprintf(topath2, sizeof(topath2), "%s.txt", topath);
 	if (ast_check_realtime("voicemail_data")) {
-		var = ast_load_realtime("voicemail_data", "filename", frompath, NULL);
+		var = ast_load_realtime("voicemail_data", "filename", frompath, SENTINEL);
 		/* This cycle converts ast_variable linked list, to va_list list of arguments, may be there is a better way to do it? */
 		for (tmp = var; tmp; tmp = tmp->next) {
 			if (!strcasecmp(tmp->name, "origmailbox")) {
@@ -2135,7 +2135,7 @@
 				duration = tmp->value;
 			}
 		}
-		ast_store_realtime("voicemail_data", "filename", topath, "origmailbox", origmailbox, "context", context, "macrocontext", macrocontext, "exten", exten, "priority", priority, "callerchan", callerchan, "callerid", callerid, "origdate", origdate, "origtime", origtime, "category", category, "duration", duration, NULL);
+		ast_store_realtime("voicemail_data", "filename", topath, "origmailbox", origmailbox, "context", context, "macrocontext", macrocontext, "exten", exten, "priority", priority, "callerchan", callerchan, "callerid", callerid, "origdate", origdate, "origtime", origtime, "category", category, "duration", duration, SENTINEL);
 	}
 	copy(frompath2, topath2);
 	ast_variables_destroy(var);
@@ -2163,7 +2163,7 @@
 	 * but trying to eliminate all sprintf's anyhow
 	 */
 	if (ast_check_realtime("voicemail_data")) {
-		ast_destroy_realtime("voicemail_data", "filename", file, NULL);
+		ast_destroy_realtime("voicemail_data", "filename", file, SENTINEL);
 	}
 	snprintf(txt, txtsize, "%s.txt", file);
 	unlink(txt);
@@ -4013,7 +4013,7 @@
 			snprintf(priority, sizeof(priority), "%d", chan->priority);
 			snprintf(origtime, sizeof(origtime), "%ld", (long)time(NULL));
 			get_date(date, sizeof(date));
-			rtmsgid = ast_store_realtime("voicemail_data", "origmailbox", ext, "context", chan->context, "macrocontext", chan->macrocontext, "exten", chan->exten, "priority", priority, "callerchan", chan->name, "callerid", ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"), "origdate", date, "origtime", origtime, "category", S_OR(category,""), NULL);
+			rtmsgid = ast_store_realtime("voicemail_data", "origmailbox", ext, "context", chan->context, "macrocontext", chan->macrocontext, "exten", chan->exten, "priority", priority, "callerchan", chan->name, "callerid", ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"), "origdate", date, "origtime", origtime, "category", S_OR(category,""), SENTINEL);
 		}
 
 		/* Store information */
@@ -4062,7 +4062,7 @@
 				unlink(tmptxtfile);
 				if (ast_check_realtime("voicemail_data")) {
 					snprintf(tmpid, sizeof(tmpid), "%d", rtmsgid);
-					ast_destroy_realtime("voicemail_data", "id", tmpid, NULL);
+					ast_destroy_realtime("voicemail_data", "id", tmpid, SENTINEL);
 				}
 			} else {
 				fprintf(txt, "duration=%d\n", duration);
@@ -4078,7 +4078,7 @@
 					ast_unlock_path(dir);
 					if (ast_check_realtime("voicemail_data")) {
 						snprintf(tmpid, sizeof(tmpid), "%d", rtmsgid);
-						ast_destroy_realtime("voicemail_data", "id", tmpid, NULL);
+						ast_destroy_realtime("voicemail_data", "id", tmpid, SENTINEL);
 					}
 				} else {
 #ifndef IMAP_STORAGE
@@ -4106,7 +4106,7 @@
 					if (ast_check_realtime("voicemail_data")) {
 						snprintf(tmpid, sizeof(tmpid), "%d", rtmsgid);
 						snprintf(tmpdur, sizeof(tmpdur), "%d", duration);
-						ast_update_realtime("voicemail_data", "id", tmpid, "filename", fn, "duration", tmpdur, NULL);
+						ast_update_realtime("voicemail_data", "id", tmpid, "filename", fn, "duration", tmpdur, SENTINEL);
 					}
 					/* We must store the file first, before copying the message, because
 					 * ODBC storage does the entire copy with SQL.
@@ -8884,7 +8884,7 @@
 	const char *cat = NULL;
 
 	if (!(cfg = ast_load_realtime_multientry("voicemail", 
-		"context", context, NULL))) {
+		"context", context, SENTINEL))) {
 		return CLI_FAILURE;
 	}
 
@@ -10098,8 +10098,8 @@
 	ast_cli_register_multiple(cli_voicemail, sizeof(cli_voicemail) / sizeof(struct ast_cli_entry));
 
 	ast_install_vm_functions(has_voicemail, inboxcount, messagecount, sayname);
-	ast_realtime_require_field("voicemail", "uniqueid", RQ_UINTEGER3, 11, "password", RQ_CHAR, 10, NULL);
-	ast_realtime_require_field("voicemail_data", "filename", RQ_CHAR, 30, "duration", RQ_UINTEGER3, 5, NULL);
+	ast_realtime_require_field("voicemail", "uniqueid", RQ_UINTEGER3, 11, "password", RQ_CHAR, 10, SENTINEL);
+	ast_realtime_require_field("voicemail_data", "filename", RQ_CHAR, 30, "duration", RQ_UINTEGER3, 5, SENTINEL);
 
 	return res;
 }
@@ -10691,7 +10691,7 @@
 	ast_set_flag(vmu, VM_ALLOCED);
 	populate_defaults(vmu);
 
-	var = ast_load_realtime("voicemail", "imapuser", imapuser, NULL);
+	var = ast_load_realtime("voicemail", "imapuser", imapuser, SENTINEL);
 	if (var) {
 		apply_options_full(vmu, var);
 		ast_variables_destroy(var);

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu Jun 19 15:48:33 2008
@@ -3085,13 +3085,13 @@
 	int dynamic=0;
 
 	if (peername) {
-		var = ast_load_realtime("iaxpeers", "name", peername, "host", "dynamic", NULL);
+		var = ast_load_realtime("iaxpeers", "name", peername, "host", "dynamic", SENTINEL);
 		if (!var && sin)
-			var = ast_load_realtime("iaxpeers", "name", peername, "host", ast_inet_ntoa(sin->sin_addr), NULL);
+			var = ast_load_realtime("iaxpeers", "name", peername, "host", ast_inet_ntoa(sin->sin_addr), SENTINEL);
 	} else if (sin) {
 		char porta[25];
 		sprintf(porta, "%d", ntohs(sin->sin_port));
-		var = ast_load_realtime("iaxpeers", "ipaddr", ast_inet_ntoa(sin->sin_addr), "port", porta, NULL);
+		var = ast_load_realtime("iaxpeers", "ipaddr", ast_inet_ntoa(sin->sin_addr), "port", porta, SENTINEL);
 		if (var) {
 			/* We'll need the peer name in order to build the structure! */
 			for (tmp = var; tmp; tmp = tmp->next) {
@@ -3101,7 +3101,7 @@
 		}
 	}
 	if (!var && peername) { /* Last ditch effort */
-		var = ast_load_realtime("iaxpeers", "name", peername, NULL);
+		var = ast_load_realtime("iaxpeers", "name", peername, SENTINEL);
 		/*!\note
 		 * If this one loaded something, then we need to ensure that the host
 		 * field matched.  The only reason why we can't have this as a criteria
@@ -3202,18 +3202,18 @@
 	struct ast_variable *tmp;
 	struct iax2_user *user=NULL;
 
-	var = ast_load_realtime("iaxusers", "name", username, "host", "dynamic", NULL);
+	var = ast_load_realtime("iaxusers", "name", username, "host", "dynamic", SENTINEL);
 	if (!var)
-		var = ast_load_realtime("iaxusers", "name", username, "host", ast_inet_ntoa(sin->sin_addr), NULL);
+		var = ast_load_realtime("iaxusers", "name", username, "host", ast_inet_ntoa(sin->sin_addr), SENTINEL);
 	if (!var && sin) {
 		char porta[6];
 		snprintf(porta, sizeof(porta), "%d", ntohs(sin->sin_port));
-		var = ast_load_realtime("iaxusers", "name", username, "ipaddr", ast_inet_ntoa(sin->sin_addr), "port", porta, NULL);
+		var = ast_load_realtime("iaxusers", "name", username, "ipaddr", ast_inet_ntoa(sin->sin_addr), "port", porta, SENTINEL);
 		if (!var)
-			var = ast_load_realtime("iaxusers", "ipaddr", ast_inet_ntoa(sin->sin_addr), "port", porta, NULL);
+			var = ast_load_realtime("iaxusers", "ipaddr", ast_inet_ntoa(sin->sin_addr), "port", porta, SENTINEL);
 	}
 	if (!var) { /* Last ditch effort */
-		var = ast_load_realtime("iaxusers", "name", username, NULL);
+		var = ast_load_realtime("iaxusers", "name", username, SENTINEL);
 		/*!\note
 		 * If this one loaded something, then we need to ensure that the host
 		 * field matched.  The only reason why we can't have this as a criteria
@@ -3276,7 +3276,7 @@
 	snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
 	ast_update_realtime("iaxpeers", "name", peername, 
 		"ipaddr", ast_inet_ntoa(sin->sin_addr), "port", port, 
-		"regseconds", regseconds, NULL);
+		"regseconds", regseconds, SENTINEL);
 }
 
 struct create_addr_info {
@@ -12185,7 +12185,7 @@
 	reload_firmware(0);
 	iax_provision_reload(0);
 
-	ast_realtime_require_field("iaxpeers", "name", RQ_CHAR, 10, "ipaddr", RQ_CHAR, 15, "port", RQ_UINTEGER2, 5, "regseconds", RQ_UINTEGER2, 6, NULL);
+	ast_realtime_require_field("iaxpeers", "name", RQ_CHAR, 10, "ipaddr", RQ_CHAR, 15, "port", RQ_UINTEGER2, 5, "regseconds", RQ_UINTEGER2, 6, SENTINEL);
 
 	return AST_MODULE_LOAD_SUCCESS;
 }

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Jun 19 15:48:33 2008
@@ -3643,13 +3643,13 @@
 			"port", port, "regseconds", regseconds,
 			deprecated_username ? "username" : "defaultuser", defaultuser,
 			"useragent", useragent,
-			fc, fullcontact, syslabel, sysname, NULL); /* note fc and syslabel _can_ be NULL */
+			fc, fullcontact, syslabel, sysname, SENTINEL); /* note fc and syslabel _can_ be NULL */
 	} else {
 		ast_update_realtime(tablename, "name", peername, "ipaddr", ipaddr,
 			"port", port, "regseconds", regseconds,
 			"useragent", useragent,
 			deprecated_username ? "username" : "defaultuser", defaultuser,
-			syslabel, sysname, NULL); /* note syslabel _can_ be NULL */
+			syslabel, sysname, SENTINEL); /* note syslabel _can_ be NULL */
 	}
 }
 
@@ -3828,13 +3828,13 @@
 	/* First check on peer name */
 	if (newpeername) {
 		if (realtimeregs)
-			varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
-
-		var = ast_load_realtime("sippeers", "name", newpeername, "host", "dynamic", NULL);
+			varregs = ast_load_realtime("sipregs", "name", newpeername, SENTINEL);
+
+		var = ast_load_realtime("sippeers", "name", newpeername, "host", "dynamic", SENTINEL);
 		if (!var && sin)
-			var = ast_load_realtime("sippeers", "name", newpeername, "host", ast_inet_ntoa(sin->sin_addr), NULL);
+			var = ast_load_realtime("sippeers", "name", newpeername, "host", ast_inet_ntoa(sin->sin_addr), SENTINEL);
 		if (!var) {
-			var = ast_load_realtime("sippeers", "name", newpeername, NULL);
+			var = ast_load_realtime("sippeers", "name", newpeername, SENTINEL);
 			/*!\note
 			 * If this one loaded something, then we need to ensure that the host
 			 * field matched.  The only reason why we can't have this as a criteria
@@ -3862,62 +3862,62 @@
 		ast_copy_string(ipaddr, ast_inet_ntoa(sin->sin_addr), sizeof(ipaddr));
 		portnum = ntohs(sin->sin_port);
 		sprintf(portstring, "%u", portnum);
-		var = ast_load_realtime("sippeers", "host", ipaddr, "port", portstring, NULL);	/* First check for fixed IP hosts */
+		var = ast_load_realtime("sippeers", "host", ipaddr, "port", portstring, SENTINEL);	/* First check for fixed IP hosts */
 		if (var) {
 			if (realtimeregs) {
 				newpeername = get_name_from_variable(var, newpeername);
-				varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
+				varregs = ast_load_realtime("sipregs", "name", newpeername, SENTINEL);
 			}
 		} else {
 			if (realtimeregs)
-				varregs = ast_load_realtime("sipregs", "ipaddr", ipaddr, "port", portstring, NULL); /* Then check for registered hosts */
+				varregs = ast_load_realtime("sipregs", "ipaddr", ipaddr, "port", portstring, SENTINEL); /* Then check for registered hosts */
 			else
-				var = ast_load_realtime("sippeers", "ipaddr", ipaddr, "port", portstring, NULL); /* Then check for registered hosts */
+				var = ast_load_realtime("sippeers", "ipaddr", ipaddr, "port", portstring, SENTINEL); /* Then check for registered hosts */
 			if (varregs) {
 				newpeername = get_name_from_variable(varregs, newpeername);
-				var = ast_load_realtime("sippeers", "name", newpeername, NULL);
+				var = ast_load_realtime("sippeers", "name", newpeername, SENTINEL);
 			}
 		}
 		if (!var) { /*We couldn't match on ipaddress and port, so we need to check if port is insecure*/
-			peerlist = ast_load_realtime_multientry("sippeers", "host", ipaddr, NULL);
+			peerlist = ast_load_realtime_multientry("sippeers", "host", ipaddr, SENTINEL);
 			if (peerlist) {
 				var = get_insecure_variable_from_config(peerlist);
 				if(var) {
 					if (realtimeregs) {
 						newpeername = get_name_from_variable(var, newpeername);
-						varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
+						varregs = ast_load_realtime("sipregs", "name", newpeername, SENTINEL);
 					}
 				} else { /*var wasn't found in the list of "hosts", so try "ipaddr"*/
 					peerlist = NULL;
 					cat = NULL;
-					peerlist = ast_load_realtime_multientry("sippeers", "ipaddr", ipaddr, NULL);
+					peerlist = ast_load_realtime_multientry("sippeers", "ipaddr", ipaddr, SENTINEL);
 					if(peerlist) {
 						var = get_insecure_variable_from_config(peerlist);
 						if(var) {
 							if (realtimeregs) {
 								newpeername = get_name_from_variable(var, newpeername);
-								varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
+								varregs = ast_load_realtime("sipregs", "name", newpeername, SENTINEL);
 							}
 						}
 					}
 				}
 			} else {
 				if (realtimeregs) {
-					peerlist = ast_load_realtime_multientry("sipregs", "ipaddr", ipaddr, NULL);
+					peerlist = ast_load_realtime_multientry("sipregs", "ipaddr", ipaddr, SENTINEL);
 					if (peerlist) {
 						varregs = get_insecure_variable_from_config(peerlist);
 						if (varregs) {
 							newpeername = get_name_from_variable(varregs, newpeername);
-							var = ast_load_realtime("sippeers", "name", newpeername, NULL);
+							var = ast_load_realtime("sippeers", "name", newpeername, SENTINEL);
 						}
 					}
 				} else {
-					peerlist = ast_load_realtime_multientry("sippeers", "ipaddr", ipaddr, NULL);
+					peerlist = ast_load_realtime_multientry("sippeers", "ipaddr", ipaddr, SENTINEL);
 					if (peerlist) {
 						var = get_insecure_variable_from_config(peerlist);
 						if (var) {
 							newpeername = get_name_from_variable(var, newpeername);
-							varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
+							varregs = ast_load_realtime("sipregs", "name", newpeername, SENTINEL);
 						}
 					}
 				}
@@ -4063,7 +4063,7 @@
 	struct ast_variable *tmp;
 	struct sip_user *user = NULL;
 
-	var = ast_load_realtime("sipusers", "name", username, NULL);
+	var = ast_load_realtime("sipusers", "name", username, SENTINEL);
 
 	if (!var)
 		return NULL;
@@ -10108,7 +10108,7 @@
 
 	if (!sip_cfg.ignore_regexpire) {
 		if (peer->rt_fromcontact)
-			ast_update_realtime(tablename, "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", peer->deprecated_username ? "username" : "defaultuser", "", "regserver", "", "useragent", "", NULL);
+			ast_update_realtime(tablename, "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", peer->deprecated_username ? "username" : "defaultuser", "", "regserver", "", "useragent", "", SENTINEL);
 		else 
 			ast_db_del("SIP/Registry", peer->name);
 	}
@@ -22985,7 +22985,7 @@
 		"fullcontact", RQ_CHAR, 20,
 		"regserver", RQ_CHAR, 20,
 		"useragent", RQ_CHAR, 20,
-		NULL);
+		SENTINEL);
 
 	return AST_MODULE_LOAD_SUCCESS;
 }

Modified: trunk/doc/CODING-GUIDELINES
URL: http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/doc/CODING-GUIDELINES (original)
+++ trunk/doc/CODING-GUIDELINES Thu Jun 19 15:48:33 2008
@@ -296,6 +296,15 @@
 prototype in an appropriate header file (usually in include/asterisk). A more
 specific name should be given, such as "ast_find_call_feature".
 
+* Variable function argument parsing
+------------------------------------
+
+Functions with a variable amount of argumenst need a 'sentinel' when called.
+Newer GNU C compilers are fine if you use NULL for this. Older versions (pre 4)
+don't like this.
+You should use the constant SENTINEL.
+This one is defined in include/asterisk/compiler.h
+
 * Variable naming
 -----------------
 

Modified: trunk/funcs/func_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_realtime.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/funcs/func_realtime.c (original)
+++ trunk/funcs/func_realtime.c Thu Jun 19 15:48:33 2008
@@ -66,7 +66,7 @@
 	if (chan)
 		ast_autoservice_start(chan);
 
-	head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, NULL);
+	head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, SENTINEL);
 
 	if (!head) {
 		if (chan)
@@ -112,7 +112,7 @@
 
 	AST_STANDARD_APP_ARGS(args, data);
 
-	res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, NULL);
+	res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, SENTINEL);
 
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n");
@@ -156,7 +156,7 @@
 		a.f[10], v.v[10], a.f[11], v.v[11], a.f[12], v.v[12], a.f[13], v.v[13], a.f[14], v.v[14],
 		a.f[15], v.v[15], a.f[16], v.v[16], a.f[17], v.v[17], a.f[18], v.v[18], a.f[19], v.v[19],
 		a.f[20], v.v[20], a.f[21], v.v[21], a.f[22], v.v[22], a.f[23], v.v[23], a.f[24], v.v[24],
-		a.f[25], v.v[25], a.f[26], v.v[26], a.f[27], v.v[27], a.f[28], v.v[28], a.f[29], v.v[29], NULL
+		a.f[25], v.v[25], a.f[26], v.v[26], a.f[27], v.v[27], a.f[28], v.v[28], a.f[29], v.v[29], SENTINEL
 	);
 
 	if (res < 0) {
@@ -201,7 +201,7 @@
 	if (chan)
 		ast_autoservice_start(chan);
 
-	head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, NULL);
+	head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, SENTINEL);
 
 	if (!head) {
 		if (chan)
@@ -222,7 +222,7 @@
 	}
 	ast_copy_string(buf, out->str, len);
 
-	ast_destroy_realtime(args.family, args.fieldmatch, args.value, NULL);
+	ast_destroy_realtime(args.family, args.fieldmatch, args.value, SENTINEL);
 
 	if (chan)
 		ast_autoservice_stop(chan);

Modified: trunk/include/asterisk/compiler.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/compiler.h?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/include/asterisk/compiler.h (original)
+++ trunk/include/asterisk/compiler.h Thu Jun 19 15:48:33 2008
@@ -65,4 +65,7 @@
 #define attribute_warn_unused_result
 #endif
 
+/* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */
+#define SENTINEL ((char *)NULL)
+
 #endif /* _ASTERISK_COMPILER_H */

Modified: trunk/main/logger.c
URL: http://svn.digium.com/view/asterisk/trunk/main/logger.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Thu Jun 19 15:48:33 2008
@@ -480,7 +480,7 @@
 						"agent", agent, 
 						"event", event,
 						"data", qlog_msg,
-						NULL);
+						SENTINEL);
 	} else {
 		if (qlog) {
 			va_start(ap, fmt);

Modified: trunk/pbx/pbx_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_realtime.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/pbx/pbx_realtime.c (original)
+++ trunk/pbx/pbx_realtime.c Thu Jun 19 15:48:33 2008
@@ -90,9 +90,9 @@
 		ematch = "exten";
 		ast_copy_string(rexten, exten, sizeof(rexten));
 	}
-	var = ast_load_realtime(table, ematch, rexten, "context", context, "priority", pri, NULL);
+	var = ast_load_realtime(table, ematch, rexten, "context", context, "priority", pri, SENTINEL);
 	if (!var) {
-		cfg = ast_load_realtime_multientry(table, "exten LIKE", "\\_%", "context", context, "priority", pri, NULL);	
+		cfg = ast_load_realtime_multientry(table, "exten LIKE", "\\_%", "context", context, "priority", pri, SENTINEL);	
 		if (cfg) {
 			char *cat = ast_category_browse(cfg, NULL);
 

Modified: trunk/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_musiconhold.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/res/res_musiconhold.c (original)
+++ trunk/res/res_musiconhold.c Thu Jun 19 15:48:33 2008
@@ -1134,14 +1134,14 @@
 	/* If no moh class found in memory, then check RT */
 	if (!mohclass && ast_check_realtime("musiconhold")) {
 		if (!ast_strlen_zero(chan->musicclass)) {
-			var = ast_load_realtime("musiconhold", "name", chan->musicclass, NULL);
+			var = ast_load_realtime("musiconhold", "name", chan->musicclass, SENTINEL);
 		}
 		if (!var && !ast_strlen_zero(mclass))
-			var = ast_load_realtime("musiconhold", "name", mclass, NULL);
+			var = ast_load_realtime("musiconhold", "name", mclass, SENTINEL);
 		if (!var && !ast_strlen_zero(interpclass))
-			var = ast_load_realtime("musiconhold", "name", interpclass, NULL);
+			var = ast_load_realtime("musiconhold", "name", interpclass, SENTINEL);
 		if (!var)
-			var = ast_load_realtime("musiconhold", "name", "default", NULL);
+			var = ast_load_realtime("musiconhold", "name", "default", SENTINEL);
 		if (var && (mohclass = moh_class_malloc())) {
 			mohclass->realtime = 1;
 			for (tmp = var; tmp; tmp = tmp->next) {

Modified: trunk/res/res_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_realtime.c?view=diff&rev=124127&r1=124126&r2=124127
==============================================================================
--- trunk/res/res_realtime.c (original)
+++ trunk/res/res_realtime.c Thu Jun 19 15:48:33 2008
@@ -61,7 +61,7 @@
 	if (a->argc < 5) 
 		return CLI_SHOWUSAGE;
 
-	var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], NULL);
+	var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], SENTINEL);
 
 	if (var) {
 		ast_cli(a->fd, CRL_HEADER_FORMAT, "Column Name", "Column Value");
@@ -97,7 +97,7 @@
 	if (a->argc < 7) 
 		return CLI_SHOWUSAGE;
 
-	res = ast_update_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], NULL);
+	res = ast_update_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], SENTINEL);
 
 	if(res < 0) {
 		ast_cli(a->fd, "Failed to update. Check the debug log for possible SQL related entries.\n");




More information about the svn-commits mailing list