Browse code

- fixed all the warnings in core (now it compiles cleanly on linux/i386, solaris/sparc64, netbsd/sparc64, freebsd/i386, openbsd/i386).

Andrei Pelinescu-Onciul authored on 26/11/2002 15:29:51
Showing 10 changed files
... ...
@@ -536,7 +536,8 @@ ifeq ($(OS), freebsd)
536 536
 endif
537 537
 
538 538
 ifeq ($(OS), openbsd)
539
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DDLSYM_PREFIX='"_"' -DHAVE_GETHOSTBYNAME2 
539
+	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DDLSYM_PREFIX='"_"' -DHAVE_GETHOSTBYNAME2 \
540
+		-DHAVE_UNION_SEMUN
540 541
 	# (symbols on openbsd are prefixed by "_")
541 542
 	YACC=yacc
542 543
 	# no sched_yield on openbsd unless linking with c_r (not recommended)
... ...
@@ -48,8 +48,8 @@ struct id_list* lst_tmp;
48 48
 %}
49 49
 
50 50
 %union {
51
-	int intval;
52
-	unsigned uval;
51
+	long intval;
52
+	unsigned long uval;
53 53
 	char* strval;
54 54
 	struct expr* expr;
55 55
 	struct action* action;
... ...
@@ -479,7 +479,7 @@ int open_fifo_server()
479 479
 	t=ctime(&up_since);
480 480
 	if (strlen(t)+1>=MAX_CTIME_LEN) {
481 481
 		LOG(L_ERR, "ERROR: open_fifo_server: "
482
-			"too long date %d\n", strlen(t));
482
+			"too long date %d\n", (int)strlen(t));
483 483
 		return -1;
484 484
 	}
485 485
 	memcpy(up_since_ctime,t,strlen(t)+1);
