mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-02-25 16:54:13 +01:00
Tidy gotos
This commit is contained in:
parent
007bf5de93
commit
5627479c60
28
stream.c
28
stream.c
|
|
@ -1121,7 +1121,8 @@ void *open_stream_in(rzip_control *control, int f, int n, char chunk_bytes)
|
|||
}
|
||||
}
|
||||
sinfo->initial_pos = get_readseek(control, f);
|
||||
if (unlikely(sinfo->initial_pos == -1)) goto failed;
|
||||
if (unlikely(sinfo->initial_pos == -1))
|
||||
goto failed;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
uchar c, enc_head[25 + SALT_LEN];
|
||||
|
|
@ -1171,8 +1172,10 @@ again:
|
|||
}
|
||||
sinfo->total_read += header_length;
|
||||
|
||||
if (ENCRYPT)
|
||||
if (unlikely(!decrypt_header(control, enc_head, &c, &v1, &v2, &sinfo->s[i].last_head))) goto failed;
|
||||
if (ENCRYPT) {
|
||||
if (unlikely(!decrypt_header(control, enc_head, &c, &v1, &v2, &sinfo->s[i].last_head)))
|
||||
goto failed;
|
||||
}
|
||||
|
||||
v1 = le64toh(v1);
|
||||
v2 = le64toh(v2);
|
||||
|
|
@ -1227,16 +1230,17 @@ static bool rewrite_encrypted(rzip_control *control, struct stream_info *sinfo,
|
|||
if (unlikely(!head))
|
||||
fatal_return(("Failed to malloc head in rewrite_encrypted\n"), false);
|
||||
buf = head + SALT_LEN;
|
||||
if (unlikely(!get_rand(control, head, SALT_LEN))) goto error;
|
||||
if (unlikely(!get_rand(control, head, SALT_LEN)))
|
||||
goto error;
|
||||
if (unlikely(seekto(control, sinfo, ofs - SALT_LEN)))
|
||||
failure_goto(("Failed to seekto buf ofs in rewrite_encrypted\n"), error);
|
||||
if (unlikely(write_buf(control, head, SALT_LEN)))
|
||||
failure_goto(("Failed to write_buf head in rewrite_encrypted\n"), error);
|
||||
if (unlikely(read_buf(control, sinfo->fd, buf, 25)))
|
||||
|
||||
failure_goto(("Failed to read_buf buf in rewrite_encrypted\n"), error);
|
||||
|
||||
if (unlikely(!lrz_encrypt(control, buf, 25, head))) goto error;
|
||||
if (unlikely(!lrz_encrypt(control, buf, 25, head)))
|
||||
goto error;
|
||||
|
||||
if (unlikely(seekto(control, sinfo, ofs)))
|
||||
failure_goto(("Failed to seek back to ofs in rewrite_encrypted\n"), error);
|
||||
|
|
@ -1306,7 +1310,8 @@ retry:
|
|||
cti->s_buf = realloc(cti->s_buf, MIN_SIZE);
|
||||
if (unlikely(!cti->s_buf))
|
||||
fatal_goto(("Failed to realloc s_buf in compthread\n"), error);
|
||||
if (unlikely(!get_rand(control, cti->s_buf + cti->c_len, MIN_SIZE - cti->c_len))) goto error;
|
||||
if (unlikely(!get_rand(control, cti->s_buf + cti->c_len, MIN_SIZE - cti->c_len)))
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* If compression fails for whatever reason multithreaded, then wait
|
||||
|
|
@ -1362,7 +1367,8 @@ retry:
|
|||
|
||||
/* First chunk of this stream, write headers */
|
||||
ctis->initial_pos = get_seek(control, ctis->fd);
|
||||
if (unlikely(ctis->initial_pos == -1)) goto error;
|
||||
if (unlikely(ctis->initial_pos == -1))
|
||||
goto error;
|
||||
|
||||
print_maxverbose("Writing initial header at %lld\n", ctis->initial_pos);
|
||||
for (j = 0; j < ctis->num_streams; j++) {
|
||||
|
|
@ -1418,10 +1424,12 @@ retry:
|
|||
ctis->cur_pos += 1 + (write_len * 3);
|
||||
|
||||
if (ENCRYPT) {
|
||||
if (unlikely(!get_rand(control, cti->salt, SALT_LEN))) goto error;
|
||||
if (unlikely(!get_rand(control, cti->salt, SALT_LEN)))
|
||||
goto error;
|
||||
if (unlikely(write_buf(control, cti->salt, SALT_LEN)))
|
||||
fatal_goto(("Failed to write_buf block salt in compthread %d\n", i), error);
|
||||
if (unlikely(!lrz_encrypt(control, cti->s_buf, padded_len, cti->salt))) goto error;
|
||||
if (unlikely(!lrz_encrypt(control, cti->s_buf, padded_len, cti->salt)))
|
||||
goto error;
|
||||
ctis->cur_pos += SALT_LEN;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue