[asterisk-commits] trunk - r8378 in /trunk/channels: chan_agent.c
chan_iax2.c chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sat Jan 21 01:01:25 MST 2006
Author: russell
Date: Sat Jan 21 02:01:24 2006
New Revision: 8378
URL: http://svn.digium.com/view/asterisk?rev=8378&view=rev
Log:
remove some useless checks of the result of ast_strdupa
Modified:
trunk/channels/chan_agent.c
trunk/channels/chan_iax2.c
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=8378&r1=8377&r2=8378&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Sat Jan 21 02:01:24 2006
@@ -329,10 +329,6 @@
struct agent_pvt *p, *prev;
parse = ast_strdupa(agent);
- if (!parse) {
- ast_log(LOG_ERROR, "Out of memory!\n");
- return NULL;
- }
/* Extract username (agt), password and name from agent (args). */
AST_NONSTANDARD_APP_ARGS(args, parse, ',');
@@ -1767,11 +1763,7 @@
LOCAL_USER_ADD(u);
- if (!(parse = ast_strdupa(data))) {
- ast_log(LOG_ERROR, "Out of memory!\n");
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
@@ -2511,10 +2503,6 @@
}
item = ast_strdupa(data);
- if (!item) {
- ast_log(LOG_ERROR, "Out of memory!\n");
- return buf;
- }
agentid = strsep(&item, ":");
if (!item)
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=8378&r1=8377&r2=8378&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Sat Jan 21 02:01:24 2006
@@ -2784,12 +2784,10 @@
char *key = NULL;
family = ast_strdupa(peer->dbsecret);
- if (family) {
- key = strchr(family, '/');
- if (key)
- *key++ = '\0';
- }
- if (!family || !key || ast_db_get(family, key, cai->secret, sizeof(cai->secret))) {
+ key = strchr(family, '/');
+ if (key)
+ *key++ = '\0';
+ if (!key || ast_db_get(family, key, cai->secret, sizeof(cai->secret))) {
ast_log(LOG_WARNING, "Unable to retrieve database password for family/key '%s'!\n", peer->dbsecret);
if (ast_test_flag(peer, IAX_TEMPONLY))
destroy_peer(peer);
@@ -3906,9 +3904,8 @@
unsigned char digest[16];
char *tmppw, *stringp;
- tmppw = ast_strdupa(iaxs[callno]->secret);
- stringp = tmppw;
- while((tmppw = strsep(&stringp, ";"))) {
+ stringp = ast_strdupa(iaxs[callno]->secret);
+ while ((tmppw = strsep(&stringp, ";"))) {
MD5Init(&md5);
MD5Update(&md5, (unsigned char *)iaxs[callno]->challenge, strlen(iaxs[callno]->challenge));
MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw));
@@ -4855,14 +4852,10 @@
if (!ast_strlen_zero(user->dbsecret)) {
char *family, *key=NULL;
family = ast_strdupa(user->dbsecret);
- if (family) {
- key = strchr(family, '/');
- if (key) {
- *key = '\0';
- key++;
- }
- }
- if (!family || !key || ast_db_get(family, key, iaxs[callno]->secret, sizeof(iaxs[callno]->secret))) {
+ key = strchr(family, '/');
+ if (key)
+ *key++ = '\0';
+ if (!key || ast_db_get(family, key, iaxs[callno]->secret, sizeof(iaxs[callno]->secret))) {
ast_log(LOG_WARNING, "Unable to retrieve database password for family/key '%s'!\n", user->dbsecret);
if (ast_test_flag(user, IAX_TEMPONLY)) {
destroy_user(user);
@@ -4968,9 +4961,8 @@
unsigned char digest[16];
char *tmppw, *stringp;
- tmppw = ast_strdupa(p->secret);
- stringp = tmppw;
- while((tmppw = strsep(&stringp, ";"))) {
+ stringp = ast_strdupa(p->secret);
+ while ((tmppw = strsep(&stringp, ";"))) {
MD5Init(&md5);
MD5Update(&md5, (unsigned char *)p->challenge, strlen(p->challenge));
MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw));
@@ -5098,9 +5090,8 @@
unsigned char digest[16];
char *tmppw, *stringp;
- tmppw = ast_strdupa(p->secret);
- stringp = tmppw;
- while((tmppw = strsep(&stringp, ";"))) {
+ stringp = ast_strdupa(p->secret);
+ while ((tmppw = strsep(&stringp, ";"))) {
MD5Init(&md5);
MD5Update(&md5, (unsigned char *)iaxs[callno]->challenge, strlen(iaxs[callno]->challenge));
MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw));
@@ -8034,10 +8025,6 @@
char *portstr;
tmp = ast_strdupa(srcaddr);
- if (!tmp) {
- ast_log(LOG_WARNING, "Out of memory!\n");
- return -1;
- }
addr = strsep(&tmp, ":");
portstr = tmp;
@@ -8335,7 +8322,7 @@
user->ha = ast_append_ha(v->name, v->value, user->ha);
} else if (!strcasecmp(v->name, "setvar")) {
varname = ast_strdupa(v->value);
- if (varname && (varval = strchr(varname,'='))) {
+ if ((varval = strchr(varname,'='))) {
*varval = '\0';
varval++;
if((tmpvar = ast_variable_new(varname, varval))) {
@@ -9174,10 +9161,7 @@
char *peername, *colname;
char iabuf[INET_ADDRSTRLEN];
- if (!(peername = ast_strdupa(data))) {
- ast_log(LOG_ERROR, "Memory Error!\n");
- return ret;
- }
+ peername = ast_strdupa(data);
/* if our channel, return the IP address of the endpoint of current channel */
if (!strcmp(peername,"CURRENTCHANNEL")) {
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=8378&r1=8377&r2=8378&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Jan 21 02:01:24 2006
@@ -1860,12 +1860,9 @@
char *tmpcall;
char *c;
tmpcall = ast_strdupa(r->callid);
- if (tmpcall) {
- c = strchr(tmpcall, '@');
- if (c) {
- *c = '\0';
- ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
- }
+ if ((c = strchr(tmpcall, '@'))) {
+ *c = '\0';
+ ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
}
}
if (ast_strlen_zero(r->tohost)) {
@@ -7057,12 +7054,8 @@
if ((c = strchr(of, ':')))
*c = '\0';
tmp = ast_strdupa(of);
- if (tmp) {
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, of);
- }
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
if (ast_strlen_zero(of))
return 0;
@@ -7087,12 +7080,8 @@
if (*calleridname)
ast_string_field_set(p, cid_name, calleridname);
tmp = ast_strdupa(rpid_num);
- if (tmp) {
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, rpid_num);
- }
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
if (p->rtp) {
@@ -7119,12 +7108,8 @@
ast_string_field_set(p, context, user->context);
if (!ast_strlen_zero(user->cid_num) && !ast_strlen_zero(p->cid_num)) {
char *tmp = ast_strdupa(user->cid_num);
- if (tmp) {
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, user->cid_num);
- }
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
if (!ast_strlen_zero(user->cid_name) && !ast_strlen_zero(p->cid_num))
ast_string_field_set(p, cid_name, user->cid_name);
@@ -7186,12 +7171,8 @@
char *tmp = ast_strdupa(rpid_num);
if (*calleridname)
ast_string_field_set(p, cid_name, calleridname);
- if (tmp) {
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, rpid_num);
- }
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
if (p->rtp) {
ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
@@ -7236,12 +7217,8 @@
}
if (!ast_strlen_zero(peer->cid_num) && !ast_strlen_zero(p->cid_num)) {
char *tmp = ast_strdupa(peer->cid_num);
- if (tmp) {
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, peer->cid_num);
- }
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
if (!ast_strlen_zero(peer->cid_name) && !ast_strlen_zero(p->cid_name))
ast_string_field_set(p, cid_name, peer->cid_name);
@@ -9292,10 +9269,7 @@
char *peername, *colname;
char iabuf[INET_ADDRSTRLEN];
- if (!(peername = ast_strdupa(data))) {
- ast_log(LOG_ERROR, "Memory Error!\n");
- return ret;
- }
+ peername = ast_strdupa(data);
if ((colname = strchr(peername, ':'))) {
*colname = '\0';
@@ -11953,7 +11927,7 @@
ast_copy_string(user->subscribecontext, v->value, sizeof(user->subscribecontext));
} else if (!strcasecmp(v->name, "setvar")) {
varname = ast_strdupa(v->value);
- if (varname && (varval = strchr(varname,'='))) {
+ if ((varval = strchr(varname,'='))) {
*varval = '\0';
varval++;
if ((tmpvar = ast_variable_new(varname, varval))) {
@@ -12257,7 +12231,7 @@
} else if (!strcasecmp(v->name, "setvar")) {
/* Set peer channel variable */
varname = ast_strdupa(v->value);
- if (varname && (varval = strchr(varname,'='))) {
+ if ((varval = strchr(varname,'='))) {
*varval = '\0';
varval++;
if ((tmpvar = ast_variable_new(varname, varval))) {
@@ -12848,10 +12822,6 @@
char tmp[80];
cdest = ast_strdupa(dest);
- if (!cdest) {
- ast_log(LOG_ERROR, "Problem allocating the memory\n");
- return 0;
- }
extension = strsep(&cdest, "@");
host = strsep(&cdest, ":");
port = strsep(&cdest, ":");
@@ -12869,28 +12839,17 @@
return 0;
}
if ((localtmp = strstr(tmp, "sip:")) && (localtmp = strchr(localtmp, '@'))) {
- char lhost[80], lport[80];
- memset(lhost, 0, sizeof(lhost));
- memset(lport, 0, sizeof(lport));
+ char lhost[80] = "", lport[80] = "";
localtmp++;
/* This is okey because lhost and lport are as big as tmp */
sscanf(localtmp, "%[^<>:; ]:%[^<>:; ]", lhost, lport);
- if (!strlen(lhost)) {
+ if (ast_strlen_zero(lhost)) {
ast_log(LOG_ERROR, "Can't find the host address\n");
return 0;
}
host = ast_strdupa(lhost);
- if (!host) {
- ast_log(LOG_ERROR, "Problem allocating the memory\n");
- return 0;
- }
- if (!ast_strlen_zero(lport)) {
+ if (!ast_strlen_zero(lport))
port = ast_strdupa(lport);
- if (!port) {
- ast_log(LOG_ERROR, "Problem allocating the memory\n");
- return 0;
- }
- }
}
}
More information about the asterisk-commits
mailing list