diff options
author | mvanbaak <mvanbaak@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-19 20:48:33 +0000 |
---|---|---|
committer | mvanbaak <mvanbaak@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-19 20:48:33 +0000 |
commit | c342cdeaf3a971c5df904b312539c7c3082c60f5 (patch) | |
tree | 7b42274bee0dd9b38bbd91570bf09a13d1c6aef0 | |
parent | f06c83d2c47969db738a3f45b729e6c9906bbbd5 (diff) |
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.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@124127 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | apps/app_directory.c | 2 | ||||
-rw-r--r-- | apps/app_minivm.c | 2 | ||||
-rw-r--r-- | apps/app_queue.c | 14 | ||||
-rw-r--r-- | apps/app_voicemail.c | 34 | ||||
-rw-r--r-- | channels/chan_iax2.c | 22 | ||||
-rw-r--r-- | channels/chan_sip.c | 44 | ||||
-rw-r--r-- | doc/CODING-GUIDELINES | 9 | ||||
-rw-r--r-- | funcs/func_realtime.c | 10 | ||||
-rw-r--r-- | include/asterisk/compiler.h | 3 | ||||
-rw-r--r-- | main/logger.c | 2 | ||||
-rw-r--r-- | pbx/pbx_realtime.c | 4 | ||||
-rw-r--r-- | res/res_musiconhold.c | 8 | ||||
-rw-r--r-- | res/res_realtime.c | 4 |
13 files changed, 85 insertions, 73 deletions
diff --git a/apps/app_directory.c b/apps/app_directory.c index eb50336ec..f85dbeb11 100644 --- a/apps/app_directory.c +++ b/apps/app_directory.c @@ -366,7 +366,7 @@ static struct ast_config *realtime_directory(char *context) /* 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) diff --git a/apps/app_minivm.c b/apps/app_minivm.c index 8746aca5b..8b507ddd7 100644 --- a/apps/app_minivm.c +++ b/apps/app_minivm.c @@ -863,7 +863,7 @@ static struct minivm_account *find_user_realtime(const char *domain, const char 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); diff --git a/apps/app_queue.c b/apps/app_queue.c index da77facac..ae31a5af7 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -1578,9 +1578,9 @@ static struct call_queue *load_realtime_queue(const char *queuename) 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 @@ static int update_realtime_member_field(struct member *mem, const char *queue_na 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 @@ static void update_realtime_members(struct call_queue *q) 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 @@ static void leave_queue(struct queue_ent *qe) /*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 @@ static int queue_function_queuewaitingcount(struct ast_channel *chan, const char 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 @@ static int load_module(void) 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; } diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index e6c56395a..672a3e6bd 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -930,9 +930,9 @@ static int change_password_realtime(struct ast_vm_user *vmu, const char *passwor int res; if (!ast_strlen_zero(vmu->uniqueid)) { if (strlen(password) > 10) { - ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), NULL); + ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), SENTINEL); } - res = ast_update_realtime("voicemail", "uniqueid", vmu->uniqueid, "password", password, NULL); + 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 @@ static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const cha 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 @@ static int remove_file(char *dir, int msgnum) 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 @@ static void rename_file(char *sfn, char *dfn) 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 @@ static void copy_plain_file(char *frompath, char *topath) 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 @@ static void copy_plain_file(char *frompath, char *topath) 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 @@ static int vm_delete(char *file) * 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 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ 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 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ 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 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ 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 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ 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 @@ static char *show_users_realtime(int fd, const char *context) const char *cat = NULL; if (!(cfg = ast_load_realtime_multientry("voicemail", - "context", context, NULL))) { + "context", context, SENTINEL))) { return CLI_FAILURE; } @@ -10098,8 +10098,8 @@ static int load_module(void) 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 @@ static struct ast_vm_user *find_user_realtime_imapuser(const char *imapuser) 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); diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index fd33bd5c9..aeae13b70 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -3085,13 +3085,13 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in 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 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in } } 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 @@ static struct iax2_user *realtime_user(const char *username, struct sockaddr_in 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 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, 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 @@ static int load_module(void) 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; } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 2caaa0d76..c6ff79b94 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3643,13 +3643,13 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, "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 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i /* First check on peer name */ if (newpeername) { if (realtimeregs) - varregs = ast_load_realtime("sipregs", "name", newpeername, NULL); + varregs = ast_load_realtime("sipregs", "name", newpeername, SENTINEL); - var = ast_load_realtime("sippeers", "name", newpeername, "host", "dynamic", NULL); + 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 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i 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 @@ static struct sip_user *realtime_user(const char *username) 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 @@ static void destroy_association(struct sip_peer *peer) 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 @@ static int load_module(void) "fullcontact", RQ_CHAR, 20, "regserver", RQ_CHAR, 20, "useragent", RQ_CHAR, 20, - NULL); + SENTINEL); return AST_MODULE_LOAD_SUCCESS; } diff --git a/doc/CODING-GUIDELINES b/doc/CODING-GUIDELINES index aeca4a15b..53fd15da3 100644 --- a/doc/CODING-GUIDELINES +++ b/doc/CODING-GUIDELINES @@ -296,6 +296,15 @@ in other files. You will have to remove the "static" declaration and define a 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 ----------------- diff --git a/funcs/func_realtime.c b/funcs/func_realtime.c index a45c670d5..f3dd14be6 100644 --- a/funcs/func_realtime.c +++ b/funcs/func_realtime.c @@ -66,7 +66,7 @@ static int function_realtime_read(struct ast_channel *chan, const char *cmd, cha 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 @@ static int function_realtime_write(struct ast_channel *chan, const char *cmd, ch 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 @@ static int function_realtime_store(struct ast_channel *chan, const char *cmd, ch 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 @@ static int function_realtime_readdestroy(struct ast_channel *chan, const char *c 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 @@ static int function_realtime_readdestroy(struct ast_channel *chan, const char *c } 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); diff --git a/include/asterisk/compiler.h b/include/asterisk/compiler.h index b6575d000..b2db7ffdb 100644 --- a/include/asterisk/compiler.h +++ b/include/asterisk/compiler.h @@ -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 */ diff --git a/main/logger.c b/main/logger.c index 23704473e..4ec414dbb 100644 --- a/main/logger.c +++ b/main/logger.c @@ -480,7 +480,7 @@ void ast_queue_log(const char *queuename, const char *callid, const char *agent, "agent", agent, "event", event, "data", qlog_msg, - NULL); + SENTINEL); } else { if (qlog) { va_start(ap, fmt); diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c index 4fb06c867..536ed9d27 100644 --- a/pbx/pbx_realtime.c +++ b/pbx/pbx_realtime.c @@ -90,9 +90,9 @@ static struct ast_variable *realtime_switch_common(const char *table, const char 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); diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index a523a0395..2b1605ec3 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -1134,14 +1134,14 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con /* 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) { diff --git a/res/res_realtime.c b/res/res_realtime.c index 297ecb5ba..5ecff8b94 100644 --- a/res/res_realtime.c +++ b/res/res_realtime.c @@ -61,7 +61,7 @@ static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_ 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 @@ static char *cli_realtime_update(struct ast_cli_entry *e, int cmd, struct ast_cl 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"); |