aboutsummaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/util.c2
-rw-r--r--src/util.h3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index 92b4d20..21b2b69 100644
--- a/src/util.c
+++ b/src/util.c
@@ -162,7 +162,7 @@ writezeroes(int fd, void *buf, size_t bufsize, size_t n)
{
size_t p, m;
for (p = 0; p < n; p += m) {
- m = bufsize < n - p ? bufsize : n - p;
+ m = MIN(bufsize, n - p);
if (writeall(fd, buf, m))
return -1;
}
diff --git a/src/util.h b/src/util.h
index a9704ec..d948452 100644
--- a/src/util.h
+++ b/src/util.h
@@ -2,6 +2,9 @@
#include "arg.h"
#define ELEMENTSOF(ARRAY) (sizeof(ARRAY) / sizeof(*(ARRAY)))
+#define MIN(A, B) ((A) < (B) ? (A) : (B))
+#define MAX(A, B) ((A) > (B) ? (A) : (B))
+#define CLIP(A, B, C) ((B) < (A) ? (A) : (B) > (C) ? (C) : (B))
#define USAGE(SYNOPSIS)\
static void usage(void)\