]> thyrsus.com Git - comparator.git/commitdiff
gcc -Wall cleanup.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 10 Sep 2003 16:58:53 +0000 (16:58 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 10 Sep 2003 16:58:53 +0000 (16:58 +0000)
main.c
report.c
shredtree.c

diff --git a/main.c b/main.c
index e0dd202edbe56c7e7059e43f9fc663259fdd0736..a94c58a03cb86eb732b30acb6d2456f3f4bf5b91 100644 (file)
--- a/main.c
+++ b/main.c
@@ -4,6 +4,7 @@
 #include <unistd.h>
 #include <stdarg.h>
 #include <string.h>
+#include <stdlib.h>
 #include <sys/stat.h>
 #include "shred.h"
 
@@ -167,7 +168,6 @@ void read_scf(const char *name, FILE *fp)
     {
        char    buf[BUFSIZ];
        linenum_t       chunks;
-       struct item *new;
 
        fgets(buf, sizeof(buf), fp);
        *strchr(buf, '\n') = '\0';
@@ -318,11 +318,12 @@ void report_time(char *legend, ...)
 
     if (mark_time)
     {
-       int elapsed = endtime - mark_time;
-       int hours = elapsed/3600; elapsed %= 3600;
-       int minutes = elapsed/60; elapsed %= 60;
-       int seconds = elapsed;
+       int elapsed, hours, minutes, seconds;
        char    buf[BUFSIZ];
+       elapsed = endtime - mark_time;
+       hours = elapsed/3600; elapsed %= 3600;
+       minutes = elapsed/60; elapsed %= 60;
+       seconds = elapsed;
 
        va_start(ap, legend);
        vsprintf(buf, legend, ap);
@@ -345,6 +346,7 @@ static void usage(void)
     exit(0);
 }
 
+int
 main(int argc, char *argv[])
 {
     extern char        *optarg;        /* set by getopt */
@@ -409,8 +411,6 @@ main(int argc, char *argv[])
 
     if (outfile)
     {
-       FILE    *ofp;
-
        if (freopen(outfile, "w", stdout) == NULL)
        {
            perror("comparator");
@@ -485,7 +485,7 @@ main(int argc, char *argv[])
        char    buf[BUFSIZ];
 
        dummy_scf.hash_method = "MD5";
-       buf[0] == '\0';
+       buf[0] = '\0';
        if (remove_whitespace)
            strcat(buf, "remove-whitespace, ");
        if (remove_comments)
index fcdd6345c794c436a5cc78bea66d14a7ebbff58d..2128e56e874bec5e1b9dce0706044a052967327a 100644 (file)
--- a/report.c
+++ b/report.c
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <time.h>
 #include <string.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include "shred.h"
 
@@ -26,7 +27,6 @@ struct match_t
 #endif /* DEBUG */
 }
 dummy_match;
-static struct match_t *reduced = &dummy_match;
 
 static int merge_ranges(struct range_t *p, struct range_t *q, int nmatches)
 /* merge p into q, if the ranges in the match are compatible */
@@ -227,7 +227,7 @@ struct match_t *reduce_matches(struct sorthash_t *obarray, int hashcount)
      return reduced;
 }
 
-static int sortmatch(void *a, void *b)
+static int sortmatch(const void *a, const void *b)
 /* sort by file and first line */
 {
     struct range_t *s = ((struct match_t *)a)->matches;
index dbee27fc51a8ab9d74e9889c1babb1242e12998d..951d28aab821313303a974031c7f5b65e26ab5eb 100644 (file)
@@ -5,7 +5,8 @@
 #include <string.h>
 #include <ftw.h>
 #include <errno.h>
-#include <alloca.h>
+#include <ctype.h>
+#include <stdlib.h>
 #include <netinet/in.h>
 #include "md5.h"
 #include "shred.h"
@@ -50,7 +51,7 @@ static int eligible(const char *file)
     {
        FILE    *fp = fopen(file, "r");
        char    buf[BUFSIZ], *cp;
-       int     printable;
+       int     printable = 0;
 
        if (!fp || !fgets(buf, sizeof(buf)-1, fp))
            return(0);
@@ -121,7 +122,6 @@ static struct hash_t emit_chunk(shred *display, int linecount)
 {
     struct md5_ctx     ctx;
     int                i, firstline;
-    unsigned char      *cp;
     struct hash_t      out;
 
     /* build completed chunk onto end of array */
@@ -136,6 +136,7 @@ static struct hash_t emit_chunk(shred *display, int linecount)
            md5_process_bytes(display[i].line, strlen(display[i].line), &ctx);
        }
     md5_finish_ctx(&ctx, (void *)&out.hash);
+    firstline = shredsize;
     for (i = shredsize - 1; i >= 0; i--)
        if (display[i].line)
            firstline = i;
@@ -215,7 +216,7 @@ static int treewalker(const char *file, const struct stat *sb, int flag)
     return(0);
 }
 
-static int stringsort(void *a, void *b)
+static int stringsort(const void *a, const void *b)
 /* sort comparison of strings by content */ 
 {
     return strcmp(*(char **)a, *(char **)b);
@@ -249,7 +250,7 @@ char **sorted_file_list(const char *tree, int *fc)
  *
  *************************************************************************/
 
-static int sortchunk(void *a, void *b)
+static int sortchunk(const void *a, const void *b)
 /* sort by hash */
 {
     int cmp = HASHCMP((struct sorthash_t *)a, (struct sorthash_t *)b);