mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Remove all open coded strerrors when they're going to be shown by fatal().
This commit is contained in:
parent
2a8cad1a28
commit
59e5bc0492
|
|
@ -21,6 +21,7 @@ every chunk is decompressed instead of after the whole file is decompressed.
|
||||||
only or to stdout).
|
only or to stdout).
|
||||||
* Clean up and simplify the times displayed component. It could potentially
|
* Clean up and simplify the times displayed component. It could potentially
|
||||||
show thousands of seconds.
|
show thousands of seconds.
|
||||||
|
* Remove open coded strerror messages when they're to be printed by fatal().
|
||||||
|
|
||||||
MARCH 2011, Michael Blumenkrantz
|
MARCH 2011, Michael Blumenkrantz
|
||||||
* Updated autotools/conf build system.
|
* Updated autotools/conf build system.
|
||||||
|
|
|
||||||
22
main.c
22
main.c
|
|
@ -195,7 +195,7 @@ void dump_tmpoutfile(int fd_out)
|
||||||
fsync(fd_out);
|
fsync(fd_out);
|
||||||
tmpoutfp = fdopen(fd_out, "r");
|
tmpoutfp = fdopen(fd_out, "r");
|
||||||
if (unlikely(tmpoutfp == NULL))
|
if (unlikely(tmpoutfp == NULL))
|
||||||
fatal("Failed to fdopen out tmpfile: %s\n", strerror(errno));
|
fatal("Failed to fdopen out tmpfile\n");
|
||||||
rewind(tmpoutfp);
|
rewind(tmpoutfp);
|
||||||
|
|
||||||
if (!TEST_ONLY) {
|
if (!TEST_ONLY) {
|
||||||
|
|
@ -248,7 +248,7 @@ static void read_tmpinfile(int fd_in)
|
||||||
fprintf(control.msgout, "Copying from stdin.\n");
|
fprintf(control.msgout, "Copying from stdin.\n");
|
||||||
tmpinfp = fdopen(fd_in, "w+");
|
tmpinfp = fdopen(fd_in, "w+");
|
||||||
if (unlikely(tmpinfp == NULL))
|
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)
|
while ((tmpchar = getchar()) != EOF)
|
||||||
fputc(tmpchar, tmpinfp);
|
fputc(tmpchar, tmpinfp);
|
||||||
|
|
@ -324,9 +324,7 @@ static void decompress_file(void)
|
||||||
} else {
|
} else {
|
||||||
fd_in = open(infilecopy, O_RDONLY);
|
fd_in = open(infilecopy, O_RDONLY);
|
||||||
if (unlikely(fd_in == -1)) {
|
if (unlikely(fd_in == -1)) {
|
||||||
fatal("Failed to open %s: %s\n",
|
fatal("Failed to open %s\n",infilecopy);
|
||||||
infilecopy,
|
|
||||||
strerror(errno));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -339,7 +337,7 @@ static void decompress_file(void)
|
||||||
/* We must ensure we don't delete a file that already
|
/* We must ensure we don't delete a file that already
|
||||||
* exists just because we tried to create a new one */
|
* exists just because we tried to create a new one */
|
||||||
control.flags |= FLAG_KEEP_BROKEN;
|
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);
|
preserve_perms(fd_in, fd_out);
|
||||||
|
|
@ -399,7 +397,7 @@ static void decompress_file(void)
|
||||||
|
|
||||||
if (!KEEP_FILES) {
|
if (!KEEP_FILES) {
|
||||||
if (unlikely(unlink(control.infile)))
|
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);
|
free(control.outfile);
|
||||||
|
|
@ -461,7 +459,7 @@ static void get_fileinfo(void)
|
||||||
else {
|
else {
|
||||||
fd_in = open(infilecopy, O_RDONLY);
|
fd_in = open(infilecopy, O_RDONLY);
|
||||||
if (unlikely(fd_in == -1))
|
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 */
|
/* Get file size */
|
||||||
|
|
@ -480,7 +478,7 @@ static void get_fileinfo(void)
|
||||||
else
|
else
|
||||||
seekspot = 75;
|
seekspot = 75;
|
||||||
if (unlikely(lseek(fd_in, seekspot, SEEK_SET) == -1))
|
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
|
/* Read the compression type of the first block. It's possible that
|
||||||
not all blocks are compressed so this may not be accurate.
|
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);
|
fd_in = open(control.infile, O_RDONLY);
|
||||||
if (unlikely(fd_in == -1))
|
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
|
} else
|
||||||
fd_in = 0;
|
fd_in = 0;
|
||||||
|
|
||||||
|
|
@ -680,7 +678,7 @@ static void compress_file(void)
|
||||||
/* We must ensure we don't delete a file that already
|
/* We must ensure we don't delete a file that already
|
||||||
* exists just because we tried to create a new one */
|
* exists just because we tried to create a new one */
|
||||||
control.flags |= FLAG_KEEP_BROKEN;
|
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
|
} else
|
||||||
fd_out = open_tmpoutfile();
|
fd_out = open_tmpoutfile();
|
||||||
|
|
@ -708,7 +706,7 @@ static void compress_file(void)
|
||||||
|
|
||||||
if (!KEEP_FILES) {
|
if (!KEEP_FILES) {
|
||||||
if (unlikely(unlink(control.infile)))
|
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);
|
free(control.outfile);
|
||||||
|
|
|
||||||
4
runzip.c
4
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+ */
|
/* Note the offset is in a different format v0.40+ */
|
||||||
offset = read_vchars(ss, 0, chunk_bytes);
|
offset = read_vchars(ss, 0, chunk_bytes);
|
||||||
if (unlikely(lseek(fd_hist, cur_pos - offset, SEEK_SET) == -1))
|
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",
|
fatal("Seek failed by %d from %d on history file in unzip_match\n",
|
||||||
offset, cur_pos, strerror(errno));
|
offset, cur_pos);
|
||||||
|
|
||||||
buf = (uchar *)malloc(len);
|
buf = (uchar *)malloc(len);
|
||||||
if (unlikely(!buf))
|
if (unlikely(!buf))
|
||||||
|
|
|
||||||
2
rzip.c
2
rzip.c
|
|
@ -753,7 +753,7 @@ void rzip_fd(int fd_in, int fd_out)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(fstat(fd_in, &s)))
|
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) {
|
if (!STDIN) {
|
||||||
len = control.st_size = s.st_size;
|
len = control.st_size = s.st_size;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue