aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-27 02:19:37 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-27 02:19:37 +0000
commitee234bbb3efea571ea7ad138de22f1e010b92ec9 (patch)
tree9f24232bc60be91cb9017aab391d2eff0f4a6341 /channels/chan_sip.c
parent4cc87ee6e1e0ad07889f178b9c843fdd55d826e8 (diff)
Remove unnecessary checks before calls to ast_strlen_zero. Also, change
some places where strlen is used instead of ast_strlen_zero git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6866 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rwxr-xr-xchannels/chan_sip.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index afefb5032..31f9f803a 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -949,7 +949,7 @@ int find_sip_method(char *msg)
{
int i, res = 0;
- if (!msg || ast_strlen_zero(msg))
+ if (ast_strlen_zero(msg))
return 0;
for (i = 1; (i < (sizeof(sip_methods) / sizeof(sip_methods[0]))) && !res; i++) {
@@ -968,7 +968,7 @@ unsigned int parse_sip_options(struct sip_pvt *pvt, char *supported)
int i;
unsigned int profile = 0;
- if (!supported || ast_strlen_zero(supported) )
+ if (ast_strlen_zero(supported) )
return 0;
if (option_debug > 2 && sipdebug)
@@ -1554,7 +1554,7 @@ static int sip_sendtext(struct ast_channel *ast, const char *text)
ast_verbose("Sending text %s on %s\n", text, ast->name);
if (!p)
return -1;
- if (!text || ast_strlen_zero(text))
+ if (ast_strlen_zero(text))
return 0;
if (debug)
ast_verbose("Really sending text %s on %s\n", text, ast->name);
@@ -3177,7 +3177,7 @@ static int sip_register(char *value, int lineno)
*hostname = '\0';
hostname++;
}
- if (!username || ast_strlen_zero(username) || !hostname || ast_strlen_zero(hostname)) {
+ if (ast_strlen_zero(username) || ast_strlen_zero(hostname)) {
ast_log(LOG_WARNING, "Format for registration is user[:secret[:authuser]]@host[:port][/contact] at line %d\n", lineno);
return -1;
}
@@ -3192,7 +3192,7 @@ static int sip_register(char *value, int lineno)
hostname = strsep(&stringp, "/");
if (hostname)
contact = strsep(&stringp, "/");
- if (!contact || ast_strlen_zero(contact))
+ if (ast_strlen_zero(contact))
contact = "s";
stringp=hostname;
hostname = strsep(&stringp, ":");
@@ -4575,7 +4575,7 @@ static void extract_uri(struct sip_pvt *p, struct sip_request *req)
n = strchr(c, ';');
if (n)
*n = '\0';
- if (c && !ast_strlen_zero(c))
+ if (!ast_strlen_zero(c))
ast_copy_string(p->uri, c, sizeof(p->uri));
}
@@ -4613,7 +4613,7 @@ static void build_rpid(struct sip_pvt *p)
if (p->owner && p->owner->cid.cid_name) {
clin = strdup(p->owner->cid.cid_name);
}
- if (!clin || ast_strlen_zero(clin))
+ if (ast_strlen_zero(clin))
clin = clid;
switch (p->callingpres) {
@@ -4728,7 +4728,7 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
}
if (!l)
l = default_callerid;
- if (!n || ast_strlen_zero(n))
+ if (ast_strlen_zero(n))
n = l;
/* Allow user to be overridden */
if (!ast_strlen_zero(p->fromuser))
@@ -5099,7 +5099,7 @@ static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs,
add_header(&req, "Content-Type", default_notifymime);
ast_build_string(&t, &maxbytes, "Messages-Waiting: %s\r\n", newmsgs ? "yes" : "no");
- ast_build_string(&t, &maxbytes, "Message-Account: sip:%s@%s\r\n", (vmexten && !ast_strlen_zero(vmexten)) ? vmexten : global_vmexten, p->fromdomain);
+ ast_build_string(&t, &maxbytes, "Message-Account: sip:%s@%s\r\n", !ast_strlen_zero(vmexten) ? vmexten : global_vmexten, p->fromdomain);
ast_build_string(&t, &maxbytes, "Voice-Message: %d/%d (0/0)\r\n", newmsgs, oldmsgs);
if (t > tmp + sizeof(tmp))
@@ -5391,7 +5391,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, char *auth,
/* Fromdomain is what we are registering to, regardless of actual
host name from SRV */
- if (p->fromdomain && !ast_strlen_zero(p->fromdomain))
+ if (!ast_strlen_zero(p->fromdomain))
snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
else
snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
@@ -5418,7 +5418,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, char *auth,
if (auth) /* Add auth header */
add_header(&req, authheader, auth);
- else if ( !ast_strlen_zero(r->nonce) ) {
+ else if (!ast_strlen_zero(r->nonce)) {
char digest[1024];
/* We have auth data to reuse, build a digest header! */
@@ -5778,7 +5778,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
what we currently have stored as their contact address, so return
it
*/
- if (ast_strlen_zero(c) && (!expires || ast_strlen_zero(expires))) {
+ if (ast_strlen_zero(c) && ast_strlen_zero(expires)) {
if ((p->expire > -1) && !ast_strlen_zero(p->fullcontact)) {
/* tell them when the registration is going to expire */
pvt->expiry = ast_sched_when(sched, p->expire);
@@ -7364,7 +7364,7 @@ static int manager_sip_show_peers( struct mansession *s, struct message *m )
char idtext[256] = "";
int total = 0;
- if (id && !ast_strlen_zero(id))
+ if (!ast_strlen_zero(id))
snprintf(idtext,256,"ActionID: %s\r\n",id);
astman_send_ack(s, m, "Peer status list will follow");
@@ -7404,7 +7404,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
if (s) { /* Manager - get ActionID */
id = astman_get_header(m,"ActionID");
- if (id && !ast_strlen_zero(id))
+ if (!ast_strlen_zero(id))
snprintf(idtext,256,"ActionID: %s\r\n",id);
}
@@ -7784,7 +7784,7 @@ static int manager_sip_show_peer( struct mansession *s, struct message *m )
int ret;
peer = astman_get_header(m,"Peer");
- if (!peer || ast_strlen_zero(peer)) {
+ if (ast_strlen_zero(peer)) {
astman_send_error(s, m, "Peer: <name> missing.\n");
return 0;
}
@@ -7793,7 +7793,7 @@ static int manager_sip_show_peer( struct mansession *s, struct message *m )
a[2] = "peer";
a[3] = peer;
- if (id && !ast_strlen_zero(id))
+ if (!ast_strlen_zero(id))
ast_cli(s->fd, "ActionID: %s\r\n",id);
ret = _sip_show_peer(1, s->fd, s, m, 4, a );
ast_cli( s->fd, "\r\n\r\n" );
@@ -9131,7 +9131,7 @@ static struct ast_custom_function sip_header_function = {
/*! \brief function_check_sipdomain: Dial plan function to check if domain is local */
static char *func_check_sipdomain(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
{
- if (!data || ast_strlen_zero(data)) {
+ if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "CHECKSIPDOMAIN requires an argument - A domain name\n");
return buf;
}
@@ -10185,7 +10185,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
parse_sip_options(p, supported);
}
required = get_header(req, "Required");
- if (required && !ast_strlen_zero(required)) {
+ if (!ast_strlen_zero(required)) {
required_profile = parse_sip_options(NULL, required);
if (required_profile) { /* They require something */
/* At this point we support no extensions, so fail */
@@ -10641,7 +10641,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
return 0;
}
/* Initialize the context if it hasn't been already */
- if (p->subscribecontext && !ast_strlen_zero(p->subscribecontext))
+ if (!ast_strlen_zero(p->subscribecontext))
ast_copy_string(p->context, p->subscribecontext, sizeof(p->context));
else if (ast_strlen_zero(p->context))
strcpy(p->context, default_context);
@@ -11589,7 +11589,7 @@ static int add_sip_domain(const char *domain, const enum domain_mode mode, const
{
struct domain *d;
- if (!domain || ast_strlen_zero(domain)) {
+ if (ast_strlen_zero(domain)) {
ast_log(LOG_WARNING, "Zero length domain.\n");
return 1;
}
@@ -11602,7 +11602,7 @@ static int add_sip_domain(const char *domain, const enum domain_mode mode, const
ast_copy_string(d->domain, domain, sizeof(d->domain));
- if (context && !ast_strlen_zero(context))
+ if (!ast_strlen_zero(context))
ast_copy_string(d->context, context, sizeof(d->context));
d->mode = mode;
@@ -11660,7 +11660,7 @@ static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char
struct sip_auth *auth;
struct sip_auth *b = NULL, *a = authlist;
- if (!configuration || ast_strlen_zero(configuration))
+ if (ast_strlen_zero(configuration))
return authlist;
ast_log(LOG_DEBUG, "Auth config :: %s\n", configuration);
@@ -11674,7 +11674,7 @@ static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char
*realm = '\0';
realm++;
}
- if (!username || ast_strlen_zero(username) || !realm || ast_strlen_zero(realm)) {
+ if (ast_strlen_zero(username) || ast_strlen_zero(realm)) {
ast_log(LOG_WARNING, "Format for authentication entry is user[:secret]@realm at line %d\n", lineno);
return authlist;
}
@@ -12378,7 +12378,7 @@ static int reload_config(void)
if (ast_strlen_zero(domain))
ast_log(LOG_WARNING, "Empty domain specified at line %d\n", v->lineno);
- else if (context && ast_strlen_zero(context))
+ else if (ast_strlen_zero(context))
ast_log(LOG_WARNING, "Empty context specified at line %d for domain '%s'\n", v->lineno, domain);
else
add_sip_domain(ast_strip(domain), SIP_DOMAIN_CONFIG, context ? ast_strip(context) : "");