diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-01-16 06:40:24 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-01-16 06:40:24 +0000 |
commit | 315054f4737a39489e0a14f3a92bff61f1592832 (patch) | |
tree | 62bf010653374ce09b6beb4dfa0414a91457233b /usr.sbin/syslogd/ringbuf.c | |
parent | 79e3d817585ca08a91e30ad14abe43e2ab70295f (diff) |
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'usr.sbin/syslogd/ringbuf.c')
-rw-r--r-- | usr.sbin/syslogd/ringbuf.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.sbin/syslogd/ringbuf.c b/usr.sbin/syslogd/ringbuf.c index 80f06fe603d..1af7d7d6fa0 100644 --- a/usr.sbin/syslogd/ringbuf.c +++ b/usr.sbin/syslogd/ringbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ringbuf.c,v 1.7 2005/09/21 23:25:32 djm Exp $ */ +/* $OpenBSD: ringbuf.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2004 Damien Miller @@ -21,13 +21,14 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "syslogd.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + /* Initialise a ring buffer */ struct ringbuf * ringbuf_init(size_t len) @@ -141,7 +142,7 @@ ringbuf_to_string(char *buf, size_t len, struct ringbuf *rb) if (buf == NULL || rb == NULL || len == 0) return (-1); - copy_len = MIN(len - 1, ringbuf_used(rb)); + copy_len = MINIMUM(len - 1, ringbuf_used(rb)); if (copy_len == 0) return (copy_len); @@ -151,9 +152,9 @@ ringbuf_to_string(char *buf, size_t len, struct ringbuf *rb) else { /* If the buffer is wrapped, copy each hunk separately */ n = rb->len - rb->start; - memcpy(buf, rb->buf + rb->start, MIN(n, copy_len)); + memcpy(buf, rb->buf + rb->start, MINIMUM(n, copy_len)); if (copy_len > n) - memcpy(buf + n, rb->buf, MIN(rb->end, copy_len - n)); + memcpy(buf + n, rb->buf, MINIMUM(rb->end, copy_len - n)); } buf[copy_len] = '\0'; |