Browse code

fix more compiler warnings (bb #273)

git-svn: trunk@4353

Török Edvin authored on 2008/11/08 03:49:47
Showing 16 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Nov  7 19:37:38 EET 2008 (edwin)
2
+------------------------------------
3
+ * clamd/, libclamav/, libclamunrar/, unit_tests/: fix more compiler
4
+ warnings (bb #273)
5
+
1 6
 Fri Nov  7 13:28:49 CET 2008 (tk)
2 7
 ---------------------------------
3 8
  * freshclam/manager.c: remove unused parameter (bb#1280)
... ...
@@ -222,7 +222,7 @@ int thrmgr_printstats(int f)
222 222
 			if(invalids)
223 223
 				mdprintf(f," (INVALID timestamps: %u)", invalids);
224 224
 		}
225
-		if(cnt + invalids != pool->queue->item_count)
225
+		if(cnt + invalids != (unsigned)pool->queue->item_count)
226 226
 			mdprintf(f," (ERROR: %u != %u)", cnt + invalids,
227 227
 					(unsigned)pool->queue->item_count);
228 228
 		mdprintf(f, "\n");
... ...
@@ -397,8 +397,8 @@ struct DISASMED {
397 397
   uint32_t opsize;
398 398
   uint32_t adsize;
399 399
   uint32_t segment;
400
-  struct DIS_ARGS args[3];
401 400
   uint8_t cur;
401
+  struct DIS_ARGS args[3];
402 402
 };
403 403
 
404 404
 #endif
... ...
@@ -100,8 +100,8 @@ typedef struct file_buff_tag {
100 100
 } file_buff_t;
101 101
 
102 102
 struct tag_contents {
103
-	unsigned char contents[MAX_TAG_CONTENTS_LENGTH + 1];
104 103
 	size_t pos;
104
+	unsigned char contents[MAX_TAG_CONTENTS_LENGTH + 1];
105 105
 };
106 106
 
107 107
 static const int base64_chars[256] = {
... ...
@@ -72,12 +72,10 @@ typedef struct scanner {
72 72
 typedef int YY_BUFFER_STATE;
73 73
 
74 74
 static int yylex( YYSTYPE *lvalp, yyscan_t  );
75
-static void yy_delete_buffer( YY_BUFFER_STATE, yyscan_t);
76 75
 static YY_BUFFER_STATE yy_scan_bytes( const char *, size_t, yyscan_t scanner );
77 76
 static const char *yyget_text ( yyscan_t scanner );
78 77
 static int yyget_leng ( yyscan_t scanner );
79 78
 static int yylex_init ( yyscan_t * ptr_yy_globals ) ;
80
-static void yyset_debug (int debug_flag ,yyscan_t yyscanner );
81 79
 static int yylex_destroy ( yyscan_t yyscanner ) ;
82 80
 /* ----------- tokenizer end ---------------- */
83 81
 
... ...
@@ -687,7 +685,7 @@ static void handle_de(yystype *tokens, size_t start, const size_t cnt, const cha
687 687
 	}
688 688
 }
689 689
 
690
-static int handle_unescape(struct tokens *tokens, size_t start, const size_t cnt)
690
+static int handle_unescape(struct tokens *tokens, size_t start)
691 691
 {
692 692
 	if(tokens->data[start].type == TOK_StringLiteral) {
693 693
 		char *R;
... ...
@@ -707,7 +705,7 @@ static int handle_unescape(struct tokens *tokens, size_t start, const size_t cnt
707 707
 
708 708
 
709 709
 /* scriptasylum dot com's JS encoder */
710
-static void handle_df(const yystype *tokens, size_t start, const size_t cnt, struct decode_result *res)
710
+static void handle_df(const yystype *tokens, size_t start, struct decode_result *res)
711 711
 {
712 712
 	char *str, *s1;
713 713
 	size_t len, s1_len, i;
... ...
@@ -760,7 +758,7 @@ static void run_folders(struct tokens *tokens)
760 760
 		    cstring &&
761 761
 		    !strcmp("unescape", cstring) && tokens->data[i+1].type == TOK_PAR_OPEN) {
762 762
 
763
-		  handle_unescape(tokens, i+2, tokens->cnt);
763
+		  handle_unescape(tokens, i+2);
764 764
 	  }
765 765
   }
766 766
 }
... ...
@@ -813,7 +811,7 @@ static void run_decoders(struct parser_state *state)
813 813
 		  /* TODO: also match signature of dF function (possibly
814 814
 		   * declared using unescape */
815 815
 
816
-		  handle_df(tokens->data, i+2, tokens->cnt, &res);
816
+		  handle_df(tokens->data, i+2, &res);
817 817
 	  } else if(i+2 < tokens->cnt && tokens->data[i].type == TOK_IDENTIFIER_NAME &&
818 818
 			  cstring &&
819 819
 			  !strcmp("eval", cstring) && tokens->data[i+1].type == TOK_PAR_OPEN) {
... ...
@@ -1150,7 +1148,6 @@ void cli_js_process_buffer(struct parser_state *state, const char *buf, size_t n
1150 1150
 		memset(&val, 0, sizeof(val));
1151 1151
 		val.vtype = vtype_undefined;
1152 1152
 	}
1153
-	yy_delete_buffer(yyb, state->scanner);
1154 1153
 }
1155 1154
 
1156 1155
 struct parser_state *cli_js_init(void)
... ...
@@ -1169,7 +1166,6 @@ struct parser_state *cli_js_init(void)
1169 1169
 		free(state);
1170 1170
 		return NULL;
1171 1171
 	}
1172
-	yyset_debug(1, state->scanner);
1173 1172
 	cli_dbgmsg(MODULE "cli_js_init() done\n");
1174 1173
 	return state;
1175 1174
 }
... ...
@@ -1440,14 +1436,6 @@ static int yy_scan_bytes(const char *p, size_t len, yyscan_t scanner)
1440 1440
 	return 0;
1441 1441
 }
