Browse code

fix gcc -W* warnings

git-svn: trunk@2915

Tomasz Kojm authored on 2007/03/07 02:05:04
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Mar  6 16:10:52 CET 2007 (tk)
2
+---------------------------------
3
+  * clamscan: fix gcc -W* warnings
4
+
1 5
 Tue Mar  6 15:36:47 CET 2007 (tk)
2 6
 ---------------------------------
3 7
   * clamd: fix gcc -W* warnings
... ...
@@ -409,14 +409,14 @@ int scanmanager(const struct optstruct *opt)
409 409
  */
410 410
 
411 411
 #ifdef C_WINDOWS
412
-static int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt)
412
+static int clamav_unpack(const char *prog, const char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt)
413 413
 {
414 414
     /* TODO: use spamvp(P_WAIT, prog, args); */
415 415
     cli_errmsg("clamav_unpack is not supported under Windows yet\n");
416 416
     return -1;
417 417
 }
418 418
 #else
419
-static int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt)
419
+static int clamav_unpack(const char *prog, const char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt)
420 420
 {
421 421
 	pid_t pid;
422 422
 	int status, wret, fdevnull;
... ...
@@ -496,7 +496,7 @@ static int clamav_unpack(const char *prog, char **args, const char *tmpdir, cons
496 496
 
497 497
 		    if(!du(tmpdir, &n))
498 498
 			if((maxfiles && n.files > maxfiles) || (maxspace && n.space > maxspace)) {
499
-			    logg("*n.files: %d, n.space: %d\n", n.files, n.space);
499
+			    logg("*n.files: %u, n.space: %lu\n", n.files, n.space);
500 500
 			    kill(pid, 9); /* stop it immediately */
501 501
 			}
502 502
 		}
... ...
@@ -527,8 +527,9 @@ static int clamav_unpack(const char *prog, char **args, const char *tmpdir, cons
527 527
 
528 528
 static void move_infected(const char *filename, const struct optstruct *opt)
529 529
 {
530
-	char *movedir, *movefilename, *tmp, numext[4 + 1];
531
-	struct stat fstat, mfstat;
530
+	char *movedir, *movefilename, numext[4 + 1];
531
+	const char *tmp;
532
+	struct stat ofstat, mfstat;
532 533
 	int n, len, movefilename_size;
533 534
 	int moveflag = opt_check(opt, "move");
534 535
 	struct utimbuf ubuf;
... ...
@@ -537,7 +538,7 @@ static void move_infected(const char *filename, const struct optstruct *opt)
537 537
     if((moveflag && !(movedir = opt_arg(opt, "move"))) ||
538 538
 	(!moveflag && !(movedir = opt_arg(opt, "copy")))) {
539 539
         /* Should never reach here */
540
-        logg("!opt_arg() returned NULL\n", filename);
540
+        logg("!opt_arg() returned NULL\n");
541 541
         info.notmoved++;
542 542
         return;
543 543
     }
... ...
@@ -549,7 +550,7 @@ static void move_infected(const char *filename, const struct optstruct *opt)
549 549
     }
550 550
 
551 551
     if(!(tmp = strrchr(filename, '/')))
552
-	tmp = (const char *) filename;
552
+	tmp = filename;
553 553
 
554 554
     movefilename_size = sizeof(char) * (strlen(movedir) + strlen(tmp) + sizeof(numext) + 2);
555 555
 
... ...
@@ -574,10 +575,10 @@ static void move_infected(const char *filename, const struct optstruct *opt)
574 574
         return;
575 575
     }
576 576
 
577
-    stat(filename, &fstat);
577
+    stat(filename, &ofstat);
578 578
 
579 579
     if(!stat(movefilename, &mfstat)) {
580
-        if(fstat.st_ino == mfstat.st_ino) { /* It's the same file*/
580
+        if(ofstat.st_ino == mfstat.st_ino) { /* It's the same file*/
581 581
             logg("File excluded '%s'\n", filename);
582 582
             info.notmoved++;
583 583
             free(movefilename);
... ...
@@ -609,13 +610,13 @@ static void move_infected(const char *filename, const struct optstruct *opt)
609 609
 	    return;
610 610
 	}
611 611
 
612
-	chmod(movefilename, fstat.st_mode);
612
+	chmod(movefilename, ofstat.st_mode);
613 613
 #ifndef C_OS2
614
-	chown(movefilename, fstat.st_uid, fstat.st_gid);
614
+	chown(movefilename, ofstat.st_uid, ofstat.st_gid);
615 615
 #endif
616 616
 
617
-	ubuf.actime = fstat.st_atime;
618
-	ubuf.modtime = fstat.st_mtime;
617
+	ubuf.actime = ofstat.st_atime;
618
+	ubuf.modtime = ofstat.st_mtime;
619 619
 	utime(movefilename, &ubuf);
620 620
 
621 621
 	if(moveflag && unlink(filename)) {
... ...
@@ -665,7 +666,8 @@ static int checkfile(const char *filename, const struct cl_engine *engine, const
665 665
 static int scancompressed(const char *filename, struct cl_engine *engine, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options)
666 666
 {
667 667
 	int ret = 0;
668
-	char *tmpdir, *gendir, *userprg;
668
+	char *gendir, *userprg;
669
+	const char *tmpdir;
669 670
 	struct stat statbuf;
670 671
 
671 672
 
... ...
@@ -708,11 +710,11 @@ static int scancompressed(const char *filename, struct cl_engine *engine, const
708 708
 
709 709
     /* unpack file  - as unprivileged user */
710 710
     if(cli_strbcasestr(filename, ".zip")) {
711
-	char *args[] = { "unzip", "-P", "clam", "-o", NULL, NULL };
711
+	const char *args[] = { "unzip", "-P", "clam", "-o", NULL, NULL };
712 712
 	/* Sun's SUNWspro C compiler doesn't allow direct initialisation
713 713
 	 * with a variable
714 714
 	 */
715
-	args[4] = (char *) filename;
715
+	args[4] = filename;
716 716
 
717 717
 	if((userprg = opt_arg(opt, "unzip")))
718 718
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
... ...
@@ -720,64 +722,64 @@ static int scancompressed(const char *filename, struct cl_engine *engine, const
720 720
 	    ret = clamav_unpack("unzip", args, gendir, user, opt);
721 721
 
722 722
     } else if(cli_strbcasestr(filename, ".rar")) { 
723
-	char *args[] = { "unrar", "x", "-p-", "-y", NULL, NULL };
724
-	args[4] = (char *) filename;
723
+	const char *args[] = { "unrar", "x", "-p-", "-y", NULL, NULL };
724
+	args[4] = filename;
725 725
 	if((userprg = opt_arg(opt, "unrar")))
726 726
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
727 727
 	else
728 728
 	    ret = clamav_unpack("unrar", args, gendir, user, opt);
729 729
 
730 730
     } else if(cli_strbcasestr(filename, ".arj")) { 
731
-        char *args[] = { "arj", "x","-y", NULL, NULL };
732
-	args[3] = (char *) filename;
731
+        const char *args[] = { "arj", "x","-y", NULL, NULL };
732
+	args[3] = filename;
733 733
         if((userprg = opt_arg(opt, "arj")))
734 734
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
735 735
 	else
736 736
 	    ret = clamav_unpack("arj", args, gendir, user, opt);
737 737
 
738 738
     } else if(cli_strbcasestr(filename, ".zoo")) { 
739
-	char *args[] = { "unzoo", "-x","-j","./", NULL, NULL };
740
-	args[4] = (char *) filename;
739
+	const char *args[] = { "unzoo", "-x","-j","./", NULL, NULL };
740
+	args[4] = filename;
741 741
 	if((userprg = opt_arg(opt, "unzoo")))
742 742
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
743 743
 	else
744 744
 	    ret = clamav_unpack("unzoo", args, gendir, user, opt);
745 745
 
746 746
     } else if(cli_strbcasestr(filename, ".jar")) { 
747
-	char *args[] = { "unzip", "-P", "clam", "-o", NULL, NULL };
748
-	args[4] = (char *) filename;
747
+	const char *args[] = { "unzip", "-P", "clam", "-o", NULL, NULL };
748
+	args[4] = filename;
749 749
 	if((userprg = opt_arg(opt, "jar")))
750 750
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
751 751
 	else
752 752
 	    ret = clamav_unpack("unzip", args, gendir, user, opt);
753 753
 
754 754
     } else if(cli_strbcasestr(filename, ".lzh")) { 
755
-	char *args[] = { "lha", "xf", NULL, NULL };
756
-	args[2] = (char *) filename;
755
+	const char *args[] = { "lha", "xf", NULL, NULL };
756
+	args[2] = filename;
757 757
 	if((userprg = opt_arg(opt, "lha")))
758 758
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
759 759
 	else
760 760
 	    ret = clamav_unpack("lha", args, gendir, user, opt);
761 761
 
762 762
     } else if(cli_strbcasestr(filename, ".tar")) { 
763
-	char *args[] = { "tar", "-xpvf", NULL, NULL };
764
-	args[2] = (char *) filename;
763
+	const char *args[] = { "tar", "-xpvf", NULL, NULL };
764
+	args[2] = filename;
765 765
 	if((userprg = opt_arg(opt, "tar")))
766 766
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
767 767
 	else
768 768
 	    ret = clamav_unpack("tar", args, gendir, user, opt);
769 769
 
770 770
     } else if(cli_strbcasestr(filename, ".deb")) { 
771
-	char *args[] = { "ar", "x", NULL, NULL };
772
-	args[2] = (char *) filename;
771
+	const char *args[] = { "ar", "x", NULL, NULL };
772
+	args[2] = filename;
773 773
 	if((userprg = opt_arg(opt, "deb")))
774 774
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
775 775
 	else
776 776
 	    ret = clamav_unpack("ar", args, gendir, user, opt);
777 777
 
778 778
     } else if((cli_strbcasestr(filename, ".tar.gz") || cli_strbcasestr(filename, ".tgz"))) {
779
-	char *args[] = { "tar", "-zxpvf", NULL, NULL };
780
-	args[2] = (char *) filename;
779
+	const char *args[] = { "tar", "-zxpvf", NULL, NULL };
780
+	args[2] = filename;
781 781
 	if((userprg = opt_arg(opt, "tgz")))
782 782
 	    ret = clamav_unpack(userprg, args, gendir, user, opt);
783 783
 	else
... ...
@@ -865,7 +867,8 @@ static int scancompressed(const char *filename, struct cl_engine *engine, const
865 865
 
866 866
 static int scandenied(const char *filename, struct cl_engine *engine, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options)
867 867
 {
868
-	char *tmpdir, *gendir, *tmpfile, *pt;
868
+	char *gendir, *tmp_file;
869
+	const char *tmpdir, *pt;
869 870
 	struct stat statbuf;
870 871
 	int ret;
871 872
 
... ...
@@ -899,16 +902,16 @@ static int scandenied(const char *filename, struct cl_engine *engine, const stru
899 899
 	exit(63); /* critical */
900 900
     }
901 901
 
902
-    tmpfile = (char *) malloc(strlen(gendir) + strlen(filename) + 10);
902
+    tmp_file = (char *) malloc(strlen(gendir) + strlen(filename) + 10);
903 903
     pt = strrchr(filename, '/');
904 904
     if(!pt)
905
-	pt = (char *) filename;
905
+	pt = filename;
906 906
     else
907 907
 	pt += 1;
908 908
 
909
-    sprintf(tmpfile, "%s/%s", gendir, pt);
909
+    sprintf(tmp_file, "%s/%s", gendir, pt);
910 910
 
911
-    if(filecopy(filename, tmpfile) == -1) {
911
+    if(filecopy(filename, tmp_file) == -1) {
912 912
 	logg("!I/O error\n");
913 913
 	perror("copyfile()");
914 914
 	exit(58);
... ...
@@ -919,7 +922,7 @@ static int scandenied(const char *filename, struct cl_engine *engine, const stru
919 919
 #if !defined(C_OS2) && !defined(C_WINDOWS)
920 920
     if(user) {
921 921
 	chown(gendir, user->pw_uid, user->pw_gid);
922
-	chown(tmpfile, user->pw_uid, user->pw_gid);
922
+	chown(tmp_file, user->pw_uid, user->pw_gid);
923 923
     }
924 924
 #endif
925 925
 
... ...
@@ -941,7 +944,7 @@ static int scandenied(const char *filename, struct cl_engine *engine, const stru
941 941
     clamav_rmdirs(gendir);
942 942
 
943 943
     free(gendir);
944
-    free(tmpfile);
944
+    free(tmp_file);
945 945
 
946 946
     return ret;
947 947
 }
... ...
@@ -53,6 +53,7 @@
53 53
 #include "shared/misc.h"
54 54
 
55 55
 #include "libclamav/clamav.h"
56
+#include "libclamav/others.h"
56 57
 
57 58
 int treewalk(const char *dirname, struct cl_engine *engine, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, unsigned int options, unsigned int depth)
58 59
 {