This patch is going to go in on the weekend unless someone has any
worthwhile nits about it. It was submitted by Hiten Pandya.
The patch basically removes random MIN/MAX implementations from
22 files in the kernel and modifies the one in sys/param.h (see the
last part of the patch) so it is present for all kernel builds.
-Matt
Matthew Dillon
<[EMAIL PROTECTED]>
Index: alpha/alpha/busdma_machdep.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/alpha/alpha/busdma_machdep.c,v
retrieving revision 1.24
diff -u -r1.24 busdma_machdep.c
--- alpha/alpha/busdma_machdep.c 4 Oct 2002 20:40:39 -0000 1.24
+++ alpha/alpha/busdma_machdep.c 18 Jan 2003 18:39:27 -0000
@@ -45,8 +45,6 @@
#include <machine/sgmap.h>
#include <machine/md_var.h>
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX_BPAGES 128
struct bus_dma_tag {
Index: cam/scsi/scsi_cd.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/cam/scsi/scsi_cd.c,v
retrieving revision 1.68
diff -u -r1.68 scsi_cd.c
--- cam/scsi/scsi_cd.c 23 Nov 2002 22:51:50 -0000 1.68
+++ cam/scsi/scsi_cd.c 18 Jan 2003 18:39:55 -0000
@@ -172,10 +172,6 @@
}
};
-#ifndef MIN
-#define MIN(x,y) ((x<y) ? x : y)
-#endif
-
#define CD_CDEV_MAJOR 15
static d_open_t cdopen;
Index: cam/scsi/scsi_pass.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/cam/scsi/scsi_pass.c,v
retrieving revision 1.34
diff -u -r1.34 scsi_pass.c
--- cam/scsi/scsi_pass.c 15 Aug 2002 20:54:03 -0000 1.34
+++ cam/scsi/scsi_pass.c 18 Jan 2003 18:40:09 -0000
@@ -76,10 +76,6 @@
dev_t dev;
};
-#ifndef MIN
-#define MIN(x,y) ((x<y) ? x : y)
-#endif
-
#define PASS_CDEV_MAJOR 31
static d_open_t passopen;
Index: cam/scsi/scsi_targ_bh.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/cam/scsi/scsi_targ_bh.c,v
retrieving revision 1.14
diff -u -r1.14 scsi_targ_bh.c
--- cam/scsi/scsi_targ_bh.c 15 Aug 2002 20:54:03 -0000 1.14
+++ cam/scsi/scsi_targ_bh.c 18 Jan 2003 18:40:23 -0000
@@ -69,8 +69,6 @@
#define MAX_IMMEDIATE 16
#define MAX_BUF_SIZE 256 /* Max inquiry/sense/mode page transfer */
-#define MIN(a, b) ((a > b) ? b : a)
-
/* Offsets into our private CCB area for storing accept information */
#define ccb_type ppriv_field0
#define ccb_descr ppriv_ptr1
Index: compat/svr4/svr4_stream.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/compat/svr4/svr4_stream.c,v
retrieving revision 1.41
diff -u -r1.41 svr4_stream.c
--- compat/svr4/svr4_stream.c 13 Jan 2003 00:28:57 -0000 1.41
+++ compat/svr4/svr4_stream.c 18 Jan 2003 18:41:41 -0000
@@ -329,9 +329,6 @@
if (len <= 0 || fromsa == 0)
len = 0;
else {
-#ifndef MIN
-#define MIN(a,b) ((a)>(b)?(b):(a))
-#endif
/* save sa_len before it is destroyed by MSG_COMPAT */
len = MIN(len, fromsa->sa_len);
error = copyout(fromsa,
Index: contrib/dev/oltr/if_oltr.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/contrib/dev/oltr/if_oltr.c,v
retrieving revision 1.21
diff -u -r1.21 if_oltr.c
--- contrib/dev/oltr/if_oltr.c 15 Nov 2002 00:00:14 -0000 1.21
+++ contrib/dev/oltr/if_oltr.c 18 Jan 2003 18:42:53 -0000
@@ -92,7 +92,6 @@
#define PCI_VENDOR_OLICOM 0x108D
-#define MIN(A,B) (((A) < (B)) ? (A) : (B))
#define MIN3(A,B,C) (MIN(A, (MIN(B, C))))
char *AdapterName[] = {
Index: contrib/ipfilter/netinet/ip_proxy.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/contrib/ipfilter/netinet/ip_proxy.c,v
retrieving revision 1.20
diff -u -r1.20 ip_proxy.c
--- contrib/ipfilter/netinet/ip_proxy.c 28 Aug 2002 13:41:36 -0000 1.20
+++ contrib/ipfilter/netinet/ip_proxy.c 18 Jan 2003 18:43:09 -0000
@@ -84,10 +84,6 @@
extern KRWLOCK_T ipf_nat, ipf_state;
#endif
-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
static int appr_fixseqack __P((fr_info_t *, ip_t *, ap_session_t *, int ));
Index: dev/advansys/advlib.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/dev/advansys/advlib.c,v
retrieving revision 1.17
diff -u -r1.17 advlib.c
--- dev/advansys/advlib.c 15 Oct 2000 14:17:58 -0000 1.17
+++ dev/advansys/advlib.c 18 Jan 2003 18:43:24 -0000
@@ -1170,8 +1170,6 @@
period = &dummy_period;
}
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-
*offset = MIN(ADV_SYN_MAX_OFFSET, *offset);
if (*period != 0 && *offset != 0) {
for (i = 0; i < adv->sdtr_period_tbl_size; i++) {
Index: dev/advansys/adwcam.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/dev/advansys/adwcam.c,v
retrieving revision 1.11
diff -u -r1.11 adwcam.c
--- dev/advansys/adwcam.c 1 Mar 2001 17:08:55 -0000 1.11
+++ dev/advansys/adwcam.c 18 Jan 2003 18:43:42 -0000
@@ -72,8 +72,6 @@
#define ccb_acb_ptr spriv_ptr0
#define ccb_adw_ptr spriv_ptr1
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
u_long adw_unit;
static __inline cam_status adwccbstatus(union ccb*);
Index: dev/aha/aha.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/dev/aha/aha.c,v
retrieving revision 1.43
diff -u -r1.43 aha.c
--- dev/aha/aha.c 1 Jan 2003 18:48:49 -0000 1.43
+++ dev/aha/aha.c 18 Jan 2003 18:44:02 -0000
@@ -84,10 +84,6 @@
*/
#define PROBABLY_NEW_BOARD(REV) (REV > 0x43 && REV < 0x56)
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
/* MailBox Management functions */
static __inline void ahanextinbox(struct aha_softc *aha);
static __inline void ahanextoutbox(struct aha_softc *aha);
Index: dev/ahb/ahb.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/dev/ahb/ahb.c,v
retrieving revision 1.24
diff -u -r1.24 ahb.c
--- dev/ahb/ahb.c 24 May 2002 05:21:36 -0000 1.24
+++ dev/ahb/ahb.c 18 Jan 2003 18:44:23 -0000
@@ -55,8 +55,6 @@
#define ccb_ecb_ptr spriv_ptr0
#define ccb_ahb_ptr spriv_ptr1
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
#define ahb_inb(ahb, port) \
bus_space_read_1((ahb)->tag, (ahb)->bsh, port)
Index: dev/buslogic/bt.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/dev/buslogic/bt.c,v
retrieving revision 1.34
diff -u -r1.34 bt.c
--- dev/buslogic/bt.c 6 Nov 2002 20:34:38 -0000 1.34
+++ dev/buslogic/bt.c 18 Jan 2003 18:45:21 -0000
@@ -72,10 +72,6 @@
#include <dev/buslogic/btreg.h>
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
/* MailBox Management functions */
static __inline void btnextinbox(struct bt_softc *bt);
static __inline void btnextoutbox(struct bt_softc *bt);
Index: dev/sound/pci/cs4281.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/dev/sound/pci/cs4281.c,v
retrieving revision 1.12
diff -u -r1.12 cs4281.c
--- dev/sound/pci/cs4281.c 23 Aug 2002 06:19:28 -0000 1.12
+++ dev/sound/pci/cs4281.c 18 Jan 2003 18:45:56 -0000
@@ -50,9 +50,6 @@
/* Misc */
-#define MIN(x,y) (x) < (y) ? (x) : (y)
-#define MAX(x,y) (x) > (y) ? (x) : (y)
-
#define inline __inline
#ifndef DEB
Index: dev/sym/sym_hipd.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/dev/sym/sym_hipd.c,v
retrieving revision 1.38
diff -u -r1.38 sym_hipd.c
--- dev/sym/sym_hipd.c 1 Jan 2003 18:48:52 -0000 1.38
+++ dev/sym/sym_hipd.c 18 Jan 2003 18:47:06 -0000
@@ -398,13 +398,6 @@
#define MAX_QUEUE SYM_CONF_MAX_QUEUE
/*
- * These ones should have been already defined.
- */
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-
-/*
* Active debugging tags and verbosity.
*/
#define DEBUG_ALLOC (0x0001)
Index: i386/i386/busdma_machdep.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/i386/i386/busdma_machdep.c,v
retrieving revision 1.28
diff -u -r1.28 busdma_machdep.c
--- i386/i386/busdma_machdep.c 4 Oct 2002 20:40:37 -0000 1.28
+++ i386/i386/busdma_machdep.c 18 Jan 2003 18:47:20 -0000
@@ -44,8 +44,6 @@
#include <machine/bus.h>
#include <machine/md_var.h>
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX_BPAGES 128
struct bus_dma_tag {
Index: i386/isa/gpib.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/i386/isa/gpib.c,v
retrieving revision 1.35
diff -u -r1.35 gpib.c
--- i386/isa/gpib.c 9 Nov 2002 12:55:06 -0000 1.35
+++ i386/isa/gpib.c 18 Jan 2003 18:47:33 -0000
@@ -35,8 +35,6 @@
#error "The gpib device requires the old isa compatibility shims"
#endif
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
#define GPIBPRI (PZERO + 8) | PCATCH
#define SLEEP_MAX 1000
#define SLEEP_MIN 4
Index: i386/isa/gsc.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/i386/isa/gsc.c,v
retrieving revision 1.41
diff -u -r1.41 gsc.c
--- i386/isa/gsc.c 4 Nov 2001 08:52:11 -0000 1.41
+++ i386/isa/gsc.c 18 Jan 2003 18:47:45 -0000
@@ -80,8 +80,6 @@
#define lprintf(args)
#endif
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
#define TIMEOUT (hz*15) /* timeout while reading a buffer - default value */
#define LONG (hz/60) /* timesteps while reading a buffer */
#define GSCPRI PRIBIO /* priority while reading a buffer */
Index: ia64/ia64/busdma_machdep.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/ia64/ia64/busdma_machdep.c,v
retrieving revision 1.10
diff -u -r1.10 busdma_machdep.c
--- ia64/ia64/busdma_machdep.c 4 Oct 2002 20:40:35 -0000 1.10
+++ ia64/ia64/busdma_machdep.c 18 Jan 2003 18:48:16 -0000
@@ -42,8 +42,6 @@
#include <machine/bus.h>
#include <machine/md_var.h>
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX_BPAGES 128
struct bus_dma_tag {
Index: kern/uipc_syscalls.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/kern/uipc_syscalls.c,v
retrieving revision 1.135
diff -u -r1.135 uipc_syscalls.c
--- kern/uipc_syscalls.c 13 Jan 2003 00:28:55 -0000 1.135
+++ kern/uipc_syscalls.c 18 Jan 2003 18:48:06 -0000
@@ -947,9 +947,6 @@
if (len <= 0 || fromsa == 0)
len = 0;
else {
-#ifndef MIN
-#define MIN(a,b) ((a)>(b)?(b):(a))
-#endif
/* save sa_len before it is destroyed by MSG_COMPAT */
len = MIN(len, fromsa->sa_len);
#ifdef COMPAT_OLDSOCK
Index: net/zlib.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/net/zlib.c,v
retrieving revision 1.15
diff -u -r1.15 zlib.c
--- net/zlib.c 9 Nov 2002 12:55:06 -0000 1.15
+++ net/zlib.c 18 Jan 2003 18:48:31 -0000
@@ -2055,8 +2055,6 @@
}
#endif /* DEBUG_ZLIB */
-
-#define MAX(a,b) (a >= b ? a : b)
/* the arguments must not have side effects */
/* ===========================================================================
Index: netinet6/nd6.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/netinet6/nd6.c,v
retrieving revision 1.20
diff -u -r1.20 nd6.c
--- netinet6/nd6.c 2 Aug 2002 20:49:14 -0000 1.20
+++ netinet6/nd6.c 18 Jan 2003 18:48:44 -0000
@@ -204,7 +204,6 @@
nd6_setmtu(ifp)
struct ifnet *ifp;
{
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
struct nd_ifinfo *ndi = &nd_ifinfo[ifp->if_index];
u_long oldmaxmtu = ndi->maxmtu;
u_long oldlinkmtu = ndi->linkmtu;
Index: pccard/pccard.c
===================================================================
RCS file: /home/hiten/ncvs/src/sys/pccard/pccard.c,v
retrieving revision 1.152
diff -u -r1.152 pccard.c
--- pccard/pccard.c 13 Sep 2002 16:23:41 -0000 1.152
+++ pccard/pccard.c 18 Jan 2003 18:48:59 -0000
@@ -52,8 +52,6 @@
#include <machine/md_var.h>
-#define MIN(a,b) ((a)<(b)?(a):(b))
-
static int allocate_driver(struct slot *, struct dev_desc *);
static void inserted(void *);
static void disable_slot(struct slot *);
Index: sys/param.h
===================================================================
RCS file: /home/hiten/ncvs/src/sys/sys/param.h,v
retrieving revision 1.139
diff -u -r1.139 param.h
--- sys/param.h 1 Nov 2002 09:38:33 -0000 1.139
+++ sys/param.h 18 Jan 2003 18:49:55 -0000
@@ -252,10 +252,8 @@
#define powerof2(x) ((((x)-1)&(x))==0)
/* Macros for min/max. */
-#ifndef _KERNEL
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
-#endif
#ifdef _KERNEL
/*
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message