Module: sip-router Branch: master Commit: e4a750639587056cbcad699980d0fe191a10a504 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e4a75063...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Sat Jun 11 11:21:49 2011 +0200
core: fix warnings/eliminate unused variables
Eliminate initialized, but unused variables (reported by gcc 4.6).
---
counters.c | 4 ++-- dns_cache.c | 2 -- events.c | 6 ++++-- mem/q_malloc.c | 10 +++++++--- msg_translator.c | 4 +++- parser/msg_parser.c | 4 ---- parser/parse_subscription_state.c | 3 +-- pvapi.c | 3 +-- rvalue.c | 2 -- switch.c | 7 +------ tcp_main.c | 2 -- tcp_read.c | 2 -- ut.h | 5 ----- 13 files changed, 19 insertions(+), 35 deletions(-)
diff --git a/counters.c b/counters.c index 56bcd2f..72a9b4e 100644 --- a/counters.c +++ b/counters.c @@ -202,10 +202,10 @@ int counters_prefork_init(int max_process_no) /* replace the temporary pre-fork pkg array (with only 1 row) with the final shm version (with max_process_no rows) */ old = _cnts_vals; - _cnts_vals = shm_malloc(max_process_no * row_size); + _cnts_vals = shm_malloc(size); if (_cnts_vals == 0) return -1; - memset(_cnts_vals, 0, max_process_no * row_size); + memset(_cnts_vals, 0, size); cnts_max_rows = max_process_no; /* copy prefork values into the newly shm array */ if (old) { diff --git a/dns_cache.c b/dns_cache.c index 22d1676..5a12ca1 100644 --- a/dns_cache.c +++ b/dns_cache.c @@ -2202,14 +2202,12 @@ inline static struct dns_rr* dns_entry_get_rr( struct dns_hash_entry* e, { struct dns_rr* rr; int n; - int flags; #ifdef DNS_WATCHDOG_SUPPORT int servers_up;
servers_up = atomic_get(dns_servers_up); #endif
- flags=0; for(rr=e->rr_lst, n=0;rr && (n<*no);rr=rr->next, n++);/* skip *no records*/ for(;rr;rr=rr->next){ if ( diff --git a/events.c b/events.c index 881da1d..fccfd1c 100644 --- a/events.c +++ b/events.c @@ -93,13 +93,15 @@ int sr_event_register_cb(int type, sr_event_cb_f f) int sr_event_exec(int type, void *data) { int ret; +#ifdef EXTRA_DEBUG str *p; +#endif /* EXTRA_DEBUG */ switch(type) { case SREV_NET_DATA_IN: if(unlikely(_sr_events_list.net_data_in!=0)) { - p = (str*)data; #ifdef EXTRA_DEBUG + p = (str*)data; LM_DBG("PRE-IN ++++++++++++++++++++++++++++++++\n" "%.*s\n+++++\n", p->len, p->s); #endif /* EXTRA_DEBUG */ @@ -114,8 +116,8 @@ int sr_event_exec(int type, void *data) case SREV_NET_DATA_OUT: if(unlikely(_sr_events_list.net_data_out!=0)) { - p = (str*)data; #ifdef EXTRA_DEBUG + p = (str*)data; LM_DBG("PRE-OUT ++++++++++++++++++++\n" "%.*s\n+++++++++++++++++++\n", p->len, p->s); #endif /* EXTRA_DEBUG */ diff --git a/mem/q_malloc.c b/mem/q_malloc.c index a90c1e6..7344f66 100644 --- a/mem/q_malloc.c +++ b/mem/q_malloc.c @@ -427,9 +427,11 @@ void qm_free(struct qm_block* qm, void* p) #endif { struct qm_frag* f; - struct qm_frag* prev; - struct qm_frag* next; unsigned long size; +#ifdef QM_JOIN_FREE + struct qm_frag* next; + struct qm_frag* prev; +#endif /* QM_JOIN_FREE*/
#ifdef DBG_QM_MALLOC MDBG("qm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line); @@ -443,7 +445,9 @@ void qm_free(struct qm_block* qm, void* p) LOG(L_WARN, "WARNING:qm_free: free(0) called\n"); return; } - prev=next=0; +#ifdef QM_JOIN_FREE + next=prev=0; +#endif /* QM_JOIN_FREE*/ f=(struct qm_frag*) ((char*)p-sizeof(struct qm_frag)); #ifdef DBG_QM_MALLOC qm_debug_frag(qm, f); diff --git a/msg_translator.c b/msg_translator.c index 8b60fa7..9b97794 100644 --- a/msg_translator.c +++ b/msg_translator.c @@ -2271,7 +2271,9 @@ char* via_builder( unsigned int *len, str* port_str; /* port no displayed in via */ struct socket_info* send_sock; int comp_len, comp_name_len; +#ifdef USE_COMP char* comp_name; +#endif /* USE_COMP */
send_sock=send_info->send_sock; /* use pre-set address in via or the outbound socket one */ @@ -2285,8 +2287,8 @@ char* via_builder( unsigned int *len, port_str=&(send_sock->port_no_str); comp_len=comp_name_len=0; - comp_name=0; #ifdef USE_COMP + comp_name=0; switch(send_info->comp){ case COMP_NONE: break; diff --git a/parser/msg_parser.c b/parser/msg_parser.c index 01bb40e..e138c7f 100644 --- a/parser/msg_parser.c +++ b/parser/msg_parser.c @@ -604,8 +604,6 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
char *tmp; char* rest; - char* first_via; - char* second_via; struct msg_start *fl; int offset; hdr_flags_t flags; @@ -654,8 +652,6 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg) } msg->unparsed=tmp; /*find first Via: */ - first_via=0; - second_via=0; if (parse_headers(msg, flags, 0)==-1) goto error;
#ifdef EXTRA_DEBUG diff --git a/parser/parse_subscription_state.c b/parser/parse_subscription_state.c index f7260bc..94a55e5 100644 --- a/parser/parse_subscription_state.c +++ b/parser/parse_subscription_state.c @@ -43,14 +43,13 @@ static int ss_parse(str *src, subscription_state_t *ss) param_t *params; str s = *src; str state; - char *c, *end; + char *c; /* initialization */ ss->expires_set = 0; ss->expires = 0; trim_leading(&s); - end = s.s + s.len; state = s; diff --git a/pvapi.c b/pvapi.c index f6c029c..b75f231 100644 --- a/pvapi.c +++ b/pvapi.c @@ -1012,7 +1012,7 @@ int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op, */ int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len) { - int n, h; + int n; pv_value_t tok; pv_elem_p it; char *cur; @@ -1026,7 +1026,6 @@ int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len) *buf = '\0'; cur = buf; - h = 0; n = 0; for (it=list; it; it=it->next) { diff --git a/rvalue.c b/rvalue.c index ea861e6..a3e158b 100644 --- a/rvalue.c +++ b/rvalue.c @@ -3424,14 +3424,12 @@ static int rve_optimize(struct rval_expr* rve) struct rvalue* rv; struct rvalue* trv; /* used only for DBG() */ enum rval_expr_op op; - int flags; struct rval_expr tmp_rve; enum rval_type type, l_type; struct rval_expr* bad_rve; enum rval_type bad_type, exp_type; ret=0; - flags=0; rv=0; if (scr_opt_lev<1) return 0; diff --git a/switch.c b/switch.c index b09d8ae..b254a7b 100644 --- a/switch.c +++ b/switch.c @@ -158,7 +158,6 @@ int fix_switch(struct action* t) struct action** tail; struct switch_jmp_table* jmp; struct switch_cond_table* sct; - int labels_no; struct action** def_jmp_bm; int* cond; struct action*** jmp_bm; @@ -170,7 +169,6 @@ int fix_switch(struct action* t) cond=0; jmp_bm=0; def_jmp_bm=0; - labels_no=0; default_found=0; /* check if string switch (first case is string or RE) */ for (c=(struct case_stms*)t->val[1].u.data; c && c->is_default; c=c->next); @@ -254,7 +252,6 @@ int fix_switch(struct action* t) goto error; } } - labels_no=n; cond=pkg_malloc(sizeof(cond[0])*n); jmp_bm=pkg_malloc(sizeof(jmp_bm[0])*n); if (cond==0 || jmp_bm==0){ @@ -432,7 +429,6 @@ static int fix_match(struct action* t) struct action* action_lst; struct action** tail; struct match_cond_table* mct; - int labels_no; struct action** def_jmp_bm; struct match_str* match; struct action*** jmp_bm; @@ -446,7 +442,6 @@ static int fix_match(struct action* t) match=0; jmp_bm=0; def_jmp_bm=0; - labels_no=0; default_found=0; rv=0; s.s=0; @@ -578,7 +573,7 @@ static int fix_match(struct action* t) goto error; } } - labels_no=n; + /* n is the number of labels here */ match=pkg_malloc(sizeof(match[0])*n); jmp_bm=pkg_malloc(sizeof(jmp_bm[0])*n); if (match==0 || jmp_bm==0){ diff --git a/tcp_main.c b/tcp_main.c index ac76dc5..5aa8638 100644 --- a/tcp_main.c +++ b/tcp_main.c @@ -1774,7 +1774,6 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from, int fd; long response[2]; int n; - int do_close_fd; ticks_t con_lifetime; #ifdef USE_TLS const char* rest_buf; @@ -1784,7 +1783,6 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from, snd_flags_t t_send_flags; #endif /* USE_TLS */ - do_close_fd=1; /* close the fd on exit */ port=su_getport(&dst->to); con_lifetime=cfg_get(tcp, tcp_cfg, con_lifetime); if (likely(port)){ diff --git a/tcp_read.c b/tcp_read.c index be67f9a..1ba6cbb 100644 --- a/tcp_read.c +++ b/tcp_read.c @@ -857,14 +857,12 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read, int* read_flags) long size; struct tcp_req* req; struct dest_info dst; - int s; char c; int ret; bytes=-1; total_bytes=0; resp=CONN_RELEASE; - s=con->fd; req=&con->req;
again: diff --git a/ut.h b/ut.h index da40ebc..04ce934 100644 --- a/ut.h +++ b/ut.h @@ -192,14 +192,12 @@ static inline unsigned short str2s(const char* s, unsigned int len, unsigned short ret; int i; unsigned char *limit; - unsigned char *init; unsigned char* str;
/*init*/ str=(unsigned char*)s; ret=i=0; limit=str+len; - init=str;
for(;str<limit ;str++){ if ( (*str <= '9' ) && (*str >= '0') ){ @@ -215,12 +213,9 @@ static inline unsigned short str2s(const char* s, unsigned int len, return ret;
error_digits: - /*DBG("str2s: ERROR: too many letters in [%.*s]\n", (int)len, init); */ if (err) *err=1; return 0; error_char: - /*DBG("str2s: ERROR: unexpected char %c in %.*s\n", *str, (int)len, init); - * */ if (err) *err=1; return 0; }