1442 1442
 
1443
-static void yyset_debug (int debug_flag ,yyscan_t yyscanner )
1444
-{
1445
-}
1446
-
1447
-static void yy_delete_buffer( YY_BUFFER_STATE yyb, yyscan_t scanner)
1448
-{
1449
-}
1450
-
1451 1443
 static const char *yyget_text(yyscan_t scanner)
1452 1444
 {
1453 1445
 	assert(scanner->buf.data || scanner->yytext);
... ...
@@ -4034,7 +4034,7 @@ checkURLs(message *mainMessage, mbox_ctx *mctx, mbox_status *rc, int is_html)
4034 4034
 	b = getHrefs(mainMessage, &hrefs);
4035 4035
 	if(b) {
4036 4036
 		if(hrefs.scanContents) {
4037
-			if(phishingScan(mctx->dir, mctx->ctx, &hrefs) == CL_VIRUS) {
4037
+			if(phishingScan(mctx->ctx, &hrefs) == CL_VIRUS) {
4038 4038
 				/*
4039 4039
 				 * FIXME: message objects' contents are
4040 4040
 				 *	encapsulated so we should not access
... ...
@@ -44,11 +44,11 @@ extern uint8_t cli_debug_flag, cli_leavetemps_flag;
44 44
  * The macro can be used to protect against wraps.
45 45
  */
46 46
 #define CLI_ISCONTAINED(bb, bb_size, sb, sb_size)	\
47
-    (bb_size > 0 && sb_size > 0 && sb_size <= bb_size	\
47
+    (bb_size > 0 && sb_size > 0 && (size_t)sb_size <= (size_t)bb_size	\
48 48
      && sb >= bb && sb + sb_size <= bb + bb_size && sb + sb_size > bb)
49 49
 
50 50
 #define CLI_ISCONTAINED2(bb, bb_size, sb, sb_size)	\
51
-    (bb_size > 0 && sb_size >= 0 && sb_size <= bb_size	\
51
+    (bb_size > 0 && sb_size >= 0 && (size_t)sb_size <= (size_t)bb_size	\
52 52
      && sb >= bb && sb + sb_size <= bb + bb_size && sb + sb_size >= bb)
53 53
 
54 54
 #define CLI_MAX_ALLOCATION 184549376
... ...
@@ -1920,7 +1920,7 @@ int cli_scanpe(int desc, cli_ctx *ctx)
1920 1920
 	for(i=0 ; ; i++) {
1921 1921
 	    if(exe_sections[i].raw<head) 
1922 1922
 	        head=exe_sections[i].raw;
1923
-	    if(i==nsections-1) break;
1923
+	    if(i+1==nsections) break;
1924 1924
 	    if(ssize<exe_sections[i].rva+exe_sections[i].vsz)
1925 1925
 		ssize=exe_sections[i].rva+exe_sections[i].vsz;
1926 1926
 	}
... ...
@@ -1945,7 +1945,7 @@ int cli_scanpe(int desc, cli_ctx *ctx)
1945 1945
             if(!CLI_ISCONTAINED(src, ssize, src+exe_sections[i].rva, exe_sections[i].rsz)) break;
1946 1946
             if(cli_readn(desc, src+exe_sections[i].rva, exe_sections[i].rsz)!=exe_sections[i].rsz) break;
1947 1947
         }
1948
-        if(i!=nsections-1) {
1948
+        if(i+1!=nsections) {
1949 1949
             cli_dbgmsg("WWpack: Probably hacked/damaged file.\n");
1950 1950
             free(src);
1951 1951
             break;
... ...
@@ -40,7 +40,7 @@
40 40
 #include "phish_domaincheck_db.h"
41 41
 #include "regex_list.h"
42 42
 
43
-int domainlist_match(const struct cl_engine* engine,char* real_url,const char* display_url,const struct pre_fixup_info* pre_fixup,int hostOnly,unsigned short* flags)
43
+int domainlist_match(const struct cl_engine* engine,char* real_url,const char* display_url,const struct pre_fixup_info* pre_fixup,int hostOnly)
44 44
 {
45 45
 	const char* info;
46 46
 	int rc = engine->domainlist_matcher ? regex_list_match(engine->domainlist_matcher,real_url,display_url,hostOnly ? pre_fixup : NULL,hostOnly,&info,0) : 0;
... ...
@@ -29,7 +29,7 @@ int init_domainlist(struct cl_engine* engine);
29 29
 void domainlist_done(struct cl_engine* engine);
30 30
 void domainlist_cleanup(const struct cl_engine* engine);
31 31
 int is_domainlist_ok(const struct cl_engine* engine);
32
-int domainlist_match(const struct cl_engine* engine,char* real_url,const char* display_url,const struct pre_fixup_info* pre_fixup, int hostOnly,unsigned short* flags);
32
+int domainlist_match(const struct cl_engine *engine, char* real_url,const char* display_url,const struct pre_fixup_info* pre_fixup, int hostOnly);
33 33
 
34 34
 #endif
35 35
 
... ...
@@ -340,7 +340,7 @@ static int build_regex(regex_t* preg,const char* regex,int nosub)
340 340
 }
341 341
 
342 342
 /* allocates memory */
343
-static int get_host(const struct phishcheck* s,const char* URL,int isReal,int* phishy,const char **hstart, const char **hend)
343
+static int get_host(const char* URL,int isReal,int* phishy,const char **hstart, const char **hend)
344 344
 {
345 345
 	int rc,ismailto = 0;
346 346
 	const char* start;
... ...
@@ -425,7 +425,7 @@ rfind(char *start, char c, size_t len)
425 425
 	return (p < start) ? NULL : p;
426 426
 }
427 427
 
428
-static void get_domain(const struct phishcheck* pchk,struct string* dest,struct string* host)
428
+static void get_domain(struct string* dest,struct string* host)
429 429
 {
430 430
 	char* domain;
431 431
 	char* tld = strrchr(host->data,'.');
... ...
@@ -722,7 +722,7 @@ cleanupURL(struct string *URL,struct string *pre_URL, int isReal)
722 722
 }
723 723
 
724 724
 /* -------end runtime disable---------*/
725
-int phishingScan(const char* dir,cli_ctx* ctx,tag_arguments_t* hrefs)
725
+int phishingScan(cli_ctx* ctx,tag_arguments_t* hrefs)
726 726
 {
727 727
 	/* TODO: get_host and then apply regex, etc. */
728 728
 	int i;
... ...
@@ -992,7 +992,7 @@ static inline int validate_uri_ialpha(const char *start, const char *end)
992 992
 /*
993 993
  * Only those URLs are identified as URLs for which phishing detection can be performed.
994 994
  */
995
-static int isURL(const struct phishcheck* pchk,const char* URL, int accept_anyproto)
995
+static int isURL(const char* URL, int accept_anyproto)
996 996
 {
997 997
 	const char *start = NULL, *p, *q, *end;
998 998
 	if(!URL)
... ...
@@ -1088,13 +1088,13 @@ static enum phish_status cleanupURLs(struct url_check* urls)
1088 1088
 	return CL_PHISH_NODECISION;
1089 1089
 }
1090 1090
 
1091
-static int url_get_host(const struct phishcheck* pchk, struct url_check* url,struct url_check* host_url,int isReal,int* phishy)
1091
+static int url_get_host(struct url_check* url,struct url_check* host_url,int isReal,int* phishy)
1092 1092
 {
1093 1093
 	const char *start, *end;
1094 1094
 	struct string* host = isReal ? &host_url->realLink : &host_url->displayLink;
1095 1095
 	const char* URL = isReal ? url->realLink.data : url->displayLink.data;
1096 1096
 	int rc;
1097
-	if ((rc = get_host(pchk, URL, isReal, phishy, &start, &end))) {
1097
+	if ((rc = get_host(URL, isReal, phishy, &start, &end))) {
1098 1098
 		return rc;
1099 1099
 	}
1100 1100
 	if(!start || !end) {
... ...
@@ -1126,10 +1126,10 @@ static int url_get_host(const struct phishcheck* pchk, struct url_check* url,str
1126 1126
 	return CL_PHISH_NODECISION;
1127 1127
 }
1128 1128
 
1129
-static void url_get_domain(const struct phishcheck* pchk, struct url_check* url,struct url_check* domains)
1129
+static void url_get_domain(struct url_check* url,struct url_check* domains)
1130 1130
 {
1131
-	get_domain(pchk, &domains->realLink, &url->realLink);
1132
-	get_domain(pchk, &domains->displayLink, &url->displayLink);
1131
+	get_domain(&domains->realLink, &url->realLink);
1132
+	get_domain(&domains->displayLink, &url->displayLink);
1133 1133
 	domains->flags = url->flags;
1134 1134
 }
1135 1135
 
... ...
@@ -1289,7 +1289,7 @@ static enum phish_status phishingCheck(const struct cl_engine* engine,struct url
1289 1289
 	if(!strcmp(urls->realLink.data,urls->displayLink.data))
1290 1290
 		return CL_PHISH_CLEAN;/* displayed and real URL are identical -> clean */
1291 1291
 
1292
-	if(!isURL(pchk, urls->realLink.data, 0)) {
1292
+	if(!isURL(urls->realLink.data, 0)) {
1293 1293
 		cli_dbgmsg("Real 'url' is not url:%s\n",urls->realLink.data);
1294 1294
 		return CL_PHISH_CLEAN;
1295 1295
 	}
... ...
@@ -1308,7 +1308,7 @@ static enum phish_status phishingCheck(const struct cl_engine* engine,struct url
1308 1308
 	cli_dbgmsg("Phishcheck:URL after cleanup: %s->%s\n", urls->realLink.data,
1309 1309
 		urls->displayLink.data);
1310 1310
 
1311
-	if((!isURL(pchk, urls->displayLink.data, 1) ) &&
1311
+	if((!isURL(urls->displayLink.data, 1) ) &&
1312 1312
 			( (phishy&PHISHY_NUMERIC_IP && !isNumericURL(pchk, urls->displayLink.data)) ||
1313 1313
 			  !(phishy&PHISHY_NUMERIC_IP))) {
1314 1314
 		cli_dbgmsg("Displayed 'url' is not url:%s\n",urls->displayLink.data);
... ...
@@ -1320,12 +1320,12 @@ static enum phish_status phishingCheck(const struct cl_engine* engine,struct url
1320 1320
 
1321 1321
 	url_check_init(&host_url);
1322 1322
 
1323
-	if((rc = url_get_host(pchk, urls, &host_url, DOMAIN_DISPLAY, &phishy))) {
1323
+	if((rc = url_get_host(urls, &host_url, DOMAIN_DISPLAY, &phishy))) {
1324 1324
 		free_if_needed(&host_url);
1325 1325
 		return rc < 0 ? rc : CL_PHISH_CLEAN;
1326 1326
 	}
1327 1327
 
1328
-	if (domainlist_match(engine,host_url.displayLink.data,host_url.realLink.data,&urls->pre_fixup,1,&urls->flags)) {
1328
+	if (domainlist_match(engine, host_url.displayLink.data,host_url.realLink.data,&urls->pre_fixup,1)) {
1329 1329
 		phishy |= DOMAIN_LISTED;
1330 1330
 	} else {
1331 1331
 		urls->flags &= urls->always_check_flags;
... ...
@@ -1358,7 +1358,7 @@ static enum phish_status phishingCheck(const struct cl_engine* engine,struct url
1358 1358
 		return CL_PHISH_CLEAN;
1359 1359
 	}
1360 1360
 
1361
-	if((rc = url_get_host(pchk, urls,&host_url,DOMAIN_REAL,&phishy)))
1361
+	if((rc = url_get_host(urls,&host_url,DOMAIN_REAL,&phishy)))
1362 1362
 	{
1363 1363
 		free_if_needed(&host_url);
1364 1364
 		return rc < 0 ? rc : CL_PHISH_CLEAN;
... ...
@@ -1377,7 +1377,7 @@ static enum phish_status phishingCheck(const struct cl_engine* engine,struct url
1377 1377
 	{
1378 1378
 		struct url_check domain_url;
1379 1379
 		url_check_init(&domain_url);
1380
-		url_get_domain(pchk, &host_url,&domain_url);
1380
+		url_get_domain(&host_url,&domain_url);
1381 1381
 		if(!strcmp(domain_url.realLink.data,domain_url.displayLink.data)) {
1382 1382
 			free_if_needed(&host_url);
1383 1383
 			free_if_needed(&domain_url);
... ...
@@ -66,7 +66,7 @@ struct url_check {
66 66
 	unsigned short       link_type;
67 67
 };
68 68
 
69
-int phishingScan(const char* dir,cli_ctx* ctx,tag_arguments_t* hrefs);
69
+int phishingScan(cli_ctx* ctx,tag_arguments_t* hrefs);
70 70
 
71 71
 void phish_disable(struct cl_engine* engine,const char* reason);
72 72
 /* Global, non-thread-safe functions, call only once! */
... ...
@@ -111,7 +111,7 @@ void rarvm_set_value(int byte_mode, unsigned int *addr, unsigned int value)
111 111
 
112 112
 		
113 113
 #if WORDS_BIGENDIAN == 0
114
-#define SET_VALUE(byte_mode,addr,value) ((byte_mode) ? (*(unsigned char *)(addr)=(value)):(*(uint32_t *)(addr)=((uint32_t)(value))))
114
+#define SET_VALUE(byte_mode,addr,value) (void)(((byte_mode) ? (*(unsigned char *)(addr)=(value)):(*(uint32_t *)(addr)=((uint32_t)(value)))))
115 115
 #else
116 116
 #define SET_VALUE(byte_mode,addr,value) rarvm_set_value(byte_mode, (unsigned int *)addr, value);
117 117
 #endif
... ...
@@ -60,13 +60,13 @@ static struct test {
60 60
 
61 61
 #ifdef CHECK_HAVE_LOOPS
62 62
 
63
-static void check_dir(const char *dir, const struct test *test)
63
+static void check_dir(const char *dire, const struct test *test)
64 64
 {
65 65
 	char filename[4096];
66 66
 	int fd, reffd;
67 67
 
68 68
 	if (test->nocommentref) {
69
-		snprintf(filename, sizeof(filename), "%s/nocomment.html", dir);
69
+		snprintf(filename, sizeof(filename), "%s/nocomment.html", dire);
70 70
 		fd = open(filename, O_RDONLY);
71 71
 		fail_unless(fd > 0,"unable to open: %s", filename);
72 72
 		reffd = open_testfile(test->nocommentref);
... ...
@@ -77,7 +77,7 @@ static void check_dir(const char *dir, const struct test *test)
77 77
 		close(fd);
78 78
 	}
79 79
 	if (test->notagsref) {
80
-		snprintf(filename, sizeof(filename), "%s/notags.html", dir);
80
+		snprintf(filename, sizeof(filename), "%s/notags.html", dire);
81 81
 		fd = open(filename, O_RDONLY);
82 82
 		fail_unless(fd > 0,"unable to open: %s", filename);
83 83
 		reffd = open_testfile(test->notagsref);
... ...
@@ -88,7 +88,7 @@ static void check_dir(const char *dir, const struct test *test)
88 88
 		close(fd);
89 89
 	}
90 90
 	if (test->jsref) {
91
-		snprintf(filename, sizeof(filename), "%s/javascript", dir);
91
+		snprintf(filename, sizeof(filename), "%s/javascript", dire);
92 92
 		fd = open(filename, O_RDONLY);
93 93
 		fail_unless(fd > 0,"unable to open: %s", filename);
94 94
 		reffd = open_testfile(test->jsref);
... ...
@@ -227,11 +227,9 @@ static void jstest_teardown(void)
227 227
 static void tokenizer_test(const char *in, const char *expected, int split)
228 228
 {
229 229
 	char filename[1024];
230
-	char *buf;
231 230
 	int fd;
232 231
 	ssize_t len = strlen(expected);
233 232
 	size_t inlen = strlen(in);
234
-	ssize_t p, p2;
235 233
 
236 234
 	if(split) {
237 235
 		cli_js_process_buffer(state, in, inlen/2);
... ...
@@ -459,7 +457,7 @@ Suite *test_jsnorm_suite(void)
459 459
 {
460 460
     Suite *s = suite_create("jsnorm");
461 461
     TCase *tc_jsnorm_gperf, *tc_jsnorm_token, *tc_jsnorm_api,
462
-	  *tc_jsnorm_tokenizer, *tc_jsnorm_bugs, *tc_screnc_infloop;
462
+	  *tc_jsnorm_tokenizer, *tc_jsnorm_bugs;
463 463
 
464 464
     prepare();
465 465
     tc_jsnorm_gperf = tcase_create("jsnorm gperf");
... ...
@@ -371,7 +371,7 @@ static void do_phishing_test(const struct rtest *rtest)
371 371
 	ctx.engine = engine;
372 372
 	ctx.virname = &virname;
373 373
 
374
-	rc = phishingScan(NULL, &ctx, &hrefs);
374
+	rc = phishingScan(&ctx, &hrefs);
375 375
 
376 376
 	html_tag_arg_free(&hrefs);
377 377
 	fail_unless(rc == CL_CLEAN,"phishingScan");