Fix warnings.

Patch ~ by Serge Belyshev.
This commit is contained in:
ckolivas 2011-03-18 10:37:09 +11:00
parent e856d481bf
commit b8d8ecfe33
6 changed files with 13 additions and 7 deletions

View file

@ -34,6 +34,7 @@
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <sys/mman.h>
#include <sys/time.h>
#include <termios.h>
@ -357,7 +358,7 @@ int open_tmpinfile(rzip_control *control)
static void read_tmpinmagic(rzip_control *control)
{
char magic[MAGIC_LEN];
int md5, i, tmpchar;
int i, tmpchar;
memset(magic, 0, sizeof(magic));
for (i = 0; i < 24; i++) {
@ -946,7 +947,7 @@ void compress_file(rzip_control *control)
const char *tmp, *tmpinfile; /* we're just using this as a proxy for control->infile.
* Spares a compiler warning
*/
int fd_in, fd_out;
int fd_in, fd_out = -1;
char header[MAGIC_LEN];
if (ENCRYPT)

View file

@ -33,6 +33,7 @@ void get_header_info(rzip_control *control, int fd_in, uchar *ctype, i64 *c_len,
void get_fileinfo(rzip_control *control);
void compress_file(rzip_control *control);
void write_fdout(rzip_control *control, void *buf, i64 len);
void write_fdin(struct rzip_control *control);
void flush_tmpoutbuf(rzip_control *control);
void close_tmpoutbuf(rzip_control *control);
void clear_tmpinbuf(rzip_control *control);

9
main.c
View file

@ -136,7 +136,6 @@ static inline i64 get_ram(void)
i64 ramsize;
FILE *meminfo;
char aux[256];
char *ignore;
ramsize = (i64)sysconf(_SC_PHYS_PAGES) * PAGE_SIZE;
if (ramsize > 0)
@ -146,8 +145,10 @@ static inline i64 get_ram(void)
if(!(meminfo = fopen("/proc/meminfo", "r")))
fatal("fopen\n");
while(!feof(meminfo) && !fscanf(meminfo, "MemTotal: %Lu kB", &ramsize))
ignore = fgets(aux, sizeof(aux), meminfo);
while(!feof(meminfo) && !fscanf(meminfo, "MemTotal: %Lu kB", &ramsize)) {
if (unlikely(fgets(aux, sizeof(aux), meminfo) == NULL))
fatal("Failed to fgets in get_ram\n");
}
if (fclose(meminfo) == -1)
fatal("fclose");
ramsize *= 1000;
@ -767,7 +768,7 @@ int main(int argc, char *argv[])
* used in alloc */
usable_ram = MAX(control.ramsize - 900000000ll, 900000000ll);
control.maxram = MIN(control.maxram, usable_ram);
control.maxram = MIN(control.maxram, two_gig);
control.maxram = MIN((unsigned long long)control.maxram, two_gig);
}
round_to_page(&control.maxram);

1
rzip.c
View file

@ -47,6 +47,7 @@
#include "stream.h"
#include "util.h"
#include "liblrzip.h"
#include "lrzip.h"
/* needed for CRC routines */
#include "lzma/C/7zCrc.h"

View file

@ -45,6 +45,7 @@
#include "util.h"
#include "zpipe.h"
#include "liblrzip.h"
#include "lrzip.h"
#ifdef __APPLE__
@ -1391,7 +1392,7 @@ static int fill_buffer(rzip_control *control, struct stream_info *sinfo, int str
struct stream *s = &sinfo->s[streamno];
stream_thread_struct *st;
uchar c_type, *s_buf;
uchar salt[16];
uchar salt[BLOCKSALT_LEN];
if (s->buf)
free(s->buf);

View file

@ -37,6 +37,7 @@ int write_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 le
i64 read_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len);
int close_stream_out(rzip_control *control, void *ss);
int close_stream_in(void *ss);
ssize_t put_fdout(rzip_control *control, void *offset_buf, ssize_t ret);
const i64 one_g;
#endif