core: adjustments for cleaner compiler analyzing reports
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 20 Jul 2017 11:12:06 +0000 (13:12 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 20 Jul 2017 11:12:06 +0000 (13:12 +0200)
src/core/dns_cache.c
src/core/kemi.c
src/core/select_core.c
src/core/tcp_main.c
src/core/usr_avp.c

index d933300..7f3e338 100644 (file)
@@ -2929,7 +2929,6 @@ inline static int dns_a_resolve( struct dns_hash_entry** e,
                        goto error;
                /* found */
                *rr_no=0;
-               ret=-E_DNS_BAD_IP_ENTRY;
        }
        now=get_ticks_raw();
        /* if the entry has already expired use the time at the end of lifetime */
@@ -2978,7 +2977,6 @@ inline static int dns_aaaa_resolve( struct dns_hash_entry** e,
                        goto error;
                /* found */
                *rr_no=0;
-               ret=-E_DNS_BAD_IP_ENTRY;
        }
        now=get_ticks_raw();
        /* if the entry has already expired use the time at the end of lifetime */
@@ -3112,7 +3110,6 @@ inline static int dns_srv_resolve_nxt(struct dns_hash_entry** e,
                if (tried)
                        srv_reset_tried(tried);
 #endif
-               ret=-E_DNS_BAD_SRV_ENTRY;
        }
        now=get_ticks_raw();
        /* if the entry has already expired use the time at the end of lifetime */
@@ -4350,11 +4347,12 @@ int dns_cache_add_record(unsigned short type,
                                                break; /* insert here */
                                }
 
-                               if (!rr_p)
+                               if (!rr_p) {
                                        for (   rr_p = rr_iter;
                                                *rr_p && (*rr_p != new_rr);
                                                rr_p = &((*rr_p)->next)
                                        );
+                               }
                                if (!rr_p) {
                                        LM_ERR("Failed to correct the orderd list of SRV resource records\n");
                                        goto error;
index 941c814..fd25c15 100644 (file)
@@ -1161,10 +1161,10 @@ str *sr_kemi_param_map_get_params(int *ptypes)
                pn = sr_kemi_param_map_get_name(SR_KEMIP_NONE);
                if(pn == NULL)
                        return NULL;
-               if(pn->len<KEMI_PARAM_MAP_SIZE-1) strcat(pbuf, pn->s);
+               if(pn->len<KEMI_PARAM_MAP_SIZE-1) strncat(pbuf, pn->s, pn->len);
        }
 done:
        sret.s = pbuf;
        sret.len = strlen(sret.s);
        return &sret;
-}
+}
\ No newline at end of file
index 2aef431..d1f2ae7 100644 (file)
@@ -679,18 +679,7 @@ int select_anyheader(str* res, select_t* s, struct sip_msg* msg)
        return 0;
 }
 
-//ABSTRACT_F(select_anyheader_params)
-// Instead of ABSTRACT_F(select_anyheader_params)
-// use function which uses select_core_table
-// to avoid gcc warning about not used
-int select_anyheader_params(str* res, select_t* s, struct sip_msg* msg)
-{
-       if (select_core_table.next)
-               return -1;
-       else
-               return -1;
-}
+ABSTRACT_F(select_anyheader_params)
 
 ABSTRACT_F(select_any_uri)
 
@@ -1565,7 +1554,8 @@ int select_sys_now_fmt(str* res, select_t* s, struct sip_msg* msg)
                        tm = localtime(&t);
                        break;
                default:
-                       BUG("Unexpected parameter value 'now' \"%d\"\n", s->params[SEL_POS].v.i);
+                       BUG("Unexpected parameter value 'now' \"%d\" (%p)\n",
+                                       s->params[SEL_POS].v.i, select_core_table.next);
                        return -1;
        }
        if (s->n <= SEL_POS+1) {
index 75feb6d..06812db 100644 (file)
@@ -412,6 +412,10 @@ error:
 static int tcp_safe_close(int s)
 {
        int ret;
+
+       if(s<0)
+               return 0;
+
 retry:
        if (unlikely((ret = close(s)) < 0 )) {
                switch(errno) {
@@ -3066,8 +3070,8 @@ static int send_fd_queue_init(struct tcp_send_fd_q *q, unsigned int size)
                LM_ERR("out of memory\n");
                return -1;
        }
-       q->crt=&q->data[0];
-       q->end=&q->data[size];
+       q->crt=q->data;
+       q->end=q->data+size;
        return 0;
 }
 
@@ -3126,9 +3130,9 @@ inline static int send_fd_queue_add(      struct tcp_send_fd_q* q,
                        LM_ERR("out of memory\n");
                        goto error;
                }
-               q->crt=(q->crt-&q->data[0])+tmp;
+               q->crt=(q->crt-q->data)+tmp;
                q->data=tmp;
-               q->end=&q->data[new_size];
+               q->end=q->data + new_size;
        }
        q->crt->tcp_conn=t;
        q->crt->unix_sock=unix_sock;
index 96b877b..fc08cad 100644 (file)
@@ -432,7 +432,10 @@ avp_t *search_avp (avp_ident_t ident, avp_value_t* val, struct search_state* sta
                        break;
        }
 
-       if (!state) state = &st;
+       if (!state) {
+               memset(&st, 0, sizeof(struct search_state));
+               state = &st;
+       }
 
        if ((ident.flags & AVP_CLASS_ALL) == 0) {
                     /* The caller did not specify any class to search in, so enable
@@ -455,16 +458,18 @@ avp_t *search_avp (avp_ident_t ident, avp_value_t* val, struct search_state* sta
        state->avp = *list;
        state->name = ident.name;
 
-       if (ident.flags & AVP_NAME_STR) {
+       if(ident.flags & AVP_NAME_STR) {
                state->id = compute_ID(&ident.name.s);
        }
 
-        ret = search_next_avp(state, val);
+       ret = search_next_avp(state, val);
 
-            /* Make sure that search next avp stays in the same class as the first
-             * avp found
-             */
-       if (state && ret) state->flags = (ident.flags & ~AVP_CLASS_ALL) | (ret->flags & AVP_CLASS_ALL);
+       /* Make sure that search next avp stays in the same class as the first
+        * avp found */
+       if(ret) {
+               state->flags =
+                               (ident.flags & ~AVP_CLASS_ALL) | (ret->flags & AVP_CLASS_ALL);
+       }
        return ret;
 }