diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2012-08-14 00:31:23 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2012-08-18 18:07:04 -0700 |
| commit | 3d9df6ecf83a41a3990fbff5c276f854d158e8ad (patch) | |
| tree | 64aa3b3a0c108a0d286e94398c985e8a22ea32db /examples | |
| parent | a2981775a91d762c1747e987e30aaa022e0393fd (diff) | |
| download | zlib-3d9df6ecf83a41a3990fbff5c276f854d158e8ad.tar.gz zlib-3d9df6ecf83a41a3990fbff5c276f854d158e8ad.tar.bz2 zlib-3d9df6ecf83a41a3990fbff5c276f854d158e8ad.zip | |
Clean up examples/gzlog.[ch] comparisons of different types.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/gzlog.c | 13 | ||||
| -rw-r--r-- | examples/gzlog.h | 3 |
2 files changed, 9 insertions, 7 deletions
diff --git a/examples/gzlog.c b/examples/gzlog.c index de32058..922f878 100644 --- a/examples/gzlog.c +++ b/examples/gzlog.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * gzlog.c | 2 | * gzlog.c |
| 3 | * Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved | 3 | * Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved |
| 4 | * For conditions of distribution and use, see copyright notice in gzlog.h | 4 | * For conditions of distribution and use, see copyright notice in gzlog.h |
| 5 | * version 2.1, 8 Jul 2012 | 5 | * version 2.2, 14 Aug 2012 |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | /* | 8 | /* |
| @@ -750,7 +750,8 @@ local int log_recover(struct log *log, int op) | |||
| 750 | strcpy(log->end, ".add"); | 750 | strcpy(log->end, ".add"); |
| 751 | if (stat(log->path, &st) == 0 && st.st_size) { | 751 | if (stat(log->path, &st) == 0 && st.st_size) { |
| 752 | len = (size_t)(st.st_size); | 752 | len = (size_t)(st.st_size); |
| 753 | if (len != st.st_size || (data = malloc(st.st_size)) == NULL) { | 753 | if ((off_t)len != st.st_size || |
| 754 | (data = malloc(st.st_size)) == NULL) { | ||
| 754 | log_log(log, op, "allocation failure"); | 755 | log_log(log, op, "allocation failure"); |
| 755 | return -2; | 756 | return -2; |
| 756 | } | 757 | } |
| @@ -758,7 +759,7 @@ local int log_recover(struct log *log, int op) | |||
| 758 | log_log(log, op, ".add file read failure"); | 759 | log_log(log, op, ".add file read failure"); |
| 759 | return -1; | 760 | return -1; |
| 760 | } | 761 | } |
| 761 | ret = read(fd, data, len) != len; | 762 | ret = (size_t)read(fd, data, len) != len; |
| 762 | close(fd); | 763 | close(fd); |
| 763 | if (ret) { | 764 | if (ret) { |
| 764 | log_log(log, op, ".add file read failure"); | 765 | log_log(log, op, ".add file read failure"); |
| @@ -952,7 +953,7 @@ int gzlog_compress(gzlog *logd) | |||
| 952 | fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); | 953 | fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
| 953 | if (fd < 0) | 954 | if (fd < 0) |
| 954 | break; | 955 | break; |
| 955 | ret = write(fd, data, len) != len; | 956 | ret = (size_t)write(fd, data, len) != len; |
| 956 | if (ret | close(fd)) | 957 | if (ret | close(fd)) |
| 957 | break; | 958 | break; |
| 958 | log_touch(log); | 959 | log_touch(log); |
| @@ -963,7 +964,7 @@ int gzlog_compress(gzlog *logd) | |||
| 963 | if (fd < 0) | 964 | if (fd < 0) |
| 964 | break; | 965 | break; |
| 965 | next = DICT > len ? len : DICT; | 966 | next = DICT > len ? len : DICT; |
| 966 | ret = write(fd, (char *)data + len - next, next) != next; | 967 | ret = (size_t)write(fd, (char *)data + len - next, next) != next; |
| 967 | if (ret | close(fd)) | 968 | if (ret | close(fd)) |
| 968 | break; | 969 | break; |
| 969 | log_touch(log); | 970 | log_touch(log); |
| @@ -1013,7 +1014,7 @@ int gzlog_write(gzlog *logd, void *data, size_t len) | |||
| 1013 | fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); | 1014 | fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
| 1014 | if (fd < 0) | 1015 | if (fd < 0) |
| 1015 | return -1; | 1016 | return -1; |
| 1016 | ret = write(fd, data, len) != len; | 1017 | ret = (size_t)write(fd, data, len) != len; |
| 1017 | if (ret | close(fd)) | 1018 | if (ret | close(fd)) |
| 1018 | return -1; | 1019 | return -1; |
| 1019 | log_touch(log); | 1020 | log_touch(log); |
diff --git a/examples/gzlog.h b/examples/gzlog.h index 4e093bc..86f0cec 100644 --- a/examples/gzlog.h +++ b/examples/gzlog.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* gzlog.h | 1 | /* gzlog.h |
| 2 | Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved | 2 | Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved |
| 3 | version 2.1, 8 Jul 2012 | 3 | version 2.2, 14 Aug 2012 |
| 4 | 4 | ||
| 5 | This software is provided 'as-is', without any express or implied | 5 | This software is provided 'as-is', without any express or implied |
| 6 | warranty. In no event will the author be held liable for any damages | 6 | warranty. In no event will the author be held liable for any damages |
| @@ -28,6 +28,7 @@ | |||
| 28 | Compression now occurs as needed during gzlog_write() | 28 | Compression now occurs as needed during gzlog_write() |
| 29 | gzlog_write() now always leaves the log file as valid gzip | 29 | gzlog_write() now always leaves the log file as valid gzip |
| 30 | 2.1 8 Jul 2012 Fix argument checks in gzlog_compress() and gzlog_write() | 30 | 2.1 8 Jul 2012 Fix argument checks in gzlog_compress() and gzlog_write() |
| 31 | 2.2 14 Aug 2012 Clean up signed comparisons | ||
| 31 | */ | 32 | */ |
| 32 | 33 | ||
| 33 | /* | 34 | /* |
