From 59e5bc04927ea78ff644b8d80e0dcd44bf061451 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Tue, 8 Mar 2011 12:04:30 +1100 Subject: [PATCH] Remove all open coded strerrors when they're going to be shown by fatal(). --- ChangeLog | 1 + main.c | 22 ++++++++++------------ runzip.c | 4 ++-- rzip.c | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a35257..c16a52f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,7 @@ every chunk is decompressed instead of after the whole file is decompressed. only or to stdout). * Clean up and simplify the times displayed component. It could potentially show thousands of seconds. +* Remove open coded strerror messages when they're to be printed by fatal(). MARCH 2011, Michael Blumenkrantz * Updated autotools/conf build system. diff --git a/main.c b/main.c index 094a589..91c6631 100644 --- a/main.c +++ b/main.c @@ -195,7 +195,7 @@ void dump_tmpoutfile(int fd_out) fsync(fd_out); tmpoutfp = fdopen(fd_out, "r"); if (unlikely(tmpoutfp == NULL)) - fatal("Failed to fdopen out tmpfile: %s\n", strerror(errno)); + fatal("Failed to fdopen out tmpfile\n"); rewind(tmpoutfp); if (!TEST_ONLY) { @@ -248,7 +248,7 @@ static void read_tmpinfile(int fd_in) fprintf(control.msgout, "Copying from stdin.\n"); tmpinfp = fdopen(fd_in, "w+"); if (unlikely(tmpinfp == NULL)) - fatal("Failed to fdopen in tmpfile: %s\n", strerror(errno)); + fatal("Failed to fdopen in tmpfile\n"); while ((tmpchar = getchar()) != EOF) fputc(tmpchar, tmpinfp); @@ -324,9 +324,7 @@ static void decompress_file(void) } else { fd_in = open(infilecopy, O_RDONLY); if (unlikely(fd_in == -1)) { - fatal("Failed to open %s: %s\n", - infilecopy, - strerror(errno)); + fatal("Failed to open %s\n",infilecopy); } } @@ -339,7 +337,7 @@ static void decompress_file(void) /* We must ensure we don't delete a file that already * exists just because we tried to create a new one */ control.flags |= FLAG_KEEP_BROKEN; - fatal("Failed to create %s: %s\n", control.outfile, strerror(errno)); + fatal("Failed to create %s\n", control.outfile); } preserve_perms(fd_in, fd_out); @@ -399,7 +397,7 @@ static void decompress_file(void) if (!KEEP_FILES) { if (unlikely(unlink(control.infile))) - fatal("Failed to unlink %s: %s\n", infilecopy, strerror(errno)); + fatal("Failed to unlink %s\n", infilecopy); } free(control.outfile); @@ -461,7 +459,7 @@ static void get_fileinfo(void) else { fd_in = open(infilecopy, O_RDONLY); if (unlikely(fd_in == -1)) - fatal("Failed to open %s: %s\n", infilecopy, strerror(errno)); + fatal("Failed to open %s\n", infilecopy); } /* Get file size */ @@ -480,7 +478,7 @@ static void get_fileinfo(void) else seekspot = 75; if (unlikely(lseek(fd_in, seekspot, SEEK_SET) == -1)) - fatal("Failed to lseek in get_fileinfo: %s\n", strerror(errno)); + fatal("Failed to lseek in get_fileinfo\n"); /* Read the compression type of the first block. It's possible that not all blocks are compressed so this may not be accurate. @@ -631,7 +629,7 @@ static void compress_file(void) fd_in = open(control.infile, O_RDONLY); if (unlikely(fd_in == -1)) - fatal("Failed to open %s: %s\n", control.infile, strerror(errno)); + fatal("Failed to open %s\n", control.infile); } else fd_in = 0; @@ -680,7 +678,7 @@ static void compress_file(void) /* We must ensure we don't delete a file that already * exists just because we tried to create a new one */ control.flags |= FLAG_KEEP_BROKEN; - fatal("Failed to create %s: %s\n", control.outfile, strerror(errno)); + fatal("Failed to create %s\n", control.outfile); } } else fd_out = open_tmpoutfile(); @@ -708,7 +706,7 @@ static void compress_file(void) if (!KEEP_FILES) { if (unlikely(unlink(control.infile))) - fatal("Failed to unlink %s: %s\n", control.infile, strerror(errno)); + fatal("Failed to unlink %s\n", control.infile); } free(control.outfile); diff --git a/runzip.c b/runzip.c index 9922523..4661c05 100644 --- a/runzip.c +++ b/runzip.c @@ -107,8 +107,8 @@ static i64 unzip_match(void *ss, i64 len, int fd_out, int fd_hist, uint32 *cksum /* Note the offset is in a different format v0.40+ */ offset = read_vchars(ss, 0, chunk_bytes); if (unlikely(lseek(fd_hist, cur_pos - offset, SEEK_SET) == -1)) - fatal("Seek failed by %d from %d on history file in unzip_match - %s\n", - offset, cur_pos, strerror(errno)); + fatal("Seek failed by %d from %d on history file in unzip_match\n", + offset, cur_pos); buf = (uchar *)malloc(len); if (unlikely(!buf)) diff --git a/rzip.c b/rzip.c index 6f461ec..5f92daf 100644 --- a/rzip.c +++ b/rzip.c @@ -753,7 +753,7 @@ void rzip_fd(int fd_in, int fd_out) } if (unlikely(fstat(fd_in, &s))) - fatal("Failed to stat fd_in in rzip_fd - %s\n", strerror(errno)); + fatal("Failed to stat fd_in in rzip_fd\n"); if (!STDIN) { len = control.st_size = s.st_size;