aboutsummaryrefslogtreecommitdiff
path: root/zlib/examples/gzlog.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-11-12 13:55:55 +0100
committermarha <marha@users.sourceforge.net>2013-11-12 13:56:28 +0100
commit0e01270aeda311bf52c046f6a68e8b3e1fa86cb8 (patch)
treeeee062f34219e5c5d3f3e61caa5d3c39a5185794 /zlib/examples/gzlog.c
parent3893ee9f6b12465239b63d08763bd9ba0bd329e5 (diff)
parent4bdf8409331f44417c3622bc5ec0e42c0e68afb6 (diff)
downloadvcxsrv-0e01270aeda311bf52c046f6a68e8b3e1fa86cb8.tar.gz
vcxsrv-0e01270aeda311bf52c046f6a68e8b3e1fa86cb8.tar.bz2
vcxsrv-0e01270aeda311bf52c046f6a68e8b3e1fa86cb8.zip
Merge remote-tracking branch 'origin/released'
* origin/released: Updated zlib to 1.2.8 Conflicts: zlib/win32/zlib.def
Diffstat (limited to 'zlib/examples/gzlog.c')
-rw-r--r--zlib/examples/gzlog.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/zlib/examples/gzlog.c b/zlib/examples/gzlog.c
index d70aacaba..922f878dd 100644
--- a/zlib/examples/gzlog.c
+++ b/zlib/examples/gzlog.c
@@ -1,8 +1,8 @@
/*
* gzlog.c
- * Copyright (C) 2004, 2008 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
- * version 2.0, 25 Apr 2008
+ * version 2.2, 14 Aug 2012
*/
/*
@@ -750,7 +750,8 @@ local int log_recover(struct log *log, int op)
strcpy(log->end, ".add");
if (stat(log->path, &st) == 0 && 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");
return -2;
}
@@ -758,7 +759,7 @@ local int log_recover(struct log *log, int op)
log_log(log, op, ".add file read failure");
return -1;
}
- ret = read(fd, data, len) != len;
+ ret = (size_t)read(fd, data, len) != len;
close(fd);
if (ret) {
log_log(log, op, ".add file read failure");
@@ -913,7 +914,7 @@ int gzlog_compress(gzlog *logd)
struct log *log = logd;
/* check arguments */
- if (log == NULL || strcmp(log->id, LOGID) || len < 0)
+ if (log == NULL || strcmp(log->id, LOGID))
return -3;
/* see if we lost the lock -- if so get it again and reload the extra
@@ -952,7 +953,7 @@ int gzlog_compress(gzlog *logd)
fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
break;
- ret = write(fd, data, len) != len;
+ ret = (size_t)write(fd, data, len) != len;
if (ret | close(fd))
break;
log_touch(log);
@@ -963,7 +964,7 @@ int gzlog_compress(gzlog *logd)
if (fd < 0)
break;
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))
break;
log_touch(log);
@@ -997,9 +998,9 @@ int gzlog_write(gzlog *logd, void *data, size_t len)
struct log *log = logd;
/* check arguments */
- if (log == NULL || strcmp(log->id, LOGID) || len < 0)
+ if (log == NULL || strcmp(log->id, LOGID))
return -3;
- if (data == NULL || len == 0)
+ if (data == NULL || len <= 0)
return 0;
/* see if we lost the lock -- if so get it again and reload the extra
@@ -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);
if (fd < 0)
return -1;
- ret = write(fd, data, len) != len;
+ ret = (size_t)write(fd, data, len) != len;
if (ret | close(fd))
return -1;
log_touch(log);