]> thyrsus.com Git - comparator.git/commitdiff
gcc -Wall cleanup.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 13 Sep 2003 01:47:36 +0000 (01:47 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 13 Sep 2003 01:47:36 +0000 (01:47 +0000)
Makefile
main.c
report.c
shred.h
shredtree.c

index 516d6c7e8366678ab7faed1c62da28a175efe64e..7aec63a1ea734dc6214ce5eb7ca2a88a67ec0460 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ DOCS    = README NEWS comparator.xml scf-standard.xml COPYING
 EXTRAS  = shredtree.py shredcompare.py
 TEST    = test
 SOURCES = $(CODE) $(DOCS) $(EXTRAS) $(TEST) comparator.spec Makefile
-CFLAGS  = -O
+CFLAGS  = -O -Wall
 LDFLAGS = 
 
 all: comparator comparator.1
diff --git a/main.c b/main.c
index 270a6c3a63d8e4b9af9cd0a749d38829d17ea6af..ad9dcc595bdb0d87f7c6f12f733ff2e849136c90 100644 (file)
--- a/main.c
+++ b/main.c
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <errno.h>
+#include <time.h>
 #include "shred.h"
 
 int debug = 0;
@@ -98,7 +99,7 @@ static void write_scf(const char *tree, FILE *ofp)
 {
     char       **place, **list;
     int                file_count, progress, totalchunks;
-    u_int32_t  netfile_count, lines, totallines = 0;
+    u_int32_t  netfile_count, totallines = 0;
     char       buf[BUFSIZ];
 
     list = sorted_file_list(tree, &file_count);
@@ -194,7 +195,7 @@ static void write_scf(const char *tree, FILE *ofp)
 static void read_scf(struct scf_t *scf)
 /* merge hashes from specified files into an in-code list */
 {
-    u_int32_t  filecount, totallines;
+    u_int32_t  filecount;
     int hashcount = 0;
     struct stat sb;
 
@@ -414,7 +415,6 @@ main(int argc, char *argv[])
     int status, file_only, compile_only, argcount;
     struct scf_t       *scf;
     char *dir, *outfile;
-    struct sorthash_t *np;
 
     compile_only = file_only = 0;
     dir = outfile = NULL;
@@ -490,7 +490,7 @@ main(int argc, char *argv[])
     /* two or more arguments */
     for(; optind < argc; optind++)
     {
-       char    *olddir, *source = argv[optind];
+       char    *olddir = NULL, *source = argv[optind];
 
        scf = (struct scf_t *)calloc(sizeof(struct scf_t), 1);
        scf->next = scflist;
index b7f66915895bdf0902fc59e77c27e417b0451ac9..2285b9d1f39a3934a9c719e2c765d5715ccf11a1 100644 (file)
--- a/report.c
+++ b/report.c
@@ -164,10 +164,9 @@ static int collapse_ranges(struct match_t *reduced, int nonuniques)
 struct match_t *reduce_matches(struct sorthash_t *obarray, int *hashcountp)
 /* assemble list of duplicated hashes */
 {
-     static struct match_t dummy; 
-     struct match_t *reduced, *sp, *tp;
      unsigned int nonuniques, nreduced, progress, hashcount = *hashcountp;
      struct sorthash_t *mp, *np;
+     struct match_t    *reduced;
 
      if (debug)
         dump_array("Chunk list before reduction.\n",obarray, hashcount);
@@ -217,7 +216,6 @@ struct match_t *reduce_matches(struct sorthash_t *obarray, int *hashcountp)
      reduced = (struct match_t *)malloc(sizeof(struct match_t) * nreduced);
      for (np = obarray; np < obarray + hashcount; np = mp)
      {
-        struct match_t *new;
         int i, heterogenous, nmatches;
 
         if (!debug && progress++ % 10000 == 0)
@@ -244,7 +242,7 @@ struct match_t *reduce_matches(struct sorthash_t *obarray, int *hashcountp)
             printf("*** %d has %d in its clique\n", np-obarray, nmatches);
             for (i = 0; i < nmatches; i++)
                 printf("%d: %s:%d:%d\n", 
-                       np-obarray+i, np[i].file, np[i].hash.start, np[i].hash.end);
+                       np-obarray+i, np[i].file->name, np[i].hash.start, np[i].hash.end);
         }
 
         /* passed all tests, keep this set of ranges */
diff --git a/shred.h b/shred.h
index c04cf8c4b4ed9b9924a8d631e4f3dcf832d4d774..4da22a456654ace4954cc0d139b582d4b56b7808 100644 (file)
--- a/shred.h
+++ b/shred.h
@@ -1,6 +1,7 @@
 /* shred.h -- types for shred similarity tools */
 
 #include <sys/types.h>
+#include <netinet/in.h>
 
 /*
  * 65,536 lines should be enough, but maybe someday this will be 32 bits.
index f5c46a5ac0824da5a4724861fee2708f4020cdbd..9c81542967f0de62e4e0dd20b0cf86011e7f1ce0 100644 (file)
@@ -7,7 +7,6 @@
 #include <errno.h>
 #include <ctype.h>
 #include <stdlib.h>
-#include <netinet/in.h>
 #include "md5.h"
 #include "shred.h"
 
@@ -71,6 +70,7 @@ static int normalize(char *buf)
 /* normalize a buffer in place, return 0 if it should be skipped */
 {
     if (remove_comments)
+    {
        if (remove_braces)      /* remove C comments */
        {
            char        *ss = strstr(buf, "//");
@@ -96,6 +96,7 @@ static int normalize(char *buf)
            if (ss)
                *ss = '\0';
        }
+    }
 
     if (remove_whitespace)     /* strip whitespace, ignore blank lines */
     {
@@ -168,7 +169,7 @@ int shredfile(struct filehdr_t *file,
     if ((fp = fopen(file->name, "r")) == NULL)
     {
        fprintf(stderr, "shredtree: couldn't open %s, error %d\n",
-               file, errno);
+               file->name, errno);
        exit(1);
     }