... ...
@@ -35,7 +35,7 @@ enum { FL_WHITE=1, FL_YELLOW, FL_GREEN, FL_RED, FL_BLUE, FL_MAGENTA,
35 35
 
36 36
 typedef unsigned int flag_t;
37 37
 
38
-#define MAX_FLAG  ( sizeof(flag_t) * CHAR_BIT - 1 )
38
+#define MAX_FLAG  ((unsigned int)( sizeof(flag_t) * CHAR_BIT - 1 ))
39 39
 
40 40
 struct sip_msg;
41 41
 
... ...
@@ -116,7 +116,7 @@ struct fm_block* fm_malloc_init(char* address, unsigned int size)
116 116
 	unsigned int init_overhead;
117 117
 	
118 118
 	/* make address and size multiple of 8*/
119
-	start=(char*)ROUNDUP((unsigned int) address);
119
+	start=(char*)ROUNDUP((unsigned long) address);
120 120
 	if (size<start-address) return 0;
121 121
 	size-=(start-address);
122 122
 	if (size <(MIN_FRAG_SIZE+FRAG_OVERHEAD)) return 0;
... ...
@@ -285,12 +285,12 @@ void fm_status(struct fm_block* qm)
285 285
 	struct fm_frag* f;
286 286
 	int i,j;
287 287
 	int h;
288
-	int size;
288
+	long size;
289 289
 
290 290
 	LOG(memlog, "fm_status (%p):\n", qm);
291 291
 	if (!qm) return;
292 292
 
293
-	LOG(memlog, " heap size= %d\n", qm->size);
293
+	LOG(memlog, " heap size= %ld\n", qm->size);
294 294
 #ifdef DBG_F_MALLOC
295 295
 	LOG(memlog, " used= %d, used+overhead=%d, free=%d\n",
296 296
 			qm->used, qm->real_used, qm->size-qm->real_used);
... ...
@@ -314,7 +314,7 @@ void fm_status(struct fm_block* qm)
314 314
 		
315 315
 		for (f=qm->free_hash[h],j=0; f; size+=f->size,f=f->u.nxt_free,i++,j++);
316 316
 		if (j) LOG(memlog, "hash = %3d fragments no.: %5d,\n\t\t"
317
-							" bucket size: %9d - %9d (first %9d)\n",
317
+							" bucket size: %9d - %9d (first %9ld)\n",
318 318
 							h, j, UN_HASH(h),
319 319
 							((h<F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
320 320
 							qm->free_hash[h]->size
... ...
@@ -332,7 +332,7 @@ void fm_status(struct fm_block* qm)
332 332
 		}
333 333
 	*/
334 334
 	}
335
-	LOG(memlog, "TOTAL: %6d free fragments = %6d free bytes\n", i, size);
335
+	LOG(memlog, "TOTAL: %6d free fragments = %6ld free bytes\n", i, size);
336 336
 	LOG(memlog, "-----------------------------\n");
337 337
 }
338 338
 
... ...
@@ -97,14 +97,14 @@ inline static int big_hash_idx(int s)
97 97
 static  void qm_debug_frag(struct qm_block* qm, struct qm_frag* f)
98 98
 {
99 99
 	if (f->check!=ST_CHECK_PATTERN){
100
-		LOG(L_CRIT, "BUG: qm_*: fragm. %p beginning overwritten(%x)!\n",
100
+		LOG(L_CRIT, "BUG: qm_*: fragm. %p beginning overwritten(%lx)!\n",
101 101
 				f, f->check);
102 102
 		qm_status(qm);
103 103
 		abort();
104 104
 	};
105 105
 	if ((FRAG_END(f)->check1!=END_CHECK_PATTERN1)||
106 106
 		(FRAG_END(f)->check2!=END_CHECK_PATTERN2)){
107
-		LOG(L_CRIT, "BUG: qm_*: fragm. %p end overwritten(%x, %x)!\n",
107
+		LOG(L_CRIT, "BUG: qm_*: fragm. %p end overwritten(%lx, %lx)!\n",
108 108
 				f, FRAG_END(f)->check1, FRAG_END(f)->check2);
109 109
 		qm_status(qm);
110 110
 		abort();
... ...
@@ -112,8 +112,8 @@ static  void qm_debug_frag(struct qm_block* qm, struct qm_frag* f)
112 112
 	if ((f>qm->first_frag)&&
113 113
 			((PREV_FRAG_END(f)->check1!=END_CHECK_PATTERN1) ||
114 114
 				(PREV_FRAG_END(f)->check2!=END_CHECK_PATTERN2) ) ){
115
-		LOG(L_CRIT, "BUG: qm_*: prev. fragm. tail overwritten(%x, %x)[%p]!\n",
116
-				PREV_FRAG_END(f)->check1, PREV_FRAG_END(f)->check2, f);
115
+		LOG(L_CRIT, "BUG: qm_*: prev. fragm. tail overwritten(%lx, %lx)[%p]!\n"
116
+				,PREV_FRAG_END(f)->check1, PREV_FRAG_END(f)->check2, f);
117 117
 		qm_status(qm);
118 118
 		abort();
119 119
 	}
... ...
@@ -154,10 +154,10 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
154 154
 	
155 155
 	/* make address and size multiple of 8*/
156 156
 	start=(char*)ROUNDUP((unsigned long) address);
157
-	DBG("qm_malloc_init: QM_OPTIMIZE=%d, /ROUNDTO=%d\n",
157
+	DBG("qm_malloc_init: QM_OPTIMIZE=%ld, /ROUNDTO=%ld\n",
158 158
 			QM_MALLOC_OPTIMIZE, QM_MALLOC_OPTIMIZE/ROUNDTO);
159
-	DBG("qm_malloc_init: QM_HASH_SIZE=%d, qm_block size=%d\n",
160
-			QM_HASH_SIZE, sizeof(struct qm_block));
159
+	DBG("qm_malloc_init: QM_HASH_SIZE=%ld, qm_block size=%d\n",
160
+			QM_HASH_SIZE, (int)sizeof(struct qm_block));
161 161
 	DBG("qm_malloc_init(%p, %d), start=%p\n", address, size, start);
162 162
 	if (size<start-address) return 0;
163 163
 	size-=(start-address);
... ...
@@ -166,7 +166,7 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
166 166
 	
167 167
 	init_overhead=ROUNDUP(sizeof(struct qm_block))+sizeof(struct qm_frag)+
168 168
 		sizeof(struct qm_frag_end);
169
-	DBG("qm_malloc_init: size= %d, init_overhead=%d\n", size, init_overhead);
169
+	DBG("qm_malloc_init: size= %d, init_overhead=%ld\n", size, init_overhead);
170 170
 	
171 171
 	if (size < init_overhead)
172 172
 	{
... ...
@@ -339,7 +339,7 @@ void qm_free(struct qm_block* qm, void* p)
339 339
 	struct qm_frag* f;
340 340
 	struct qm_frag* prev;
341 341
 	struct qm_frag* next;
342
-	unsigned int size;
342
+	unsigned long size;
343 343
 
344 344
 #ifdef DBG_QM_MALLOC
345 345
 	DBG("qm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line);
... ...
@@ -359,11 +359,11 @@ void qm_free(struct qm_block* qm, void* p)
359 359
 	qm_debug_frag(qm, f);
360 360
 	if (f->u.is_free){
361 361
 		LOG(L_CRIT, "BUG: qm_free: freeing already freed pointer,"
362
-				" first free: %s: %s(%d) - aborting\n",
362
+				" first free: %s: %s(%ld) - aborting\n",
363 363
 				f->file, f->func, f->line);
364 364
 		abort();
365 365
 	}
366
-	DBG("qm_free: freeing block alloc'ed from %s: %s(%d)\n", f->file, f->func,
366
+	DBG("qm_free: freeing block alloc'ed from %s: %s(%ld)\n", f->file, f->func,
367 367
 			f->line);
368 368
 #endif
369 369
 	size=f->size;
... ...
@@ -420,22 +420,22 @@ void qm_status(struct qm_block* qm)
420 420
 	LOG(memlog, "qm_status (%p):\n", qm);
421 421
 	if (!qm) return;
422 422
 
423
-	LOG(memlog, " heap size= %d\n", qm->size);
424
-	LOG(memlog, " used= %d, used+overhead=%d, free=%d\n",
423
+	LOG(memlog, " heap size= %ld\n", qm->size);
424
+	LOG(memlog, " used= %ld, used+overhead=%ld, free=%ld\n",
425 425
 			qm->used, qm->real_used, qm->size-qm->real_used);
426
-	LOG(memlog, " max used (+overhead)= %d\n", qm->max_real_used);
426
+	LOG(memlog, " max used (+overhead)= %ld\n", qm->max_real_used);
427 427
 	
428 428
 	LOG(memlog, "dumping all allocked. fragments:\n");
429 429
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
430 430
 			,i++){
431 431
 		if (! f->u.is_free){
432
-			LOG(memlog, "    %3d. %c  address=%p  size=%d\n", i, 
432
+			LOG(memlog, "    %3d. %c  address=%p  size=%ld\n", i, 
433 433
 				(f->u.is_free)?'a':'N',
434 434
 				(char*)f+sizeof(struct qm_frag), f->size);
435 435
 #ifdef DBG_QM_MALLOC
436
-			LOG(memlog, "            %s from %s: %s(%d)\n",
436
+			LOG(memlog, "            %s from %s: %s(%ld)\n",
437 437
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
438
-			LOG(memlog, "        start check=%x, end check= %x, %x\n",
438
+			LOG(memlog, "        start check=%lx, end check= %lx, %lx\n",
439 439
 				f->check, FRAG_END(f)->check1, FRAG_END(f)->check2);
440 440
 #endif
441 441
 		}
... ...
@@ -46,13 +46,13 @@
46 46
 
47 47
 
48 48
 #define QM_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
49
-#define QM_MALLOC_OPTIMIZE  (1<<QM_MALLOC_OPTIMIZE_FACTOR)
49
+#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1<<QM_MALLOC_OPTIMIZE_FACTOR))
50 50
 								/* size to optimize for,
51 51
 									(most allocs < this size),
52 52
 									must be 2^k */
53 53
 
54
-#define QM_HASH_SIZE (QM_MALLOC_OPTIMIZE/ROUNDTO + \
55
-		(32-QM_MALLOC_OPTIMIZE_FACTOR)+1)
54
+#define QM_HASH_SIZE ((unsigned long)(QM_MALLOC_OPTIMIZE/ROUNDTO + \
55
+		(32-QM_MALLOC_OPTIMIZE_FACTOR)+1))
56 56
 
57 57
 /* hash structure:
58 58
  * 0 .... QM_MALLOC_OPTIMIE/ROUNDTO  - small buckets, size increases with
... ...
@@ -58,7 +58,7 @@ int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val)
58 58
 		break;
59 59
 
60 60
 	case INT_PARAM:
61
-		*((int*)ptr) = (int)_val;
61
+		*((int*)ptr) = (int)(long)_val;
62 62
 		break;
63 63
 	}
64 64
 
... ...
@@ -149,7 +149,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
149 149
 					default:
150 150
 						LOG( L_ERR , "ERROR: parse_to_param : "
151 151
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
152
-							*tmp,status, tmp-buffer, buffer);
152
+							*tmp,status, (int)(tmp-buffer), buffer);
153 153
 				}
154 154
 				break;
155 155
 			case '\r':
... ...
@@ -187,7 +187,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
187 187
 					default:
188 188
 						LOG( L_ERR , "ERROR: parse_to_param : "
189 189
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
190
-							*tmp,status, tmp-buffer, buffer);
190
+							*tmp,status, (int)(tmp-buffer), buffer);
191 191
 						goto error;
192 192
 				}
193 193
 				break;
... ...
@@ -206,7 +206,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
206 206
 					default:
207 207
 						LOG( L_ERR , "ERROR: parse_to_param : "
208 208
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
209
-							*tmp,status, tmp-buffer, buffer);
209
+							*tmp,status, (int)(tmp-buffer), buffer);
210 210
 						goto error;
211 211
 				}
212 212
 				break;
... ...
@@ -231,7 +231,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
231 231
 					default:
232 232
 						LOG( L_ERR , "ERROR: parse_to_param :"
233 233
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
234
-							*tmp,status, tmp-buffer, buffer);
234
+							*tmp,status,(int)(tmp-buffer), buffer);
235 235
 						goto error;
236 236
 				}
237 237
 				break;
... ...
@@ -251,7 +251,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
251 251
 						else {
252 252
 							LOG( L_ERR , "ERROR: parse_to_param : unexpected "
253 253
 								"char [%c] in status %d: <<%.*s>> .\n",
254
-								*tmp,status, tmp-buffer, buffer);
254
+								*tmp,status, (int)(tmp-buffer), buffer);
255 255
 							goto error;
256 256
 						}
257 257
 #endif
... ...
@@ -280,7 +280,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
280 280
 					default:
281 281
 						LOG( L_ERR , "ERROR: parse_to_param :"
282 282
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
283
-							*tmp,status, tmp-buffer, buffer);
283
+							*tmp,status, (int)(tmp-buffer), buffer);
284 284
 						goto error;
285 285
 				}
286 286
 				break;
... ...
@@ -313,7 +313,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
313 313
 					default:
314 314
 						LOG( L_ERR , "ERROR: parse_to_param :"
315 315
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
316
-							*tmp,status, tmp-buffer, buffer);
316
+							*tmp,status, (int)(tmp-buffer), buffer);
317 317
 						goto error;
318 318
 				}
319 319
 				break;
... ...
@@ -348,7 +348,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
348 348
 					default:
349 349
 						LOG( L_ERR , "ERROR: parse_to_param : "
350 350
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
351
-							*tmp,status, tmp-buffer, buffer);
351
+							*tmp,status, (int)(tmp-buffer), buffer);
352 352
 						goto error;
353 353
 				}
354 354
 				break;
... ...
@@ -383,7 +383,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
383 383
 					default:
384 384
 						LOG( L_ERR , "ERROR: parse_to_param : "
385 385
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
386
-							*tmp,status, tmp-buffer, buffer);
386
+							*tmp,status, (int)(tmp-buffer), buffer);
387 387
 						goto error;
388 388
 				}
389 389
 				break;
... ...
@@ -412,7 +412,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
412 412
 					default:
413 413
 						LOG( L_ERR , "ERROR: parse_to_param : "
414 414
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
415
-							*tmp,status, tmp-buffer, buffer);
415
+							*tmp,status, (int)(tmp-buffer), buffer);
416 416
 						goto error;
417 417
 				}
418 418
 				break;
... ...
@@ -526,7 +526,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
526 526
 					default:
527 527
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
528 528
 							"in status %d: <<%.*s>> .\n",
529
-							*tmp,status, tmp-buffer, buffer);
529
+							*tmp,status, (int)(tmp-buffer), buffer);
530 530
 				}
531 531
 				break;
532 532
 			case '\r':
... ...
@@ -550,7 +550,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
550 550
 					default:
551 551
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
552 552
 							"in status %d: <<%.*s>> .\n",
553
-							*tmp,status, tmp-buffer, buffer);
553
+							*tmp,status, (int)(tmp-buffer), buffer);
554 554
 						goto error;
555 555
 				}
556 556
 				break;
... ...
@@ -569,7 +569,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
569 569
 					default:
570 570
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
571 571
 							"in status %d: <<%.*s>> .\n",
572
-							*tmp,status, tmp-buffer, buffer);
572
+							*tmp,status, (int)(tmp-buffer), buffer);
573 573
 						goto error;
574 574
 				}
575 575
 				break;
... ...
@@ -596,7 +596,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
596 596
 					default:
597 597
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
598 598
 							"in status %d: <<%.*s>> .\n",
599
-							*tmp,status, tmp-buffer, buffer);
599
+							*tmp,status, (int)(tmp-buffer), buffer);
600 600
 						goto error;
601 601
 				}
602 602
 				break;
... ...
@@ -620,7 +620,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
620 620
 					default:
621 621
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
622 622
 							"in status %d: <<%.*s>> .\n",
623
-							*tmp,status, tmp-buffer, buffer);
623
+							*tmp,status, (int)(tmp-buffer), buffer);
624 624
 						goto error;
625 625
 				}
626 626
 				break;
... ...
@@ -642,7 +642,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
642 642
 					default:
643 643
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
644 644
 							"in status %d: <<%.*s>> .\n",
645
-							*tmp,status, tmp-buffer, buffer);
645
+							*tmp,status, (int)(tmp-buffer), buffer);
646 646
 						goto error;
647 647
 				}
648 648
 				break;
... ...
@@ -669,7 +669,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
669 669
 					default:
670 670
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
671 671
 							"in status %d: <<%.*s>> .\n",
672
-							*tmp,status, tmp-buffer, buffer);
672
+							*tmp,status, (int)(tmp-buffer), buffer);
673 673
 						goto error;
674 674
 				}
675 675
 				break;
... ...
@@ -1794,11 +1794,11 @@ nextvia:
1794 1794
 
1795 1795
 error:
1796 1796
 	if (end>buffer){
1797
-		LOG(L_ERR, "ERROR: parse_via on: <%.*s>\n", end-buffer, buffer);
1797
+		LOG(L_ERR, "ERROR: parse_via on: <%.*s>\n", (int)(end-buffer), buffer);
1798 1798
 	}
1799 1799
 	if ((tmp>buffer)&&(tmp<end)){
1800 1800
 		LOG(L_ERR, "ERROR: parse_via parse error, parsed so far:<%.*s>\n",
1801
-				tmp-buffer, buffer );
1801
+				(int)(tmp-buffer), buffer );
1802 1802
 	}else{
1803 1803
 		LOG(L_ERR, "ERROR: parse_via: via parse error\n");
1804 1804
 	}