From 3dc1754e50ee559ea810f6c4b406c7a117cb8131 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 28 Sep 2022 23:19:37 +0200 Subject: [PATCH] Use libc MAX() and MIN() glibc, musl, FreeBSD, and OpenBSD define the MAX() and MIN() macros in with the same definition that we use. Let's not redefine it here and use the system one, as it's effectively the same as we define (modulo whitespace). See: shadow (previously): alx@asus5775:~/src/shadow/shadow$ grepc -ktm MAX ./lib/defines.h:318:#define MAX(x,y) (((x) > (y)) ? (x) : (y)) glibc: alx@asus5775:~/src/gnu/glibc$ grepc -ktm -x 'sys/param.h$' MAX ./misc/sys/param.h:103:#define MAX(a,b) (((a)>(b))?(a):(b)) musl: alx@asus5775:~/src/musl/musl$ grepc -ktm -x 'sys/param.h$' MAX ./include/sys/param.h:19:#define MAX(a,b) (((a)>(b))?(a):(b)) OpenBSD: alx@asus5775:~/src/bsd/openbsd/src$ grepc -ktm -x 'sys/param.h$' MAX ./sys/sys/param.h:193:#define MAX(a,b) (((a)>(b))?(a):(b)) FreeBSD: alx@asus5775:~/src/bsd/freebsd/freebsd-src$ grepc -ktm -x 'sys/param.h$' MAX ./sys/sys/param.h:333:#define MAX(a,b) (((a)>(b))?(a):(b)) Signed-off-by: Alejandro Colomar --- lib/defines.h | 8 -------- libmisc/utmp.c | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/defines.h b/lib/defines.h index ee33aa0d..6a6bf73e 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -310,14 +310,6 @@ extern char *strerror (); # define format_attr(type, index, check) #endif -/* ! Arguments evaluated twice ! */ -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(x,y) (((x) > (y)) ? (x) : (y)) -#endif - /* Maximum length of usernames */ #ifdef HAVE_UTMPX_H # include diff --git a/libmisc/utmp.c b/libmisc/utmp.c index d2b65ac7..45b479f1 100644 --- a/libmisc/utmp.c +++ b/libmisc/utmp.c @@ -19,6 +19,7 @@ #endif #include +#include #include #include #include