From 96a1348a7c8fedf99f05d0bc5da0937d2f0ab54c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 6 Feb 2013 18:48:53 +0100 Subject: resolve pedantic warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- c/sha3sum.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'c') diff --git a/c/sha3sum.c b/c/sha3sum.c index 6ff70e7..4e2198b 100644 --- a/c/sha3sum.c +++ b/c/sha3sum.c @@ -276,17 +276,22 @@ int main(int argc, char** argv) char* stdin = null; char* filename; char* fn; - long f, fail = false, _; + long f, fail = false, _, bn; for (f = 0; f < fptr; f++) { + FILE* file; + long blksize; + char* chunk; + char* bs; + if (((filename = *(files + f)) == null) && stdin) { printf("%s", stdin); continue; } fn = filename ? filename : "/dev/stdin"; - FILE* file = fopen(fn, "r"); + file = fopen(fn, "r"); if (file == null) { fprintf(stderr, "%s: cannot read file: %s\n", cmd, filename); @@ -295,8 +300,8 @@ int main(int argc, char** argv) } initialise(r, c, o); - int blksize = 4096; /** XXX os.stat(os.path.realpath(fn)).st_size; **/ - char* chunk = malloc(blksize); + blksize = 4096; /** XXX os.stat(os.path.realpath(fn)).st_size; **/ + chunk = malloc(blksize); for (;;) { long read = fread(chunk, 1, blksize, file); @@ -305,8 +310,8 @@ int main(int argc, char** argv) update(chunk, read); } free(chunk); - char* bs = digest(null, 0); - long bn = (o + 7) >> 3; + bs = digest(null, 0); + bn = (o + 7) >> 3; for (_ = 1; _ < i; _++) { initialise(r, c, o); @@ -328,10 +333,11 @@ int main(int argc, char** argv) else { long flen = 0, rcptr = 0, b = 0; + char* rc; if (filename != null) while (*(filename + flen)) flen++; - char* rc = malloc((bn << 1) + 3 + (filename == null ? 1 : 0) + flen); + rc = malloc((bn << 1) + 3 + (filename == null ? 1 : 0) + flen); for (b = 0; b < bn; b++) { *(rc + rcptr++) = "0123456789ABCDEF"[(bs[b] >> 4) & 15]; -- cgit v1.2.3-70-g09d2