mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Remove unused variables and functions.
This commit is contained in:
parent
b27e1df879
commit
915edb78a2
4
lrzip.c
4
lrzip.c
|
|
@ -462,8 +462,6 @@ static void get_hash(rzip_control *control, int make_hash)
|
||||||
{
|
{
|
||||||
char *passphrase, *testphrase;
|
char *passphrase, *testphrase;
|
||||||
struct termios termios_p;
|
struct termios termios_p;
|
||||||
i64 i;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
passphrase = calloc(PASS_LEN, 1);
|
passphrase = calloc(PASS_LEN, 1);
|
||||||
testphrase = calloc(PASS_LEN, 1);
|
testphrase = calloc(PASS_LEN, 1);
|
||||||
|
|
@ -740,11 +738,11 @@ void get_fileinfo(rzip_control *control)
|
||||||
i64 expected_size, infile_size, chunk_size = 0, chunk_total = 0;
|
i64 expected_size, infile_size, chunk_size = 0, chunk_total = 0;
|
||||||
int header_length, stream = 0, chunk = 0;
|
int header_length, stream = 0, chunk = 0;
|
||||||
char *tmp, *infilecopy = NULL;
|
char *tmp, *infilecopy = NULL;
|
||||||
int seekspot, fd_in;
|
|
||||||
char chunk_byte = 0;
|
char chunk_byte = 0;
|
||||||
long double cratio;
|
long double cratio;
|
||||||
uchar ctype = 0;
|
uchar ctype = 0;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
int fd_in;
|
||||||
|
|
||||||
if (!STDIN) {
|
if (!STDIN) {
|
||||||
struct stat fdin_stat;
|
struct stat fdin_stat;
|
||||||
|
|
|
||||||
27
runzip.c
27
runzip.c
|
|
@ -71,7 +71,6 @@ static inline u32 read_u32(rzip_control *control, void *ss, int stream)
|
||||||
/* Read a variable length of chars dependant on how big the chunk was */
|
/* Read a variable length of chars dependant on how big the chunk was */
|
||||||
static inline i64 read_vchars(rzip_control *control, void *ss, int stream, int length)
|
static inline i64 read_vchars(rzip_control *control, void *ss, int stream, int length)
|
||||||
{
|
{
|
||||||
int bytes;
|
|
||||||
i64 s = 0;
|
i64 s = 0;
|
||||||
|
|
||||||
if (unlikely(read_stream(control, ss, stream, (uchar *)&s, length) != length))
|
if (unlikely(read_stream(control, ss, stream, (uchar *)&s, length) != length))
|
||||||
|
|
@ -87,20 +86,6 @@ static i64 seekcur_fdout(rzip_control *control)
|
||||||
return (control->out_relofs + control->out_ofs);
|
return (control->out_relofs + control->out_ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static i64 seekto_fdout(rzip_control *control, i64 pos)
|
|
||||||
{
|
|
||||||
if (!TMP_OUTBUF)
|
|
||||||
return lseek(control->fd_out, pos, SEEK_SET);
|
|
||||||
control->out_ofs = pos - control->out_relofs;
|
|
||||||
if (control->out_ofs > control->out_len)
|
|
||||||
control->out_len = control->out_ofs;
|
|
||||||
if (unlikely(control->out_ofs < 0 || control->out_ofs > control->out_maxlen)) {
|
|
||||||
print_err("Trying to seek outside tmpoutbuf to %lld in seekto_fdout\n", control->out_ofs);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
static i64 seekto_fdhist(rzip_control *control, i64 pos)
|
static i64 seekto_fdhist(rzip_control *control, i64 pos)
|
||||||
{
|
{
|
||||||
if (!TMP_OUTBUF)
|
if (!TMP_OUTBUF)
|
||||||
|
|
@ -160,7 +145,7 @@ static i64 read_header(rzip_control *control, void *ss, uchar *head)
|
||||||
return read_vchars(control, ss, 0, chunk_bytes);
|
return read_vchars(control, ss, 0, chunk_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static i64 unzip_literal(rzip_control *control, void *ss, i64 len, int fd_out, uint32 *cksum)
|
static i64 unzip_literal(rzip_control *control, void *ss, i64 len, uint32 *cksum)
|
||||||
{
|
{
|
||||||
i64 stream_read;
|
i64 stream_read;
|
||||||
uchar *buf;
|
uchar *buf;
|
||||||
|
|
@ -200,7 +185,7 @@ static i64 read_fdhist(rzip_control *control, void *buf, i64 len)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static i64 unzip_match(rzip_control *control, void *ss, i64 len, int fd_out, int fd_hist, uint32 *cksum, int chunk_bytes)
|
static i64 unzip_match(rzip_control *control, void *ss, i64 len, uint32 *cksum, int chunk_bytes)
|
||||||
{
|
{
|
||||||
i64 offset, n, total, cur_pos;
|
i64 offset, n, total, cur_pos;
|
||||||
uchar *buf, *off_buf;
|
uchar *buf, *off_buf;
|
||||||
|
|
@ -251,7 +236,7 @@ static i64 unzip_match(rzip_control *control, void *ss, i64 len, int fd_out, int
|
||||||
/* decompress a section of an open file. Call fatal() on error
|
/* decompress a section of an open file. Call fatal() on error
|
||||||
return the number of bytes that have been retrieved
|
return the number of bytes that have been retrieved
|
||||||
*/
|
*/
|
||||||
static i64 runzip_chunk(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 expected_size, i64 tally)
|
static i64 runzip_chunk(rzip_control *control, int fd_in, i64 expected_size, i64 tally)
|
||||||
{
|
{
|
||||||
uint32 good_cksum, cksum = 0;
|
uint32 good_cksum, cksum = 0;
|
||||||
i64 len, ofs, total = 0;
|
i64 len, ofs, total = 0;
|
||||||
|
|
@ -308,11 +293,11 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, int fd_out, int fd_his
|
||||||
while ((len = read_header(control, ss, &head)) || head) {
|
while ((len = read_header(control, ss, &head)) || head) {
|
||||||
switch (head) {
|
switch (head) {
|
||||||
case 0:
|
case 0:
|
||||||
total += unzip_literal(control, ss, len, fd_out, &cksum);
|
total += unzip_literal(control, ss, len, &cksum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
total += unzip_match(control, ss, len, fd_out, fd_hist, &cksum, chunk_bytes);
|
total += unzip_match(control, ss, len, &cksum, chunk_bytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (expected_size) {
|
if (expected_size) {
|
||||||
|
|
@ -354,7 +339,7 @@ i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 exp
|
||||||
gettimeofday(&start,NULL);
|
gettimeofday(&start,NULL);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
total += runzip_chunk(control, fd_in, fd_out, fd_hist, expected_size, total);
|
total += runzip_chunk(control, fd_in, expected_size, total);
|
||||||
if (TMP_OUTBUF)
|
if (TMP_OUTBUF)
|
||||||
flush_tmpoutbuf(control);
|
flush_tmpoutbuf(control);
|
||||||
else if (STDOUT)
|
else if (STDOUT)
|
||||||
|
|
|
||||||
65
stream.c
65
stream.c
|
|
@ -712,18 +712,6 @@ static void read_fdin(struct rzip_control *control, i64 len)
|
||||||
control->in_len = control->in_ofs + len;
|
control->in_len = control->in_ofs + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static i64 seekto_fdin(rzip_control *control, i64 pos)
|
|
||||||
{
|
|
||||||
if (!TMP_INBUF)
|
|
||||||
return lseek(control->fd_in, pos, SEEK_SET);
|
|
||||||
control->in_ofs = pos;
|
|
||||||
if (unlikely(control->in_ofs > control->in_len || control->in_ofs < 0)) {
|
|
||||||
print_err("Tried to seek outside of in_ofs range in seekto_fdin\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ditto for read */
|
/* Ditto for read */
|
||||||
ssize_t read_1g(rzip_control *control, int fd, void *buf, i64 len)
|
ssize_t read_1g(rzip_control *control, int fd, void *buf, i64 len)
|
||||||
{
|
{
|
||||||
|
|
@ -770,7 +758,7 @@ read_fd:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write to a file, return 0 on success and -1 on failure */
|
/* write to a file, return 0 on success and -1 on failure */
|
||||||
static int write_buf(rzip_control *control, int f, uchar *p, i64 len)
|
static int write_buf(rzip_control *control, uchar *p, i64 len)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
|
|
@ -787,15 +775,15 @@ static int write_buf(rzip_control *control, int f, uchar *p, i64 len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write a byte */
|
/* write a byte */
|
||||||
static inline int write_u8(rzip_control *control, int f, uchar v)
|
static inline int write_u8(rzip_control *control, uchar v)
|
||||||
{
|
{
|
||||||
return write_buf(control, f, &v, 1);
|
return write_buf(control, &v, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int write_val(rzip_control *control, int f, i64 v, int len)
|
static inline int write_val(rzip_control *control, i64 v, int len)
|
||||||
{
|
{
|
||||||
v = htole64(v);
|
v = htole64(v);
|
||||||
return write_buf(control, f, (uchar *)&v, len);
|
return write_buf(control, (uchar *)&v, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_buf(rzip_control *control, int f, uchar *p, i64 len)
|
static int read_buf(rzip_control *control, int f, uchar *p, i64 len)
|
||||||
|
|
@ -845,7 +833,7 @@ static inline int read_val(rzip_control *control, int f, i64 *v, int len)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_seekto(rzip_control *control, struct stream_info *sinfo, i64 spos, i64 pos)
|
static int fd_seekto(struct stream_info *sinfo, i64 spos, i64 pos)
|
||||||
{
|
{
|
||||||
if (unlikely(lseek(sinfo->fd, spos, SEEK_SET) != spos)) {
|
if (unlikely(lseek(sinfo->fd, spos, SEEK_SET) != spos)) {
|
||||||
print_err("Failed to seek to %lld in stream\n", pos);
|
print_err("Failed to seek to %lld in stream\n", pos);
|
||||||
|
|
@ -869,7 +857,7 @@ static int seekto(rzip_control *control, struct stream_info *sinfo, i64 pos)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fd_seekto(control, sinfo, spos, pos);
|
return fd_seekto(sinfo, spos, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_seekto(rzip_control *control, struct stream_info *sinfo, i64 pos)
|
static int read_seekto(rzip_control *control, struct stream_info *sinfo, i64 pos)
|
||||||
|
|
@ -887,7 +875,7 @@ static int read_seekto(rzip_control *control, struct stream_info *sinfo, i64 pos
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fd_seekto(control, sinfo, spos, pos);
|
return fd_seekto(sinfo, spos, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static i64 get_seek(rzip_control *control, int fd)
|
static i64 get_seek(rzip_control *control, int fd)
|
||||||
|
|
@ -1077,7 +1065,6 @@ void *open_stream_in(rzip_control *control, int f, int n, char chunk_bytes)
|
||||||
{
|
{
|
||||||
struct stream_info *sinfo;
|
struct stream_info *sinfo;
|
||||||
int total_threads, i;
|
int total_threads, i;
|
||||||
uchar salt[SALT_LEN];
|
|
||||||
i64 header_length;
|
i64 header_length;
|
||||||
|
|
||||||
sinfo = calloc(sizeof(struct stream_info), 1);
|
sinfo = calloc(sizeof(struct stream_info), 1);
|
||||||
|
|
@ -1233,7 +1220,7 @@ static void rewrite_encrypted(rzip_control *control, struct stream_info *sinfo,
|
||||||
get_rand(head, SALT_LEN);
|
get_rand(head, SALT_LEN);
|
||||||
if (unlikely(seekto(control, sinfo, ofs - SALT_LEN)))
|
if (unlikely(seekto(control, sinfo, ofs - SALT_LEN)))
|
||||||
failure("Failed to seekto buf ofs in rewrite_encrypted\n");
|
failure("Failed to seekto buf ofs in rewrite_encrypted\n");
|
||||||
if (unlikely(write_buf(control, sinfo->fd, head, SALT_LEN)))
|
if (unlikely(write_buf(control, head, SALT_LEN)))
|
||||||
failure("Failed to write_buf head in rewrite_encrypted\n");
|
failure("Failed to write_buf head in rewrite_encrypted\n");
|
||||||
if (unlikely(read_buf(control, sinfo->fd, buf, 25)))
|
if (unlikely(read_buf(control, sinfo->fd, buf, 25)))
|
||||||
failure("Failed to read_buf buf in rewrite_encrypted\n");
|
failure("Failed to read_buf buf in rewrite_encrypted\n");
|
||||||
|
|
@ -1242,7 +1229,7 @@ static void rewrite_encrypted(rzip_control *control, struct stream_info *sinfo,
|
||||||
|
|
||||||
if (unlikely(seekto(control, sinfo, ofs)))
|
if (unlikely(seekto(control, sinfo, ofs)))
|
||||||
failure("Failed to seek back to ofs in rewrite_encrypted\n");
|
failure("Failed to seek back to ofs in rewrite_encrypted\n");
|
||||||
if (unlikely(write_buf(control, sinfo->fd, buf, 25)))
|
if (unlikely(write_buf(control, buf, 25)))
|
||||||
failure("Failed to write_buf encrypted buf in rewrite_encrypted\n");
|
failure("Failed to write_buf encrypted buf in rewrite_encrypted\n");
|
||||||
free(head);
|
free(head);
|
||||||
seekto(control, sinfo, cur_ofs);
|
seekto(control, sinfo, cur_ofs);
|
||||||
|
|
@ -1337,13 +1324,13 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write chunk bytes of this block */
|
/* Write chunk bytes of this block */
|
||||||
write_u8(control, ctis->fd, ctis->chunk_bytes);
|
write_u8(control, ctis->chunk_bytes);
|
||||||
|
|
||||||
/* Write whether this is the last chunk, followed by the size
|
/* Write whether this is the last chunk, followed by the size
|
||||||
* of this chunk */
|
* of this chunk */
|
||||||
write_u8(control, ctis->fd, control->eof);
|
write_u8(control, control->eof);
|
||||||
if (!ENCRYPT)
|
if (!ENCRYPT)
|
||||||
write_val(control, ctis->fd, ctis->size, ctis->chunk_bytes);
|
write_val(control, ctis->size, ctis->chunk_bytes);
|
||||||
|
|
||||||
/* First chunk of this stream, write headers */
|
/* First chunk of this stream, write headers */
|
||||||
ctis->initial_pos = get_seek(control, ctis->fd);
|
ctis->initial_pos = get_seek(control, ctis->fd);
|
||||||
|
|
@ -1352,15 +1339,15 @@ retry:
|
||||||
/* If encrypting, we leave SALT_LEN room to write in salt
|
/* If encrypting, we leave SALT_LEN room to write in salt
|
||||||
* later */
|
* later */
|
||||||
if (ENCRYPT) {
|
if (ENCRYPT) {
|
||||||
if (unlikely(write_val(control, ctis->fd, 0, SALT_LEN)))
|
if (unlikely(write_val(control, 0, SALT_LEN)))
|
||||||
fatal("Failed to write_buf blank salt in compthread %d\n", i);
|
fatal("Failed to write_buf blank salt in compthread %d\n", i);
|
||||||
ctis->cur_pos += SALT_LEN;
|
ctis->cur_pos += SALT_LEN;
|
||||||
}
|
}
|
||||||
ctis->s[j].last_head = ctis->cur_pos + 1 + (write_len * 2);
|
ctis->s[j].last_head = ctis->cur_pos + 1 + (write_len * 2);
|
||||||
write_u8(control, ctis->fd, CTYPE_NONE);
|
write_u8(control, CTYPE_NONE);
|
||||||
write_val(control, ctis->fd, 0, write_len);
|
write_val(control, 0, write_len);
|
||||||
write_val(control, ctis->fd, 0, write_len);
|
write_val(control, 0, write_len);
|
||||||
write_val(control, ctis->fd, 0, write_len);
|
write_val(control, 0, write_len);
|
||||||
ctis->cur_pos += 1 + (write_len * 3);
|
ctis->cur_pos += 1 + (write_len * 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1368,7 +1355,7 @@ retry:
|
||||||
if (unlikely(seekto(control, ctis, ctis->s[cti->streamno].last_head)))
|
if (unlikely(seekto(control, ctis, ctis->s[cti->streamno].last_head)))
|
||||||
fatal("Failed to seekto in compthread %d\n", i);
|
fatal("Failed to seekto in compthread %d\n", i);
|
||||||
|
|
||||||
if (unlikely(write_val(control, ctis->fd, ctis->cur_pos, write_len)))
|
if (unlikely(write_val(control, ctis->cur_pos, write_len)))
|
||||||
fatal("Failed to write_val cur_pos in compthread %d\n", i);
|
fatal("Failed to write_val cur_pos in compthread %d\n", i);
|
||||||
|
|
||||||
if (ENCRYPT)
|
if (ENCRYPT)
|
||||||
|
|
@ -1381,28 +1368,28 @@ retry:
|
||||||
print_maxverbose("Thread %ld writing %lld compressed bytes from stream %d\n", i, padded_len, cti->streamno);
|
print_maxverbose("Thread %ld writing %lld compressed bytes from stream %d\n", i, padded_len, cti->streamno);
|
||||||
|
|
||||||
if (ENCRYPT) {
|
if (ENCRYPT) {
|
||||||
if (unlikely(write_val(control, ctis->fd, 0, SALT_LEN)))
|
if (unlikely(write_val(control, 0, SALT_LEN)))
|
||||||
fatal("Failed to write_buf header salt in compthread %d\n", i);
|
fatal("Failed to write_buf header salt in compthread %d\n", i);
|
||||||
ctis->cur_pos += SALT_LEN;
|
ctis->cur_pos += SALT_LEN;
|
||||||
ctis->s[cti->streamno].last_headofs = ctis->cur_pos;
|
ctis->s[cti->streamno].last_headofs = ctis->cur_pos;
|
||||||
}
|
}
|
||||||
/* We store the actual c_len even though we might pad it out */
|
/* We store the actual c_len even though we might pad it out */
|
||||||
if (unlikely(write_u8(control, ctis->fd, cti->c_type) ||
|
if (unlikely(write_u8(control, cti->c_type) ||
|
||||||
write_val(control, ctis->fd, cti->c_len, write_len) ||
|
write_val(control, cti->c_len, write_len) ||
|
||||||
write_val(control, ctis->fd, cti->s_len, write_len) ||
|
write_val(control, cti->s_len, write_len) ||
|
||||||
write_val(control, ctis->fd, 0, write_len))) {
|
write_val(control, 0, write_len))) {
|
||||||
fatal("Failed write in compthread %d\n", i);
|
fatal("Failed write in compthread %d\n", i);
|
||||||
}
|
}
|
||||||
ctis->cur_pos += 1 + (write_len * 3);
|
ctis->cur_pos += 1 + (write_len * 3);
|
||||||
|
|
||||||
if (ENCRYPT) {
|
if (ENCRYPT) {
|
||||||
get_rand(cti->salt, SALT_LEN);
|
get_rand(cti->salt, SALT_LEN);
|
||||||
if (unlikely(write_buf(control, ctis->fd, cti->salt, SALT_LEN)))
|
if (unlikely(write_buf(control, cti->salt, SALT_LEN)))
|
||||||
fatal("Failed to write_buf block salt in compthread %d\n", i);
|
fatal("Failed to write_buf block salt in compthread %d\n", i);
|
||||||
lrz_encrypt(control, cti->s_buf, padded_len, cti->salt);
|
lrz_encrypt(control, cti->s_buf, padded_len, cti->salt);
|
||||||
ctis->cur_pos += SALT_LEN;
|
ctis->cur_pos += SALT_LEN;
|
||||||
}
|
}
|
||||||
if (unlikely(write_buf(control, ctis->fd, cti->s_buf, padded_len)))
|
if (unlikely(write_buf(control, cti->s_buf, padded_len)))
|
||||||
fatal("Failed to write_buf s_buf in compthread %d\n", i);
|
fatal("Failed to write_buf s_buf in compthread %d\n", i);
|
||||||
|
|
||||||
ctis->cur_pos += padded_len;
|
ctis->cur_pos += padded_len;
|
||||||
|
|
|
||||||
1
util.c
1
util.c
|
|
@ -192,7 +192,6 @@ void lrz_crypt(const rzip_control *control, uchar *buf, i64 len, const uchar *sa
|
||||||
uchar tmp0[CBC_LEN], tmp1[CBC_LEN];
|
uchar tmp0[CBC_LEN], tmp1[CBC_LEN];
|
||||||
aes_context aes_ctx;
|
aes_context aes_ctx;
|
||||||
i64 N, M;
|
i64 N, M;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Generate unique key and IV for each block of data based on salt */
|
/* Generate unique key and IV for each block of data based on salt */
|
||||||
mlock(&aes_ctx, sizeof(aes_ctx));
|
mlock(&aes_ctx, sizeof(aes_ctx));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue