Commit 67696b2a authored by Timo Teräs's avatar Timo Teräs

io: use min() instead of MIN()

parent f123d77e
Pipeline #5173 failed with stage
in 24 seconds
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/xattr.h> #include <sys/xattr.h>
#include <sys/param.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
...@@ -64,7 +63,7 @@ ssize_t apk_istream_read(struct apk_istream *is, void *ptr, size_t size) ...@@ -64,7 +63,7 @@ ssize_t apk_istream_read(struct apk_istream *is, void *ptr, size_t size)
while (left) { while (left) {
if (is->ptr != is->end) { if (is->ptr != is->end) {
r = MIN(left, is->end - is->ptr); r = min(left, is->end - is->ptr);
if (ptr) { if (ptr) {
memcpy(ptr, is->ptr, r); memcpy(ptr, is->ptr, r);
ptr += r; ptr += r;
...@@ -505,20 +504,20 @@ ssize_t apk_istream_splice(struct apk_istream *is, int fd, size_t size, ...@@ -505,20 +504,20 @@ ssize_t apk_istream_splice(struct apk_istream *is, int fd, size_t size,
else if (r == EBADF || r == EFBIG || r == ENOSPC || r == EIO) else if (r == EBADF || r == EFBIG || r == ENOSPC || r == EIO)
return -r; return -r;
} }
bufsz = MIN(bufsz, 2*1024*1024); bufsz = min(bufsz, 2*1024*1024);
buf = mmapbase; buf = mmapbase;
} }
if (mmapbase == MAP_FAILED) { if (mmapbase == MAP_FAILED) {
if (!splice_buffer) splice_buffer = malloc(256*1024); if (!splice_buffer) splice_buffer = malloc(256*1024);
buf = splice_buffer; buf = splice_buffer;
if (!buf) return -ENOMEM; if (!buf) return -ENOMEM;
bufsz = MIN(bufsz, 256*1024); bufsz = min(bufsz, 256*1024);
} }
while (done < size) { while (done < size) {
if (cb != NULL) cb(cb_ctx, done); if (cb != NULL) cb(cb_ctx, done);
togo = MIN(size - done, bufsz); togo = min(size - done, bufsz);
r = apk_istream_read(is, buf, togo); r = apk_istream_read(is, buf, togo);
if (r <= 0) { if (r <= 0) {
if (r) goto err; if (r) goto err;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment