From ed898d159a01710ae6511e4832e1634115856569 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 10 Sep 2003 16:58:53 +0000 Subject: [PATCH] gcc -Wall cleanup. --- main.c | 16 ++++++++-------- report.c | 4 ++-- shredtree.c | 11 ++++++----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index e0dd202..a94c58a 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #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) diff --git a/report.c b/report.c index fcdd634..2128e56 100644 --- a/report.c +++ b/report.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #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; diff --git a/shredtree.c b/shredtree.c index dbee27f..951d28a 100644 --- a/shredtree.c +++ b/shredtree.c @@ -5,7 +5,8 @@ #include #include #include -#include +#include +#include #include #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); -- 2.43.0