Ignore:
Timestamp:
Feb 4, 2014 10:13:56 AM (10 years ago)
Author:
bennylp
Message:

Misc (re #1630): Fixing warnings about variable set but not used with recent gcc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c

    r4537 r4728  
    11/* $Id$ */ 
    2 /*  
     2/* 
    33 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    44 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
     
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919 */ 
    2020 
     
    138138/* 
    139139 * Create response digest based on the parameters and store the 
    140  * digest ASCII in 'result'.  
     140 * digest ASCII in 'result'. 
    141141 */ 
    142142PJ_DEF(void) pjsip_auth_create_digest( pj_str_t *result, 
     
    160160 
    161161    if ((cred_info->data_type & PASSWD_MASK) == PJSIP_CRED_DATA_PLAIN_PASSWD) { 
    162         /***  
    163          *** ha1 = MD5(username ":" realm ":" password)  
     162        /*** 
     163         *** ha1 = MD5(username ":" realm ":" password) 
    164164         ***/ 
    165165        pj_md5_init(&pms); 
     
    183183 
    184184    /*** 
    185      *** ha2 = MD5(method ":" req_uri)  
     185     *** ha2 = MD5(method ":" req_uri) 
    186186     ***/ 
    187187    pj_md5_init(&pms); 
     
    196196    /*** 
    197197     *** When qop is not used: 
    198      ***    response = MD5(ha1 ":" nonce ":" ha2)  
     198     ***    response = MD5(ha1 ":" nonce ":" ha2) 
    199199     *** 
    200200     *** When qop=auth is used: 
     
    218218    /* This is the final response digest. */ 
    219219    pj_md5_final(&pms, digest); 
    220      
     220 
    221221    /* Convert digest to string and store in chal->response. */ 
    222222    result->slen = PJSIP_MD5STRLEN; 
     
    259259 
    260260/* 
    261  * Generate response digest.  
     261 * Generate response digest. 
    262262 * Most of the parameters to generate the digest (i.e. username, realm, uri, 
    263263 * and nonce) are expected to be in the credential. Additional parameters (i.e. 
     
    308308        if ((cred_info->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) { 
    309309            /* Call application callback to create the response digest */ 
    310             return (*cred_info->ext.aka.cb)(pool, chal, cred_info,  
     310            return (*cred_info->ext.aka.cb)(pool, chal, cred_info, 
    311311                                            method, cred); 
    312         }  
     312        } 
    313313        else { 
    314314            /* Convert digest to string and store in chal->response. */ 
    315             pjsip_auth_create_digest( &cred->response, &cred->nonce, NULL,  
    316                                       NULL,  NULL, uri, &chal->realm,  
     315            pjsip_auth_create_digest( &cred->response, &cred->nonce, NULL, 
     316                                      NULL,  NULL, uri, &chal->realm, 
    317317                                      cred_info, method); 
    318318        } 
    319319 
    320320    } else if (has_auth_qop(pool, &chal->qop)) { 
    321         /* Server requires quality of protection.  
     321        /* Server requires quality of protection. 
    322322         * We respond with selecting "qop=auth" protection. 
    323323         */ 
     
    335335        if ((cred_info->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) { 
    336336            /* Call application callback to create the response digest */ 
    337             return (*cred_info->ext.aka.cb)(pool, chal, cred_info,  
     337            return (*cred_info->ext.aka.cb)(pool, chal, cred_info, 
    338338                                            method, cred); 
    339339        } 
    340340        else { 
    341             pjsip_auth_create_digest( &cred->response, &cred->nonce,  
    342                                       &cred->nc, cnonce, &pjsip_AUTH_STR,  
     341            pjsip_auth_create_digest( &cred->response, &cred->nonce, 
     342                                      &cred->nc, cnonce, &pjsip_AUTH_STR, 
    343343                                      uri, &chal->realm, cred_info, method ); 
    344344        } 
     
    346346    } else { 
    347347        /* Server requires quality protection that we don't support. */ 
    348         PJ_LOG(4,(THIS_FILE, "Unsupported qop offer %.*s",  
     348        PJ_LOG(4,(THIS_FILE, "Unsupported qop offer %.*s", 
    349349                  chal->qop.slen, chal->qop.ptr)); 
    350350        return PJSIP_EINVALIDQOP; 
     
    358358 * Update authentication session with a challenge. 
    359359 */ 
    360 static void update_digest_session( pj_pool_t *ses_pool,  
     360static void update_digest_session( pj_pool_t *ses_pool, 
    361361                                   pjsip_cached_auth *cached_auth, 
    362362                                   const pjsip_www_authenticate_hdr *hdr ) 
     
    371371             * than the one in the cache, to reduce memory usage. 
    372372             */ 
    373             const pjsip_digest_challenge *d1 =  
     373            const pjsip_digest_challenge *d1 = 
    374374                        &cached_auth->last_chal->challenge.digest; 
    375375            const pjsip_digest_challenge *d2 = &hdr->challenge.digest; 
     
    407407        */ 
    408408        if (cached_auth->realm.slen == 0) { 
    409             pj_strdup(ses_pool, &cached_auth->realm,  
     409            pj_strdup(ses_pool, &cached_auth->realm, 
    410410                      &hdr->challenge.digest.realm); 
    411411        } 
     
    413413    } else { 
    414414        /* Update last_nonce and nonce-count */ 
    415         if (!pj_strcmp(&hdr->challenge.digest.nonce,  
    416                        &cached_auth->last_chal->challenge.digest.nonce))  
     415        if (!pj_strcmp(&hdr->challenge.digest.nonce, 
     416                       &cached_auth->last_chal->challenge.digest.nonce)) 
    417417        { 
    418418            /* Same nonce, increment nonce-count */ 
     
    424424            /* Has the opaque changed? */ 
    425425            if (pj_strcmp(&cached_auth->last_chal->challenge.digest.opaque, 
    426                           &hdr->challenge.digest.opaque))  
     426                          &hdr->challenge.digest.opaque)) 
    427427            { 
    428                 pj_strdup(ses_pool,  
     428                pj_strdup(ses_pool, 
    429429                          &cached_auth->last_chal->challenge.digest.opaque, 
    430430                          &hdr->challenge.digest.opaque); 
     
    485485PJ_DEF(pj_status_t) pjsip_auth_clt_init(  pjsip_auth_clt_sess *sess, 
    486486                                          pjsip_endpoint *endpt, 
    487                                           pj_pool_t *pool,  
     487                                          pj_pool_t *pool, 
    488488                                          unsigned options) 
    489489{ 
     
    510510 
    511511    pjsip_auth_clt_init(sess, (pjsip_endpoint*)rhs->endpt, pool, 0); 
    512      
     512 
    513513    sess->cred_cnt = rhs->cred_cnt; 
    514514    sess->cred_info = (pjsip_cred_info*) 
    515                       pj_pool_alloc(pool,  
     515                      pj_pool_alloc(pool, 
    516516                                    sess->cred_cnt*sizeof(pjsip_cred_info)); 
    517517    for (i=0; i<rhs->cred_cnt; ++i) { 
    518518        pj_strdup(pool, &sess->cred_info[i].realm, &rhs->cred_info[i].realm); 
    519519        pj_strdup(pool, &sess->cred_info[i].scheme, &rhs->cred_info[i].scheme); 
    520         pj_strdup(pool, &sess->cred_info[i].username,  
     520        pj_strdup(pool, &sess->cred_info[i].username, 
    521521                  &rhs->cred_info[i].username); 
    522522        sess->cred_info[i].data_type = rhs->cred_info[i].data_type; 
     
    553553            sess->cred_info[i].data_type = c[i].data_type; 
    554554 
    555             /* When data_type is PJSIP_CRED_DATA_EXT_AKA,  
     555            /* When data_type is PJSIP_CRED_DATA_EXT_AKA, 
    556556             * callback must be specified. 
    557557             */ 
     
    569569 
    570570                /* Verify K len */ 
    571                 PJ_ASSERT_RETURN(c[i].ext.aka.k.slen <= PJSIP_AKA_KLEN,  
     571                PJ_ASSERT_RETURN(c[i].ext.aka.k.slen <= PJSIP_AKA_KLEN, 
    572572                                 PJSIP_EAUTHINAKACRED); 
    573573 
    574574                /* Verify OP len */ 
    575                 PJ_ASSERT_RETURN(c[i].ext.aka.op.slen <= PJSIP_AKA_OPLEN,  
     575                PJ_ASSERT_RETURN(c[i].ext.aka.op.slen <= PJSIP_AKA_OPLEN, 
    576576                                 PJSIP_EAUTHINAKACRED); 
    577577 
     
    631631 
    632632 
    633 /*  
     633/* 
    634634 * Create Authorization/Proxy-Authorization response header based on the challege 
    635635 * in WWW-Authenticate/Proxy-Authenticate header. 
     
    786786    if (status != PJ_SUCCESS) 
    787787        return status; 
    788      
     788 
    789789    pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)hauth); 
    790790 
     
    832832    /* Get the method. */ 
    833833    method = &tdata->msg->line.req.method; 
     834    PJ_UNUSED_ARG(method); /* Warning about unused var caused by #if below */ 
    834835 
    835836    auth = sess->cached_auth.next; 
     
    870871#           endif 
    871872 
    872         }  
     873        } 
    873874#       if defined(PJSIP_AUTH_QOP_SUPPORT) && \ 
    874875           defined(PJSIP_AUTH_AUTO_SEND_NEXT) && \ 
    875876           (PJSIP_AUTH_QOP_SUPPORT && PJSIP_AUTH_AUTO_SEND_NEXT) 
    876877        else if (auth->qop_value == PJSIP_AUTH_QOP_AUTH) { 
    877             /* For qop="auth", we have to re-create the authorization header.  
     878            /* For qop="auth", we have to re-create the authorization header. 
    878879             */ 
    879880            const pjsip_cred_info *cred; 
     
    881882            pj_status_t status; 
    882883 
    883             cred = auth_find_cred(sess, &auth->realm,  
     884            cred = auth_find_cred(sess, &auth->realm, 
    884885                                  &auth->last_chal->scheme); 
    885886            if (!cred) { 
     
    888889            } 
    889890 
    890             status = auth_respond( tdata->pool, auth->last_chal,  
    891                                    tdata->msg->line.req.uri,  
     891            status = auth_respond( tdata->pool, auth->last_chal, 
     892                                   tdata->msg->line.req.uri, 
    892893                                   cred, 
    893894                                   &tdata->msg->line.req.method, 
     
    895896            if (status != PJ_SUCCESS) 
    896897                return status; 
    897              
     898 
    898899            //pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)hauth); 
    899900            pj_list_push_back(&added, hauth); 
     
    984985        { 
    985986            sent_auth = (pjsip_authorization_hdr*) hdr; 
    986             if (pj_stricmp(&hchal->challenge.common.realm,  
     987            if (pj_stricmp(&hchal->challenge.common.realm, 
    987988                           &sent_auth->credential.common.realm )==0) 
    988989            { 
     
    10551056 
    10561057    /* Find credential to be used for the challenge. */ 
    1057     cred = auth_find_cred( sess, &hchal->challenge.common.realm,  
     1058    cred = auth_find_cred( sess, &hchal->challenge.common.realm, 
    10581059                           &hchal->scheme); 
    10591060    if (!cred) { 
    10601061        const pj_str_t *realm = &hchal->challenge.common.realm; 
    1061         PJ_LOG(4,(THIS_FILE,  
     1062        PJ_LOG(4,(THIS_FILE, 
    10621063                  "Unable to set auth for %s: can not find credential for %.*s/%.*s", 
    1063                   tdata->obj_name,  
     1064                  tdata->obj_name, 
    10641065                  realm->slen, realm->ptr, 
    10651066                  hchal->scheme.slen, hchal->scheme.ptr)); 
     
    10681069 
    10691070    /* Respond to authorization challenge. */ 
    1070     status = auth_respond( req_pool, hchal, uri, cred,  
    1071                            &tdata->msg->line.req.method,  
     1071    status = auth_respond( req_pool, hchal, uri, cred, 
     1072                           &tdata->msg->line.req.method, 
    10721073                           sess->pool, cached_auth, h_auth); 
    10731074    return status; 
     
    11481149         * authorization session. 
    11491150         */ 
    1150         status = process_auth( tdata->pool, hchal, tdata->msg->line.req.uri,  
     1151        status = process_auth( tdata->pool, hchal, tdata->msg->line.req.uri, 
    11511152                               tdata, sess, cached_auth, &hauth); 
    11521153        if (status != PJ_SUCCESS) 
Note: See TracChangeset for help on using the changeset viewer.