From 0b082c0ec835e37aa8b57388c7a458959e0e91fe Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 10 Sep 2021 00:02:43 +0000 Subject: [PATCH] annotate what symbols are used from sys/param.h lines, or delete them if not required. when deleting, add sys/signal.h or other lines which were not being pulled in --- lib/libkvm/kvm_amd64.c | 6 ++++-- lib/libkvm/kvm_cd9660.c | 5 +++-- lib/libkvm/kvm_file2.c | 6 ++++-- lib/libkvm/kvm_getloadavg.c | 8 +++++--- lib/libkvm/kvm_ntfs.c | 5 +++-- lib/libkvm/kvm_proc.c | 14 +++++++++----- lib/libkvm/kvm_proc2.c | 6 ++++-- lib/libkvm/kvm_udf.c | 5 +++-- 8 files changed, 35 insertions(+), 20 deletions(-) diff --git a/lib/libkvm/kvm_amd64.c b/lib/libkvm/kvm_amd64.c index 9ab61c14d66..9a33bf11f80 100644 --- a/lib/libkvm/kvm_amd64.c +++ b/lib/libkvm/kvm_amd64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_amd64.c,v 1.13 2015/12/19 18:40:30 mmcc Exp $ */ +/* $OpenBSD: kvm_amd64.c,v 1.14 2021/09/10 00:02:43 deraadt Exp $ */ /* $NetBSD: kvm_x86_64.c,v 1.3 2002/06/05 22:01:55 fvdl Exp $ */ /*- @@ -38,7 +38,9 @@ * x86-64 machine dependent routines for kvm. */ -#include /* MAXCOMLEN */ +#include /* MAXCOMLEN ALIGN */ +#include +#include #include #include #include diff --git a/lib/libkvm/kvm_cd9660.c b/lib/libkvm/kvm_cd9660.c index 31b7aa2756a..487baec03aa 100644 --- a/lib/libkvm/kvm_cd9660.c +++ b/lib/libkvm/kvm_cd9660.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_cd9660.c,v 1.8 2019/01/25 00:19:25 millert Exp $ */ +/* $OpenBSD: kvm_cd9660.c,v 1.9 2021/09/10 00:02:43 deraadt Exp $ */ /* * Copyright (c) 2009 Todd C. Miller @@ -16,7 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include +#include #include #define _KERNEL #include diff --git a/lib/libkvm/kvm_file2.c b/lib/libkvm/kvm_file2.c index 3f2eeeb08cf..2a01b02e9c7 100644 --- a/lib/libkvm/kvm_file2.c +++ b/lib/libkvm/kvm_file2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_file2.c,v 1.55 2019/01/25 00:19:25 millert Exp $ */ +/* $OpenBSD: kvm_file2.c,v 1.56 2021/09/10 00:02:43 deraadt Exp $ */ /* * Copyright (c) 2009 Todd C. Miller @@ -54,7 +54,9 @@ #define __need_process -#include +#include /* MAXCOMLEN */ +#include +#include #include #include #include diff --git a/lib/libkvm/kvm_getloadavg.c b/lib/libkvm/kvm_getloadavg.c index a6461c7b1d3..2a15c4ad42c 100644 --- a/lib/libkvm/kvm_getloadavg.c +++ b/lib/libkvm/kvm_getloadavg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_getloadavg.c,v 1.9 2009/10/27 23:59:28 deraadt Exp $ */ +/* $OpenBSD: kvm_getloadavg.c,v 1.10 2021/09/10 00:02:43 deraadt Exp $ */ /* $NetBSD: kvm_getloadavg.c,v 1.2 1996/03/18 22:33:31 thorpej Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include +#include #include #include #include @@ -53,6 +53,8 @@ static struct nlist nl[] = { { "" }, }; +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + /* * kvm_getloadavg() -- Get system load averages, from live or dead kernels. * @@ -89,7 +91,7 @@ kvm_getloadavg(kvm_t *kd, double loadavg[], int nelem) if (!KREAD(kd, nl[X_FSCALE].n_value, &fscale)) loadinfo.fscale = fscale; - nelem = MIN(nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t)); + nelem = MINIMUM(nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t)); for (i = 0; i < nelem; i++) loadavg[i] = (double) loadinfo.ldavg[i] / loadinfo.fscale; return (nelem); diff --git a/lib/libkvm/kvm_ntfs.c b/lib/libkvm/kvm_ntfs.c index b1ab2571bb6..32e556b89a8 100644 --- a/lib/libkvm/kvm_ntfs.c +++ b/lib/libkvm/kvm_ntfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_ntfs.c,v 1.5 2016/10/02 23:11:55 guenther Exp $ */ +/* $OpenBSD: kvm_ntfs.c,v 1.6 2021/09/10 00:02:43 deraadt Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -29,7 +29,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include +#include #include #define _KERNEL #include diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c index 96f1ae31c4b..c6a70507177 100644 --- a/lib/libkvm/kvm_proc.c +++ b/lib/libkvm/kvm_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc.c,v 1.61 2020/10/12 22:08:33 deraadt Exp $ */ +/* $OpenBSD: kvm_proc.c,v 1.62 2021/09/10 00:02:43 deraadt Exp $ */ /* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -70,7 +70,9 @@ */ #define __need_process -#include +#include /* MAXCOMLEN PAGE_SIZE */ +#include +#include #include #include #include @@ -97,6 +99,8 @@ #include "kvm_private.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) static char *_kvm_ureadm(kvm_t *, const struct kinfo_proc *, u_long, u_long *); static ssize_t kvm_ureadm(kvm_t *, const struct kinfo_proc *, u_long, char *, size_t); @@ -287,9 +291,9 @@ kvm_argv(kvm_t *kd, const struct kinfo_proc *p, u_long addr, int narg, } if (*pargv == 0) - argc = MAX(narg + 1, 32); + argc = MAXIMUM(narg + 1, 32); else if (narg + 1 > *pargc) - argc = MAX(2 * (*pargc), narg + 1); + argc = MAXIMUM(2 * (*pargc), narg + 1); else goto argv_allocated; argv = _kvm_reallocarray(kd, *pargv, argc, sizeof(**pargv)); @@ -552,7 +556,7 @@ kvm_ureadm(kvm_t *kd, const struct kinfo_proc *p, u_long uva, char *buf, _kvm_err(kd, 0, "invalid address (%lx)", uva); return (0); } - cc = (size_t)MIN(cnt, len); + cc = (size_t)MINIMUM(cnt, len); memcpy(cp, dp, cc); cp += cc; uva += cc; diff --git a/lib/libkvm/kvm_proc2.c b/lib/libkvm/kvm_proc2.c index 7cc2adab450..89b62e506be 100644 --- a/lib/libkvm/kvm_proc2.c +++ b/lib/libkvm/kvm_proc2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc2.c,v 1.33 2021/02/08 10:51:01 mpi Exp $ */ +/* $OpenBSD: kvm_proc2.c,v 1.34 2021/09/10 00:02:43 deraadt Exp $ */ /* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -70,7 +70,9 @@ */ #define __need_process -#include +#include /* MAXCOMLEN NODEV MIN */ +#include +#include #include #include #include diff --git a/lib/libkvm/kvm_udf.c b/lib/libkvm/kvm_udf.c index bb7c6f7a21a..a2e8a342543 100644 --- a/lib/libkvm/kvm_udf.c +++ b/lib/libkvm/kvm_udf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_udf.c,v 1.10 2016/10/02 23:11:55 guenther Exp $ */ +/* $OpenBSD: kvm_udf.c,v 1.11 2021/09/10 00:02:43 deraadt Exp $ */ /* * Copyright (c) 2001, 2002 Scott Long @@ -26,7 +26,8 @@ * SUCH DAMAGE. */ -#include +#include +#include #include #define _KERNEL #include -- 2.20.1