Browse code

core: fix warnings/eliminate unused variables

Eliminate initialized, but unused variables (reported by gcc 4.6).

Andrei Pelinescu-Onciul authored on 11/06/2011 09:21:49
Showing 13 changed files
... ...
@@ -202,10 +202,10 @@ int counters_prefork_init(int max_process_no)
202 202
 	/* replace the temporary pre-fork pkg array (with only 1 row) with
203 203
 	   the final shm version (with max_process_no rows) */
204 204
 	old = _cnts_vals;
205
-	_cnts_vals = shm_malloc(max_process_no * row_size);
205
+	_cnts_vals = shm_malloc(size);
206 206
 	if (_cnts_vals == 0)
207 207
 		return -1;
208
-	memset(_cnts_vals, 0, max_process_no * row_size);
208
+	memset(_cnts_vals, 0, size);
209 209
 	cnts_max_rows = max_process_no;
210 210
 	/* copy prefork values into the newly shm array */
211 211
 	if (old) {
... ...
@@ -2202,14 +2202,12 @@ inline static struct dns_rr* dns_entry_get_rr(	struct dns_hash_entry* e,
2202 2202
 {
2203 2203
 	struct dns_rr* rr;
2204 2204
 	int n;
2205
-	int flags;
2206 2205
 #ifdef DNS_WATCHDOG_SUPPORT
2207 2206
 	int servers_up;
2208 2207
 
2209 2208
 	servers_up = atomic_get(dns_servers_up);
2210 2209
 #endif
2211 2210
 
2212
-	flags=0;
2213 2211
 	for(rr=e->rr_lst, n=0;rr && (n<*no);rr=rr->next, n++);/* skip *no records*/
2214 2212
 	for(;rr;rr=rr->next){
2215 2213
 		if (
... ...
@@ -93,13 +93,15 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
93 93
 int sr_event_exec(int type, void *data)
94 94
 {
95 95
 	int ret;
96
+#ifdef EXTRA_DEBUG
96 97
 	str *p;
98
+#endif /* EXTRA_DEBUG */
97 99
 	switch(type) {
98 100
 		case SREV_NET_DATA_IN:
99 101
 				if(unlikely(_sr_events_list.net_data_in!=0))
100 102
 				{
101
-					p = (str*)data;
102 103
 #ifdef EXTRA_DEBUG
104
+					p = (str*)data;
103 105
 					LM_DBG("PRE-IN ++++++++++++++++++++++++++++++++\n"
104 106
 							"%.*s\n+++++\n", p->len, p->s);
105 107
 #endif /* EXTRA_DEBUG */
... ...
@@ -114,8 +116,8 @@ int sr_event_exec(int type, void *data)
114 114
 		case SREV_NET_DATA_OUT:
115 115
 				if(unlikely(_sr_events_list.net_data_out!=0))
116 116
 				{
117
-					p = (str*)data;
118 117
 #ifdef EXTRA_DEBUG
118
+					p = (str*)data;
119 119
 					LM_DBG("PRE-OUT ++++++++++++++++++++\n"
120 120
 							"%.*s\n+++++++++++++++++++\n", p->len, p->s);
121 121
 #endif /* EXTRA_DEBUG */
... ...
@@ -427,9 +427,11 @@ void qm_free(struct qm_block* qm, void* p)
427 427
 #endif
428 428
 {
429 429
 	struct qm_frag* f;
430
-	struct qm_frag* prev;
431
-	struct qm_frag* next;
432 430
 	unsigned long size;
431
+#ifdef QM_JOIN_FREE
432
+	struct qm_frag* next;
433
+	struct qm_frag* prev;
434
+#endif /* QM_JOIN_FREE*/
433 435
 
434 436
 #ifdef DBG_QM_MALLOC
435 437
 	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)
443 443
 		LOG(L_WARN, "WARNING:qm_free: free(0) called\n");
444 444
 		return;
445 445
 	}
446
-	prev=next=0;
446
+#ifdef QM_JOIN_FREE
447
+	next=prev=0;
448
+#endif /* QM_JOIN_FREE*/
447 449
 	f=(struct qm_frag*) ((char*)p-sizeof(struct qm_frag));
448 450
 #ifdef DBG_QM_MALLOC
449 451
 	qm_debug_frag(qm, f);
... ...
@@ -2271,7 +2271,9 @@ char* via_builder( unsigned int *len,
2271 2271
 	str* port_str; /* port no displayed in via */
2272 2272
 	struct socket_info* send_sock;
2273 2273
 	int comp_len, comp_name_len;
2274
+#ifdef USE_COMP
2274 2275
 	char* comp_name;
2276
+#endif /* USE_COMP */
2275 2277
 
2276 2278
 	send_sock=send_info->send_sock;
2277 2279
 	/* use pre-set address in via or the outbound socket one */
... ...
@@ -2285,8 +2287,8 @@ char* via_builder( unsigned int *len,
2285 2285
 		port_str=&(send_sock->port_no_str);
2286 2286
 	
2287 2287
 	comp_len=comp_name_len=0;
2288
-	comp_name=0;
2289 2288
 #ifdef USE_COMP
2289
+	comp_name=0;
2290 2290
 	switch(send_info->comp){
2291 2291
 		case COMP_NONE:
2292 2292
 			break;
... ...
@@ -604,8 +604,6 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
604 604
 
605 605
 	char *tmp;
606 606
 	char* rest;
607
-	char* first_via;
608
-	char* second_via;
609 607
 	struct msg_start *fl;
610 608
 	int offset;
611 609
 	hdr_flags_t flags;
... ...
@@ -654,8 +652,6 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
654 654
 	}
655 655
 	msg->unparsed=tmp;
656 656
 	/*find first Via: */
657
-	first_via=0;
658
-	second_via=0;
659 657
 	if (parse_headers(msg, flags, 0)==-1) goto error;
660 658
 
661 659
 #ifdef EXTRA_DEBUG
... ...
@@ -43,14 +43,13 @@ static int ss_parse(str *src, subscription_state_t *ss)
43 43
 	param_t *params;
44 44
 	str s = *src;
45 45
 	str state;
46
-	char *c, *end;
46
+	char *c;
47 47
 	
48 48
 	/* initialization */
49 49
 	ss->expires_set = 0;
50 50
 	ss->expires = 0;
51 51
 	
52 52
 	trim_leading(&s);
53
-	end = s.s + s.len;
54 53
 		
55 54
 	state = s;
56 55
 	
... ...
@@ -1012,7 +1012,7 @@ int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op,
1012 1012
  */
1013 1013
 int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len)
1014 1014
 {
1015
-	int n, h;
1015
+	int n;
1016 1016
 	pv_value_t tok;
1017 1017
 	pv_elem_p it;
1018 1018
 	char *cur;
... ...
@@ -1026,7 +1026,6 @@ int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len)
1026 1026
 	*buf = '\0';
1027 1027
 	cur = buf;
1028 1028
 	
1029
-	h = 0;
1030 1029
 	n = 0;
1031 1030
 	for (it=list; it; it=it->next)
1032 1031
 	{
... ...
@@ -3424,14 +3424,12 @@ static int rve_optimize(struct rval_expr* rve)
3424 3424
 	struct rvalue* rv;
3425 3425
 	struct rvalue* trv; /* used only for DBG() */
3426 3426
 	enum rval_expr_op op;
3427
-	int flags;
3428 3427
 	struct rval_expr tmp_rve;
3429 3428
 	enum rval_type type, l_type;
3430 3429
 	struct rval_expr* bad_rve;
3431 3430
 	enum rval_type bad_type, exp_type;
3432 3431
 	
3433 3432
 	ret=0;
3434
-	flags=0;
3435 3433
 	rv=0;
3436 3434
 	if (scr_opt_lev<1)
3437 3435
 		return 0;
... ...
@@ -158,7 +158,6 @@ int fix_switch(struct action* t)
158 158
 	struct action** tail;
159 159
 	struct switch_jmp_table* jmp;
160 160
 	struct switch_cond_table* sct;
161
-	int labels_no;
162 161
 	struct action** def_jmp_bm;
163 162
 	int* cond;
164 163
 	struct action*** jmp_bm;
... ...
@@ -170,7 +169,6 @@ int fix_switch(struct action* t)
170 170
 	cond=0;
171 171
 	jmp_bm=0;
172 172
 	def_jmp_bm=0;
173
-	labels_no=0;
174 173
 	default_found=0;
175 174
 	/* check if string switch (first case is string or RE) */
176 175
 	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)
254 254
 			goto error;
255 255
 		}
256 256
 	}
257
-	labels_no=n;
258 257
 	cond=pkg_malloc(sizeof(cond[0])*n);
259 258
 	jmp_bm=pkg_malloc(sizeof(jmp_bm[0])*n);
260 259
 	if (cond==0 || jmp_bm==0){
... ...
@@ -432,7 +429,6 @@ static int fix_match(struct action* t)
432 432
 	struct action* action_lst;
433 433
 	struct action** tail;
434 434
 	struct match_cond_table* mct;
435
-	int labels_no;
436 435
 	struct action** def_jmp_bm;
437 436
 	struct match_str* match;
438 437
 	struct action*** jmp_bm;
... ...
@@ -446,7 +442,6 @@ static int fix_match(struct action* t)
446 446
 	match=0;
447 447
 	jmp_bm=0;
448 448
 	def_jmp_bm=0;
449
-	labels_no=0;
450 449
 	default_found=0;
451 450
 	rv=0;
452 451
 	s.s=0;
... ...
@@ -578,7 +573,7 @@ static int fix_match(struct action* t)
578 578
 			goto error;
579 579
 		}
580 580
 	}
581
-	labels_no=n;
581
+	/* n is the number of labels here */
582 582
 	match=pkg_malloc(sizeof(match[0])*n);
583 583
 	jmp_bm=pkg_malloc(sizeof(jmp_bm[0])*n);
584 584
 	if (match==0 || jmp_bm==0){
... ...
@@ -1774,7 +1774,6 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1774 1774
 	int fd;
1775 1775
 	long response[2];
1776 1776
 	int n;
1777
-	int do_close_fd;
1778 1777
 	ticks_t con_lifetime;
1779 1778
 #ifdef USE_TLS
1780 1779
 	const char* rest_buf;
... ...
@@ -1784,7 +1783,6 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1784 1784
 	snd_flags_t t_send_flags;
1785 1785
 #endif /* USE_TLS */
1786 1786
 	
1787
-	do_close_fd=1; /* close the fd on exit */
1788 1787
 	port=su_getport(&dst->to);
1789 1788
 	con_lifetime=cfg_get(tcp, tcp_cfg, con_lifetime);
1790 1789
 	if (likely(port)){
... ...
@@ -857,14 +857,12 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read, int* read_flags)
857 857
 	long size;
858 858
 	struct tcp_req* req;
859 859
 	struct dest_info dst;
860
-	int s;
861 860
 	char c;
862 861
 	int ret;
863 862
 		
864 863
 		bytes=-1;
865 864
 		total_bytes=0;
866 865
 		resp=CONN_RELEASE;
867
-		s=con->fd;
868 866
 		req=&con->req;
869 867
 
870 868
 again:
... ...
@@ -192,14 +192,12 @@ static inline unsigned short str2s(const char* s, unsigned int len,
192 192
 	unsigned short ret;
193 193
 	int i;
194 194
 	unsigned char *limit;
195
-	unsigned char *init;
196 195
 	unsigned char* str;
197 196
 
198 197
 	/*init*/
199 198
 	str=(unsigned char*)s;
200 199
 	ret=i=0;
201 200
 	limit=str+len;
202
-	init=str;
203 201
 
204 202
 	for(;str<limit ;str++){
205 203
 		if ( (*str <= '9' ) && (*str >= '0') ){
... ...
@@ -215,12 +213,9 @@ static inline unsigned short str2s(const char* s, unsigned int len,
215 215
 	return ret;
216 216
 
217 217
 error_digits:
218
-	/*DBG("str2s: ERROR: too many letters in [%.*s]\n", (int)len, init); */
219 218
 	if (err) *err=1;
220 219
 	return 0;
221 220
 error_char:
222
-	/*DBG("str2s: ERROR: unexpected char %c in %.*s\n", *str, (int)len, init);
223
-	 * */
224 221
 	if (err) *err=1;
225 222
 	return 0;
226 223
 }