diff --git a/decompress_demo.c b/decompress_demo.c index 08ae68f..56f0b99 100644 --- a/decompress_demo.c +++ b/decompress_demo.c @@ -1,3 +1,20 @@ +/* + Copyright (C) 2012 Con Kolivas + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + #ifdef HAVE_CONFIG_H # include "config.h" #endif diff --git a/liblrzip.c b/liblrzip.c index cfcf926..0218a79 100644 --- a/liblrzip.c +++ b/liblrzip.c @@ -1,3 +1,20 @@ +/* + Copyright (C) 2012 Con Kolivas + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + #include #ifdef HAVE_SYS_TIME_H diff --git a/liblrzip_demo.c b/liblrzip_demo.c index 6ce9b9d..e8ead86 100644 --- a/liblrzip_demo.c +++ b/liblrzip_demo.c @@ -1,3 +1,20 @@ +/* + Copyright (C) 2012 Con Kolivas + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + #ifdef HAVE_CONFIG_H # include "config.h" #endif diff --git a/lrzip.c b/lrzip.c index de3024b..ae03665 100644 --- a/lrzip.c +++ b/lrzip.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2011 Con Kolivas + Copyright (C) 2006-2012 Con Kolivas Copyright (C) 2011 Peter Hyman Copyright (C) 1998-2003 Andrew Tridgell @@ -258,7 +258,8 @@ bool read_magic(rzip_control *control, int fd_in, i64 *expected_size) if (unlikely(read(fd_in, magic, 24) != 24)) fatal_return(("Failed to read magic header\n"), false); - if (unlikely(!get_magic(control, magic))) return false; + if (unlikely(!get_magic(control, magic))) + return false; *expected_size = control->st_size; return true; } @@ -350,9 +351,11 @@ bool flush_tmpoutbuf(rzip_control *control) if (!TEST_ONLY) { print_maxverbose("Dumping buffer to physical file.\n"); if (STDOUT) { - if (unlikely(!fwrite_stdout(control, control->tmp_outbuf, control->out_len))) return false; + if (unlikely(!fwrite_stdout(control, control->tmp_outbuf, control->out_len))) + return false; } else { - if (unlikely(!write_fdout(control, control->tmp_outbuf, control->out_len))) return false; + if (unlikely(!write_fdout(control, control->tmp_outbuf, control->out_len))) + return false; } } control->out_relofs += control->out_len; @@ -679,12 +682,14 @@ bool decompress_file(rzip_control *control) if (STDIN) { fd_in = open_tmpinfile(control); - if (unlikely(fd_in == -1)) return false; + if (unlikely(fd_in == -1)) + return false; read_tmpinmagic(control); if (ENCRYPT) failure_return(("Cannot decompress encrypted file from STDIN\n"), false); expected_size = control->st_size; - if (unlikely(!open_tmpinbuf(control))) return false; + if (unlikely(!open_tmpinbuf(control))) + return false; } else { fd_in = open(infilecopy, O_RDONLY); if (unlikely(fd_in == -1)) { @@ -712,7 +717,8 @@ bool decompress_file(rzip_control *control) /* Can't copy permissions from STDIN */ if (!STDIN) - if (unlikely(!preserve_perms(control, fd_in, fd_out))) return false; + if (unlikely(!preserve_perms(control, fd_in, fd_out))) + return false; } else { fd_out = open_tmpoutfile(control); if (unlikely(fd_out == -1)) @@ -725,10 +731,12 @@ bool decompress_file(rzip_control *control) fatal_return(("Failed to unlink tmpfile: %s\n", control->outfile), false); } - if (unlikely(!open_tmpoutbuf(control))) return false; + if (unlikely(!open_tmpoutbuf(control))) + return false; if (!STDIN) - if (unlikely(!read_magic(control, fd_in, &expected_size))) return false; + if (unlikely(!read_magic(control, fd_in, &expected_size))) + return false; if (!STDOUT) { /* Check if there's enough free space on the device chosen to fit the @@ -755,14 +763,17 @@ bool decompress_file(rzip_control *control) print_verbose("being used for integrity testing.\n"); if (ENCRYPT) - if (unlikely(!get_hash(control, 0))) return false; + if (unlikely(!get_hash(control, 0))) + return false; print_progress("Decompressing...\n"); - if (unlikely(runzip_fd(control, fd_in, fd_out, fd_hist, expected_size) < 0)) return false; + if (unlikely(runzip_fd(control, fd_in, fd_out, fd_hist, expected_size) < 0)) + return false; if (STDOUT && !TMP_OUTBUF) - if (unlikely(!dump_tmpoutfile(control, fd_out))) return false; + if (unlikely(!dump_tmpoutfile(control, fd_out))) + return false; /* if we get here, no fatal_return(( errors during decompression */ print_progress("\r"); @@ -940,7 +951,8 @@ next_chunk: if (unlikely(lseek(fd_in, stream_head[stream] + ofs, SEEK_SET)) == -1) fatal_goto(("Failed to seek to header data in get_fileinfo\n"), error); - if (unlikely(!get_header_info(control, fd_in, &ctype, &c_len, &u_len, &last_head, chunk_byte))) return false; + if (unlikely(!get_header_info(control, fd_in, &ctype, &c_len, &u_len, &last_head, chunk_byte))) + return false; print_verbose("Stream: %d\n", stream); print_maxverbose("Offset: %lld\n", ofs); @@ -953,7 +965,8 @@ next_chunk: if (unlikely(head_off = lseek(fd_in, last_head + ofs, SEEK_SET)) == -1) fatal_goto(("Failed to seek to header data in get_fileinfo\n"), error); if (unlikely(!get_header_info(control, fd_in, &ctype, &c_len, &u_len, - &last_head, chunk_byte))) return false; + &last_head, chunk_byte))) + return false; if (unlikely(last_head < 0 || c_len < 0 || u_len < 0)) failure_goto(("Entry negative, likely corrupted archive.\n"), error); print_verbose("%d\t", block); @@ -1080,7 +1093,8 @@ bool compress_file(rzip_control *control) if (MD5_RELIABLE) control->flags |= FLAG_MD5; if (ENCRYPT) - if (unlikely(!get_hash(control, 1))) return false; + if (unlikely(!get_hash(control, 1))) + return false; memset(header, 0, sizeof(header)); if (!STDIN) { @@ -1200,7 +1214,8 @@ bool initialize_control(rzip_control *control) control->suffix = strdup(".lrz"); control->compression_level = 7; control->ramsize = get_ram(control); - if (unlikely(control->ramsize == -1)) return false; + if (unlikely(control->ramsize == -1)) + return false; /* for testing single CPU */ control->threads = PROCESSORS; /* get CPUs for LZMA */ control->page_size = PAGE_SIZE; @@ -1213,7 +1228,8 @@ bool initialize_control(rzip_control *control) fatal_return(("Failed to gettimeofday in main\n"), false); control->secs = tv.tv_sec; control->encloops = nloops(control->secs, control->salt, control->salt + 1); - if (unlikely(!get_rand(control, control->salt + 2, 6))) return false; + if (unlikely(!get_rand(control, control->salt + 2, 6))) + return false; /* Get Temp Dir */ eptr = getenv("TMP"); diff --git a/main.c b/main.c index bae4bb6..261e400 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2011 Con Kolivas + Copyright (C) 2006-2012 Con Kolivas Copyright (C) 2011 Peter Hyman Copyright (C) 1998-2003 Andrew Tridgell diff --git a/runzip.c b/runzip.c index 452077a..e3a7694 100644 --- a/runzip.c +++ b/runzip.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2011 Con Kolivas + Copyright (C) 2006-2012 Con Kolivas Copyright (C) 1998-2003 Andrew Tridgell This program is free software; you can redistribute it and/or modify @@ -146,7 +146,8 @@ static i64 read_header(rzip_control *control, void *ss, uchar *head) if (control->major_version == 0 && control->minor_version == 4) chunk_bytes = 8; *head = read_u8(control, ss, 0, &err); - if (err) return -1; + if (err) + return -1; return read_vchars(control, ss, 0, chunk_bytes); } @@ -209,7 +210,8 @@ static i64 unzip_match(rzip_control *control, void *ss, i64 len, uint32 *cksum, /* Note the offset is in a different format v0.40+ */ offset = read_vchars(control, ss, 0, chunk_bytes); - if (unlikely(offset == -1)) return -1; + if (unlikely(offset == -1)) + return -1; if (unlikely(seekto_fdhist(control, cur_pos - offset) == -1)) fatal_return(("Seek failed by %d from %d on history file in unzip_match\n", offset, cur_pos), -1); @@ -309,7 +311,8 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, i64 expected_size, i64 while ((len = read_header(control, ss, &head)) || head) { i64 u; - if (unlikely(len == -1)) return -1; + if (unlikely(len == -1)) + return -1; switch (head) { case 0: u = unzip_literal(control, ss, len, &cksum); @@ -374,16 +377,20 @@ i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 exp do { u = runzip_chunk(control, fd_in, expected_size, total); - if (unlikely(u == -1)) return -1; + if (unlikely(u == -1)) + return -1; total += u; if (TMP_OUTBUF) - { if (unlikely(!flush_tmpoutbuf(control))) return -1; } + { if (unlikely(!flush_tmpoutbuf(control))) + return -1; } else if (STDOUT) - { if (unlikely(!dump_tmpoutfile(control, fd_out))) return -1; } + { if (unlikely(!dump_tmpoutfile(control, fd_out))) + return -1; } if (TMP_INBUF) clear_tmpinbuf(control); else if (STDIN) - if (unlikely(!clear_tmpinfile(control))) return -1; + if (unlikely(!clear_tmpinfile(control))) + return -1; } while (total < expected_size || (!expected_size && !control->eof)); gettimeofday(&end,NULL); @@ -406,7 +413,8 @@ i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 exp if (unlikely(read_1g(control, fd_in, md5_stored, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE)) fatal_return(("Failed to read md5 data in runzip_fd\n"), -1); if (ENCRYPT) - if (unlikely(!lrz_decrypt(control, md5_stored, MD5_DIGEST_SIZE, control->salt_pass))) return -1; + if (unlikely(!lrz_decrypt(control, md5_stored, MD5_DIGEST_SIZE, control->salt_pass))) + return -1; for (i = 0; i < MD5_DIGEST_SIZE; i++) if (md5_stored[i] != control->md5_resblock[i]) { print_output("MD5 CHECK FAILED.\nStored:"); diff --git a/rzip.c b/rzip.c index 2916413..b1222d2 100644 --- a/rzip.c +++ b/rzip.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2011 Con Kolivas + Copyright (C) 2006-2012 Con Kolivas Copyright (C) 1998 Andrew Tridgell Modified to use flat hash, memory limit and variable hash culling @@ -177,7 +177,8 @@ static uchar *sliding_get_sb(rzip_control *control, struct sliding_buffer *sb, i if (p >= sb->offset_high && p < (sb->offset_high + sb->size_high)) return (sb->buf_high + (p - sb->offset_high)); /* p is not within the low or high buffer range */ - if (unlikely(!remap_high_sb(control, &control->sb, p))) return NULL; + if (unlikely(!remap_high_sb(control, &control->sb, p))) + return NULL; return (sb->buf_high + (p - sb->offset_high)); } @@ -238,8 +239,10 @@ static inline bool put_vchars(rzip_control *control, void *ss, i64 s, int length static bool put_header(rzip_control *control, void *ss, uchar head, i64 len) { - if (unlikely(!put_u8(control, ss, head))) return false; - if (unlikely(!put_vchars(control, ss, len, 2))) return false; + if (unlikely(!put_u8(control, ss, head))) + return false; + if (unlikely(!put_vchars(control, ss, len, 2))) + return false; return true; } @@ -252,8 +255,10 @@ static bool put_match(rzip_control *control, struct rzip_state *st, i64 p, i64 o n = 0xFFFF; ofs = (p - offset); - if (unlikely(!put_header(control, st->ss, 1, n))) return false; - if (unlikely(!put_vchars(control, st->ss, ofs, st->chunk_bytes))) return false; + if (unlikely(!put_header(control, st->ss, 1, n))) + return false; + if (unlikely(!put_vchars(control, st->ss, ofs, st->chunk_bytes))) + return false; st->stats.matches++; st->stats.match_bytes += n; @@ -279,7 +284,8 @@ static int write_sbstream(rzip_control *control, void *ss, int stream, i64 p, i6 len -= n; if (sinfo->s[stream].buflen == sinfo->bufsize) - if (unlikely(!flush_buffer(control, sinfo, stream))) return -1; + if (unlikely(!flush_buffer(control, sinfo, stream))) + return -1; } return 0; } @@ -294,7 +300,8 @@ static bool put_literal(rzip_control *control, struct rzip_state *st, i64 last, st->stats.literals++; st->stats.literal_bytes += len; - if (unlikely(!put_header(control, st->ss, 0, len))) return false; + if (unlikely(!put_header(control, st->ss, 0, len))) + return false; if (unlikely(len && write_sbstream(control, st->ss, 1, last, len))) fatal_return(("Failed to write_stream in put_literal\n"), false); @@ -425,10 +432,12 @@ static inline tag next_tag(rzip_control *control, struct rzip_state *st, i64 p, uchar *u; u = control->get_sb(control, &control->sb, p - 1); - if (unlikely(!u)) return -1; + if (unlikely(!u)) + return -1; t ^= st->hash_index[*u]; u = control->get_sb(control, &control->sb, p + MINIMUM_MATCH - 1); - if (unlikely(!u)) return -1; + if (unlikely(!u)) + return -1; t ^= st->hash_index[*u]; return t; } @@ -441,7 +450,8 @@ static inline tag full_tag(rzip_control *control, struct rzip_state *st, i64 p) for (i = 0; i < MINIMUM_MATCH; i++) { u = control->get_sb(control, &control->sb, p + i); - if (unlikely(!u)) return -1; + if (unlikely(!u)) + return -1; ret ^= st->hash_index[*u]; } return ret; @@ -589,7 +599,8 @@ static bool hash_search(rzip_control *control, struct rzip_state *st, double pct if (likely(end > 0)) { t = full_tag(control, st, p); - if (unlikely(t == -1)) return false; + if (unlikely(t == -1)) + return false; } while (p < end) { @@ -600,7 +611,8 @@ static bool hash_search(rzip_control *control, struct rzip_state *st, double pct if (unlikely(sb->offset_search > sb->offset_low + sb->size_low)) remap_low_sb(control, &control->sb); t = next_tag(control, st, p, t); - if (unlikely(t == -1)) return false; + if (unlikely(t == -1)) + return false; /* Don't look for a match if there are no tags with this number of bits in the hash table. */ @@ -627,13 +639,16 @@ static bool hash_search(rzip_control *control, struct rzip_state *st, double pct if ((current.len >= GREAT_MATCH || p >= current.p + MINIMUM_MATCH) && current.len >= MINIMUM_MATCH) { if (st->last_match < current.p) - if (unlikely(!put_literal(control, st, st->last_match, current.p))) return false; - if (unlikely(!put_match(control, st, current.p, current.ofs, current.len))) return false; + if (unlikely(!put_literal(control, st, st->last_match, current.p))) + return false; + if (unlikely(!put_match(control, st, current.p, current.ofs, current.len))) + return false; st->last_match = current.p + current.len; current.p = p = st->last_match; current.len = 0; t = full_tag(control, st, p); - if (unlikely(t == -1)) return false; + if (unlikely(t == -1)) + return false; } if (unlikely(p % 128 == 0)) { @@ -689,8 +704,10 @@ static bool hash_search(rzip_control *control, struct rzip_state *st, double pct free(ckbuf); } - if (unlikely(!put_literal(control, st, 0, 0))) return false; - if (unlikely(!put_u32(control, st->ss, st->cksum))) return false; + if (unlikely(!put_literal(control, st, 0, 0))) + return false; + if (unlikely(!put_u32(control, st->ss, st->cksum))) + return false; return true; } @@ -782,7 +799,8 @@ static bool rzip_chunk(rzip_control *control, struct rzip_state *st, int fd_in, { struct sliding_buffer *sb = &control->sb; - if (unlikely(!init_sliding_mmap(control, st, fd_in, offset))) return false; + if (unlikely(!init_sliding_mmap(control, st, fd_in, offset))) + return false; st->ss = open_stream_out(control, fd_out, NUM_STREAMS, st->chunk_size, st->chunk_bytes); if (unlikely(!st->ss)) @@ -1137,7 +1155,8 @@ retry: void rzip_control_free(rzip_control *control) { size_t x; - if (!control) return; + if (!control) + return; free(control->tmpdir); free(control->outname); diff --git a/stream.c b/stream.c index 824156b..50480bf 100644 --- a/stream.c +++ b/stream.c @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Serge Belyshev - Copyright (C) 2006-2011 Con Kolivas + Copyright (C) 2006-2012 Con Kolivas Copyright (C) 2011 Peter Hyman Copyright (C) 1998 Andrew Tridgell @@ -180,7 +180,8 @@ static inline FILE *fake_fmemopen(rzip_control *control, void *buf, size_t bufle return NULL; } rewind(in); - return in; + + return in; } static inline FILE *fake_open_memstream(rzip_control *control, char **buf, size_t *length) @@ -191,7 +192,7 @@ static inline FILE *fake_open_memstream(rzip_control *control, char **buf, size_ failure_return(("NULL parameter to fake_open_memstream"), NULL); out = tmpfile(); if (unlikely(!out)) - return NULL; + return NULL; return out; } @@ -693,9 +694,11 @@ ssize_t put_fdout(rzip_control *control, void *offset_buf, ssize_t ret) /* The data won't fit in a temporary output buffer so we have * to fall back to temporary files. */ print_verbose("Unable to decompress entirely in ram, will use physical files\n"); - if (unlikely(!write_fdout(control, control->tmp_outbuf, control->out_len))) return -1; + if (unlikely(!write_fdout(control, control->tmp_outbuf, control->out_len))) + return -1; close_tmpoutbuf(control); - if (unlikely(!write_fdout(control, offset_buf, ret))) return -1; + if (unlikely(!write_fdout(control, offset_buf, ret))) + return -1; return ret; } memcpy(control->tmp_outbuf + control->out_ofs, offset_buf, ret); @@ -754,13 +757,16 @@ ssize_t read_1g(rzip_control *control, int fd, void *buf, i64 len) /* We're decompressing from STDIN */ if (unlikely(control->in_ofs + len > control->in_maxlen)) { /* We're unable to fit it all into the temp buffer */ - if (unlikely(!write_fdin(control))) return -1; - if (unlikely(!read_tmpinfile(control, control->fd_in))) return -1; + if (unlikely(!write_fdin(control))) + return -1; + if (unlikely(!read_tmpinfile(control, control->fd_in))) + return -1; close_tmpinbuf(control); goto read_fd; } if (control->in_ofs + len > control->in_len) - if (unlikely(!read_fdin(control, control->in_ofs + len - control->in_len))) return false; + if (unlikely(!read_fdin(control, control->in_ofs + len - control->in_len))) + return false; memcpy(buf, control->tmp_inbuf + control->in_ofs, len); control->in_ofs += len; return len; @@ -897,7 +903,8 @@ static int read_seekto(rzip_control *control, struct stream_info *sinfo, i64 pos if (TMP_INBUF) { if (spos > control->in_len) - if (unlikely(!read_fdin(control, spos - control->in_len))) return -1; + if (unlikely(!read_fdin(control, spos - control->in_len))) + return -1; control->in_ofs = spos; if (unlikely(spos < 0)) { print_err("Trying to seek to %lld outside tmp inbuf in read_seekto\n", spos); @@ -1106,7 +1113,8 @@ static bool decrypt_header(rzip_control *control, uchar *head, uchar *c_type, memcpy(buf + 9, u_len, 8); memcpy(buf + 17, last_head, 8); - if (unlikely(!lrz_decrypt(control, buf, 25, head))) return false; + if (unlikely(!lrz_decrypt(control, buf, 25, head))) + return false; memcpy(c_type, buf, 1); memcpy(c_len, buf + 1, 8); @@ -1279,7 +1287,8 @@ static bool rewrite_encrypted(rzip_control *control, struct stream_info *sinfo, i64 cur_ofs; cur_ofs = get_seek(control, sinfo->fd) - sinfo->initial_pos; - if (unlikely(cur_ofs == -1)) return false; + if (unlikely(cur_ofs == -1)) + return false; head = malloc(25 + SALT_LEN); if (unlikely(!head)) fatal_return(("Failed to malloc head in rewrite_encrypted\n"), false); @@ -1663,7 +1672,8 @@ fill_another: sinfo->total_read += header_length; if (ENCRYPT) { - if (unlikely(!decrypt_header(control, enc_head, &c_type, &c_len, &u_len, &last_head))) return -1; + if (unlikely(!decrypt_header(control, enc_head, &c_type, &c_len, &u_len, &last_head))) + return -1; if (unlikely(read_buf(control, sinfo->fd, blocksalt, SALT_LEN))) return -1; } @@ -1684,7 +1694,8 @@ fill_another: return -1; if (ENCRYPT) - if (unlikely(!lrz_decrypt(control, s_buf, padded_len, blocksalt))) return -1; + if (unlikely(!lrz_decrypt(control, s_buf, padded_len, blocksalt))) + return -1; ucthread[s->uthread_no].s_buf = s_buf; ucthread[s->uthread_no].c_len = c_len; @@ -1727,7 +1738,8 @@ out: unlock_mutex(control, &output_lock); /* join_pthread here will make it wait till the data is ready */ - if (unlikely(!join_pthread(control, threads[s->unext_thread], NULL))) return -1; + if (unlikely(!join_pthread(control, threads[s->unext_thread], NULL))) + return -1; ucthread[s->unext_thread].busy = 0; print_maxverbose("Taking decompressed data from thread %ld\n", s->unext_thread); @@ -1759,7 +1771,8 @@ int write_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 le /* Flush the buffer every sinfo->bufsize into one thread */ if (sinfo->s[streamno].buflen == sinfo->bufsize) - if (unlikely(!flush_buffer(control, sinfo, streamno))) return -1; + if (unlikely(!flush_buffer(control, sinfo, streamno))) + return -1; } return 0; } @@ -1803,7 +1816,8 @@ int close_stream_out(rzip_control *control, void *ss) for (i = 0; i < sinfo->num_streams; i++) { if (sinfo->s[i].buflen) - if (unlikely(!clear_buffer(control, sinfo, i, 0))) return -1; + if (unlikely(!clear_buffer(control, sinfo, i, 0))) + return -1; } if (ENCRYPT) { @@ -1825,14 +1839,16 @@ int close_stream_out(rzip_control *control, void *ss) if (!control->sinfo_buckets) { /* no streams added */ control->sinfo_queue = calloc(STREAM_BUCKET_SIZE + 1, sizeof(void*)); - if (!control->sinfo_queue) return -1; + if (!control->sinfo_queue) + return -1; control->sinfo_buckets++; } else if (control->sinfo_idx == STREAM_BUCKET_SIZE * control->sinfo_buckets + 1) { /* all buckets full, create new bucket */ void *tmp; tmp = realloc(control->sinfo_queue, (++control->sinfo_buckets * STREAM_BUCKET_SIZE + 1) * sizeof(void*)); - if (!tmp) return -1; + if (!tmp) + return -1; control->sinfo_queue = tmp; memset(control->sinfo_queue + control->sinfo_idx, 0, ((control->sinfo_buckets * STREAM_BUCKET_SIZE + 1) - control->sinfo_idx) * sizeof(void*)); } diff --git a/util.c b/util.c index ea3dfb1..e22f4a7 100644 --- a/util.c +++ b/util.c @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Serge Belyshev - Copyright (C) 2006-2011 Con Kolivas + Copyright (C) 2006-2012 Con Kolivas Copyright (C) 2008, 2011 Peter Hyman Copyright (C) 1998 Andrew Tridgell @@ -190,7 +190,8 @@ bool get_rand(rzip_control *control, uchar *buf, int len) fprintf(control->msgout, "Using configuration file %s\n", homeconf); } } - if (fp == NULL) return true; + if (fp == NULL) + return true; /* if we get here, we have a file. read until no more. */