Преглед изворни кода

core: fix warnings/eliminate unused variables

Eliminate initialized, but unused variables (reported by gcc 4.6).
Andrei Pelinescu-Onciul пре 14 година
родитељ
комит
e4a7506395
13 измењених фајлова са 19 додато и 35 уклоњено
  1. 2 2
      counters.c
  2. 0 2
      dns_cache.c
  3. 4 2
      events.c
  4. 7 3
      mem/q_malloc.c
  5. 3 1
      msg_translator.c
  6. 0 4
      parser/msg_parser.c
  7. 1 2
      parser/parse_subscription_state.c
  8. 1 2
      pvapi.c
  9. 0 2
      rvalue.c
  10. 1 6
      switch.c
  11. 0 2
      tcp_main.c
  12. 0 2
      tcp_read.c
  13. 0 5
      ut.h

+ 2 - 2
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) {

+ 0 - 2
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 (

+ 4 - 2
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 */

+ 7 - 3
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);

+ 3 - 1
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;

+ 0 - 4
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

+ 1 - 2
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;
 	

+ 1 - 2
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)
 	{

+ 0 - 2
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;

+ 1 - 6
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){

+ 0 - 2
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)){

+ 0 - 2
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:

+ 0 - 5
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;
 }