localize some variables and reduce nesting depth
authorLuigi Rizzo <rizzo@icir.org>
Sun, 8 Oct 2006 23:04:12 +0000 (23:04 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Sun, 8 Oct 2006 23:04:12 +0000 (23:04 +0000)
(indentation will be fixed by a separate commit).

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44749 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 624a920..0ed3390 100644 (file)
@@ -6522,25 +6522,21 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
 
        add_header(&req, "Allow", ALLOWED_METHODS);
        add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
-       if (p->options && p->options->addsipheaders ) {
-               struct ast_channel *ast;
-               struct varshead *headp = NULL;
-               const struct ast_var_t *current;
-
-               ast = p->owner; /* The owner channel */
-               if (ast) {
-                       char *headdup;
-                       headp = &ast->varshead;
+       if (p->options && p->options->addsipheaders && p->owner) {
+               struct ast_channel *ast = p->owner; /* The owner channel */
+               struct varshead *headp = &ast->varshead;
+
                        if (!headp)
                                ast_log(LOG_WARNING,"No Headp for the channel...ooops!\n");
                        else {
+                               const struct ast_var_t *current;
                                AST_LIST_TRAVERSE(headp, current, entries) {  
                                        /* SIPADDHEADER: Add SIP header to outgoing call */
                                        if (!strncasecmp(ast_var_name(current), "SIPADDHEADER", strlen("SIPADDHEADER"))) {
                                                char *content, *end;
                                                const char *header = ast_var_value(current);
+                                               char *headdup = ast_strdupa(header);
 
-                                               headdup = ast_strdupa(header);
                                                /* Strip of the starting " (if it's there) */
                                                if (*headdup == '"')
                                                        headdup++;
@@ -6559,7 +6555,6 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
                                        }
                                }
                        }
-               }
        }
        if (sdp) {
                if (p->udptl && p->t38.state == T38_LOCAL_DIRECT) {