Remove all open coded strerrors when they're going to be shown by fatal().

This commit is contained in:
ckolivas 2011-03-08 12:04:30 +11:00
parent 2a8cad1a28
commit 59e5bc0492
4 changed files with 14 additions and 15 deletions

View file

@ -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.

22
main.c
View file

@ -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);

View file

@ -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))

2
rzip.c
View file

@ -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;