Clean up examples/gzlog.[ch] comparisons of different types.
This commit is contained in:
parent
a2981775a9
commit
3d9df6ecf8
@ -2,7 +2,7 @@
|
|||||||
* gzlog.c
|
* gzlog.c
|
||||||
* Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved
|
* Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved
|
||||||
* For conditions of distribution and use, see copyright notice in gzlog.h
|
* For conditions of distribution and use, see copyright notice in gzlog.h
|
||||||
* version 2.1, 8 Jul 2012
|
* version 2.2, 14 Aug 2012
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -750,7 +750,8 @@ local int log_recover(struct log *log, int op)
|
|||||||
strcpy(log->end, ".add");
|
strcpy(log->end, ".add");
|
||||||
if (stat(log->path, &st) == 0 && st.st_size) {
|
if (stat(log->path, &st) == 0 && st.st_size) {
|
||||||
len = (size_t)(st.st_size);
|
len = (size_t)(st.st_size);
|
||||||
if (len != st.st_size || (data = malloc(st.st_size)) == NULL) {
|
if ((off_t)len != st.st_size ||
|
||||||
|
(data = malloc(st.st_size)) == NULL) {
|
||||||
log_log(log, op, "allocation failure");
|
log_log(log, op, "allocation failure");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
@ -758,7 +759,7 @@ local int log_recover(struct log *log, int op)
|
|||||||
log_log(log, op, ".add file read failure");
|
log_log(log, op, ".add file read failure");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = read(fd, data, len) != len;
|
ret = (size_t)read(fd, data, len) != len;
|
||||||
close(fd);
|
close(fd);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
log_log(log, op, ".add file read failure");
|
log_log(log, op, ".add file read failure");
|
||||||
@ -952,7 +953,7 @@ int gzlog_compress(gzlog *logd)
|
|||||||
fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
break;
|
break;
|
||||||
ret = write(fd, data, len) != len;
|
ret = (size_t)write(fd, data, len) != len;
|
||||||
if (ret | close(fd))
|
if (ret | close(fd))
|
||||||
break;
|
break;
|
||||||
log_touch(log);
|
log_touch(log);
|
||||||
@ -963,7 +964,7 @@ int gzlog_compress(gzlog *logd)
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
break;
|
break;
|
||||||
next = DICT > len ? len : DICT;
|
next = DICT > len ? len : DICT;
|
||||||
ret = write(fd, (char *)data + len - next, next) != next;
|
ret = (size_t)write(fd, (char *)data + len - next, next) != next;
|
||||||
if (ret | close(fd))
|
if (ret | close(fd))
|
||||||
break;
|
break;
|
||||||
log_touch(log);
|
log_touch(log);
|
||||||
@ -1013,7 +1014,7 @@ int gzlog_write(gzlog *logd, void *data, size_t len)
|
|||||||
fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
ret = write(fd, data, len) != len;
|
ret = (size_t)write(fd, data, len) != len;
|
||||||
if (ret | close(fd))
|
if (ret | close(fd))
|
||||||
return -1;
|
return -1;
|
||||||
log_touch(log);
|
log_touch(log);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* gzlog.h
|
/* gzlog.h
|
||||||
Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved
|
Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved
|
||||||
version 2.1, 8 Jul 2012
|
version 2.2, 14 Aug 2012
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the author be held liable for any damages
|
warranty. In no event will the author be held liable for any damages
|
||||||
@ -28,6 +28,7 @@
|
|||||||
Compression now occurs as needed during gzlog_write()
|
Compression now occurs as needed during gzlog_write()
|
||||||
gzlog_write() now always leaves the log file as valid gzip
|
gzlog_write() now always leaves the log file as valid gzip
|
||||||
2.1 8 Jul 2012 Fix argument checks in gzlog_compress() and gzlog_write()
|
2.1 8 Jul 2012 Fix argument checks in gzlog_compress() and gzlog_write()
|
||||||
|
2.2 14 Aug 2012 Clean up signed comparisons
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user