Skip to contentSkip to conversation

minmax-removal

PATCH In review Michael Veeck 2 participants 12 messages Aug 15, 2004 – Sep 21, 2004

Subsystems (6)
Kernel janitors MIPS s390 SuperH +2 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 minmax-removal

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/ia64/hp/sim/simserial.c +1 -5
@@ -50,10 +50,6 @@
 #define _INLINE_ inline
 #endif
 
-#ifndef MIN
-#define MIN(a,b)	((a) < (b) ? (a) : (b))
-#endif
-
 #define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
 
 #define SSC_GETCHAR	21
@@ -275,7 +271,7 @@ static _INLINE_ void transmit_chars(stru
 	 * Then from the beginning of the buffer until necessary
 	 */
 
-	count = MIN(CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE),
+	count = min(CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE),
 		    SERIAL_XMIT_SIZE - info->xmit.tail);
 	console->write(console, info->xmit.buf+info->xmit.tail, count);
 

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

PATCH 1/1 minmax-removal arch/ia64/kernel/unwind.c

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/ia64/kernel/unwind.c +7 -8
@@ -47,7 +47,6 @@
 #include "entry.h"
 #include "unwind_i.h"
 
-#define MIN(a,b)	((a) < (b) ? (a) : (b))
 #define p5		5
 
 #define UNW_LOG_CACHE_SIZE	7	/* each unw_script is ~256 bytes in size */
@@ -963,13 +962,13 @@ static inline void
 desc_mem_stack_f (unw_word t, unw_word size, struct unw_state_record *sr)
 {
 	set_reg(sr->curr.reg + UNW_REG_PSP, UNW_WHERE_NONE,
-		sr->region_start + MIN((int)t, sr->region_len - 1), 16*size);
+		sr->region_start + min_t(int, t, sr->region_len - 1), 16*size);
 }
 
 static inline void
 desc_mem_stack_v (unw_word t, struct unw_state_record *sr)
 {
-	sr->curr.reg[UNW_REG_PSP].when = sr->region_start + MIN((int)t, sr->region_len - 1);
+	sr->curr.reg[UNW_REG_PSP].when = sr->region_start + min_t(int, t, sr->region_len - 1);
 }
 
 static inline void
@@ -1005,7 +1004,7 @@ desc_reg_when (unsigned char regnum, unw
 
 	if (reg->where == UNW_WHERE_NONE)
 		reg->where = UNW_WHERE_GR_SAVE;
-	reg->when = sr->region_start + MIN((int)t, sr->region_len - 1);
+	reg->when = sr->region_start + min_t(int, t, sr->region_len - 1);
 }
 
 static inline void
@@ -1073,7 +1072,7 @@ desc_label_state (unw_word label, struct
 static inline int
 desc_is_active (unsigned char qp, unw_word t, struct unw_state_record *sr)
 {
-	if (sr->when_target <= sr->region_start + MIN((int)t, sr->region_len - 1))
+	if (sr->when_target <= sr->region_start + min_t(int, t, sr->region_len - 1))
 		return 0;
 	if (qp > 0) {
 		if ((sr->pr_val & (1UL << qp)) == 0)
@@ -1114,7 +1113,7 @@ desc_spill_reg_p (unsigned char qp, unw_
 
 	r = sr->curr.reg + decode_abreg(abreg, 0);
 	r->where = where;
-	r->when = sr->region_start + MIN((int)t, sr->region_len - 1);
+	r->when = sr->region_start + min_t(int, t, sr->region_len - 1);
 	r->val = (ytreg & 0x7f);
 }
 
@@ -1129,7 +1128,7 @@ desc_spill_psprel_p (unsigned char qp, u
 
 	r = sr->curr.reg + decode_abreg(abreg, 1);
 	r->where = UNW_WHERE_PSPREL;
-	r->when = sr->region_start + MIN((int)t, sr->region_len - 1);
+	r->when = sr->region_start + min_t(int, t, sr->region_len - 1);
 	r->val = 0x10 - 4*pspoff;
 }
 
@@ -1144,7 +1143,7 @@ desc_spill_sprel_p (unsigned char qp, un
 
 	r = sr->curr.reg + decode_abreg(abreg, 1);
 	r->where = UNW_WHERE_SPREL;
-	r->when = sr->region_start + MIN((int)t, sr->region_len - 1);
+	r->when = sr->region_start + min_t(int, t, sr->region_len - 1);
 	r->val = 4*spoff;
 }
 

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw

PATCH 1/1 minmax-removal

In reply to Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/ia64/sn/fakeprom/fw-emu.c +2 -4
@@ -77,8 +77,6 @@
 #define MB	(1024*1024UL)
 #define GB	(MB*1024UL)
 #define BOOT_PARAM_ADDR 0x40000
-#define MAX(i,j)		((i) > (j) ? (i) : (j))
-#define MIN(i,j)		((i) < (j) ? (i) : (j))
 #define ALIGN8(p)		(((long)(p) +7) & ~7)
 
 #define FPROM_BUG()		do {while (1);} while (0)
@@ -497,7 +495,7 @@ sys_fw_init (const char *args, int argle
 	num_nodes = GetNumNodes();
 	num_cpus = GetNumCpus();
 	for (max_nasid=0, cnode=0; cnode<num_nodes; cnode++)
-		max_nasid = MAX(max_nasid, GetNasid(cnode));
+		max_nasid = max(max_nasid, GetNasid(cnode));
 
 
 	memset(fw_mem, 0, sizeof(fw_mem));
@@ -670,7 +668,7 @@ sys_fw_init (const char *args, int argle
 	for (i=0; i<=max_nasid; i++)
 		for (j=0; j<=max_nasid; j++)
 			if (nasid_present(i) && nasid_present(j))
-				*(cp+PROXIMITY_DOMAIN(i)*acpi_slit->localities+PROXIMITY_DOMAIN(j)) = 10 + MIN(254, 5*abs(i-j));
+				*(cp+PROXIMITY_DOMAIN(i)*acpi_slit->localities+PROXIMITY_DOMAIN(j)) = 10 + min(254, 5*abs(i-j));
 
 	cp = acpi_slit->entry + acpi_slit->localities*acpi_slit->localities;
 	acpi_checksum(&acpi_slit->header, cp - (char*)acpi_slit);

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw

PATCH 1/1 minmax-removal arch/m68k/kernel/bios32.c

In reply to Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/m68k/kernel/bios32.c +2 -4
@@ -46,8 +46,6 @@
 
 #define ALIGN(val,align)	(((val) + ((align) - 1)) & ~((align) - 1))
 
-#define MAX(val1, val2)		(((val1) > (val2)) ? val1 : val2)
-
 /*
  * Offsets relative to the I/O and memory base addresses from where resources
  * are allocated.
@@ -176,7 +174,7 @@ static void __init layout_dev(struct pci
 			 * Align to multiple of size of minimum base.
 			 */
 
-			alignto = MAX(0x040, size) ;
+			alignto = max_t(unsigned int, 0x040, size);
 			base = ALIGN(io_base, alignto);
 			io_base = base + size;
 			pci_write_config_dword(dev, reg, base | PCI_BASE_ADDRESS_SPACE_IO);
@@ -219,7 +217,7 @@ static void __init layout_dev(struct pci
 			 * Align to multiple of size of minimum base.
 			 */
 
-			alignto = MAX(0x1000, size) ;
+			alignto = max_t(unsigned int, 0x1000, size);
 			base = ALIGN(mem_base, alignto);
 			mem_base = base + size;
 			pci_write_config_dword(dev, reg, base);

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#4 lore raw

PATCH 1/1 minmax-removal

In reply to Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/mips/au1000/common/usbdev.c +0 -2
@@ -61,8 +61,6 @@
 #define vdbg(fmt, arg...) do {} while (0)
 #endif
 
-#define MAX(a,b)	(((a)>(b))?(a):(b))
-
 #define ALLOC_FLAGS (in_interrupt () ? GFP_ATOMIC : GFP_KERNEL)
 
 #define EP_FIFO_DEPTH 8

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#5 lore raw

PATCH 1/1 minmax-removal arch/s390/kernel/debug.c

In reply to Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/s390/kernel/debug.c +6 -7
@@ -24,7 +24,6 @@
 
 #include <asm/debug.h>
 
-#define MIN(a,b) (((a)<(b))?(a):(b))
 #define DEBUG_PROLOG_ENTRY -1
 
 /* typedefs */
@@ -435,7 +434,7 @@ static ssize_t debug_output(struct file 
 
 	while(count < len){
 		size = debug_format_entry(p_info);
-		size = MIN((len - count), (size - entry_offset));
+		size = min((len - count), (size - entry_offset));
 
 		if(size){
 			if (copy_to_user(user_buf + count, 
@@ -723,7 +722,7 @@ debug_entry_t *debug_event_common(debug_
 	spin_lock_irqsave(&id->lock, flags);
 	active = get_active_entry(id);
 	memset(DEBUG_DATA(active), 0, id->buf_size);
-	memcpy(DEBUG_DATA(active), buf, MIN(len, id->buf_size));
+	memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
 	debug_finish_entry(id, active, level, 0);
 	spin_unlock_irqrestore(&id->lock, flags);
 
@@ -744,7 +743,7 @@ debug_entry_t *debug_exception_common(de
 	spin_lock_irqsave(&id->lock, flags);
 	active = get_active_entry(id);
 	memset(DEBUG_DATA(active), 0, id->buf_size);
-	memcpy(DEBUG_DATA(active), buf, MIN(len, id->buf_size));
+	memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
 	debug_finish_entry(id, active, level, 1);
 	spin_unlock_irqrestore(&id->lock, flags);
 
@@ -789,7 +788,7 @@ debug_entry_t *debug_sprintf_event(debug
 	curr_event=(debug_sprintf_entry_t *) DEBUG_DATA(active);
 	va_start(ap,string);
 	curr_event->string=string;
-	for(idx=0;idx<MIN(numargs,((id->buf_size / sizeof(long))-1));idx++)
+	for(idx=0;idx<min(numargs,((id->buf_size / sizeof(long))-1));idx++)
 		curr_event->args[idx]=va_arg(ap,long);
 	va_end(ap);
 	debug_finish_entry(id, active, level, 0);
@@ -821,7 +820,7 @@ debug_entry_t *debug_sprintf_exception(d
 	curr_event=(debug_sprintf_entry_t *)DEBUG_DATA(active);
 	va_start(ap,string);
 	curr_event->string=string;
-	for(idx=0;idx<MIN(numargs,((id->buf_size / sizeof(long))-1));idx++)
+	for(idx=0;idx<min(numargs,((id->buf_size / sizeof(long))-1));idx++)
 		curr_event->args[idx]=va_arg(ap,long);
 	va_end(ap);
 	debug_finish_entry(id, active, level, 1);
@@ -1157,7 +1156,7 @@ int debug_sprintf_format_fn(debug_info_t
 	}
 
 	/* number of arguments used for sprintf (without the format string) */
-	num_used_args   = MIN(DEBUG_SPRINTF_MAX_ARGS, (num_longs - 1));
+	num_used_args = min(DEBUG_SPRINTF_MAX_ARGS, (num_longs - 1));
 
 	memset(index,0, DEBUG_SPRINTF_MAX_ARGS * sizeof(int));
 

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#6 lore raw

PATCH 1/1 minmax-removal arch/sh/boards/bigsur/io.c

In reply to Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/sh/boards/bigsur/io.c +2 -6
@@ -37,10 +37,6 @@ static u8 bigsur_iomap_lo_shift[BIGSUR_I
 static u32 bigsur_iomap_hi[BIGSUR_IOMAP_HI_NMAP];
 static u8 bigsur_iomap_hi_shift[BIGSUR_IOMAP_HI_NMAP];
 
-#ifndef MAX
-#define MAX(a,b)    ((a)>(b)?(a):(b))
-#endif
-
 void bigsur_port_map(u32 baseport, u32 nports, u32 addr, u8 shift)
 {
 	u32 port, endport = baseport + nports;
@@ -57,7 +53,7 @@ void bigsur_port_map(u32 baseport, u32 n
 	    	addr += (1<<(BIGSUR_IOMAP_LO_SHIFT));
 	}
 
-	for (port = MAX(baseport, BIGSUR_IOMAP_LO_THRESH) ;
+	for (port = max(baseport, BIGSUR_IOMAP_LO_THRESH);
 	     port < endport && port < BIGSUR_IOMAP_HI_THRESH ;
 	     port += (1<<BIGSUR_IOMAP_HI_SHIFT)) {
 	    	pr_debug("    maphi[0x%x] = 0x%08x\n", port, addr);
@@ -80,7 +76,7 @@ void bigsur_port_unmap(u32 baseport, u32
 		bigsur_iomap_lo[port>>BIGSUR_IOMAP_LO_SHIFT] = 0;
 	}
 
-	for (port = MAX(baseport, BIGSUR_IOMAP_LO_THRESH) ;
+	for (port = max(baseport, BIGSUR_IOMAP_LO_THRESH);
 	     port < endport && port < BIGSUR_IOMAP_HI_THRESH ;
 	     port += (1<<BIGSUR_IOMAP_HI_SHIFT)) {
 		bigsur_iomap_hi[port>>BIGSUR_IOMAP_HI_SHIFT] = 0;

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#7 lore raw

PATCH 1/1 minmax-removal

In reply to Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/sh/cchips/hd6446x/hd64465/io.c +2 -6
@@ -48,10 +48,6 @@ static unsigned char	hd64465_iomap_lo_sh
 static unsigned long	hd64465_iomap_hi[HD64465_IOMAP_HI_NMAP];
 static unsigned char	hd64465_iomap_hi_shift[HD64465_IOMAP_HI_NMAP];
 
-#ifndef MAX
-#define MAX(a,b)    ((a)>(b)?(a):(b))
-#endif
-
 #define PORT2ADDR(x) (sh_mv.mv_isa_port2addr(x))
 
 void hd64465_port_map(unsigned short baseport, unsigned int nports,
@@ -71,7 +67,7 @@ void hd64465_port_map(unsigned short bas
 	    addr += (1<<(HD64465_IOMAP_LO_SHIFT));
 	}
 
-	for (port = MAX(baseport, HD64465_IOMAP_LO_THRESH) ;
+	for (port = max_t(unsigned int, baseport, HD64465_IOMAP_LO_THRESH);
 	     port < endport && port < HD64465_IOMAP_HI_THRESH ;
 	     port += (1<<HD64465_IOMAP_HI_SHIFT)) {
 	    DPRINTK("    maphi[0x%x] = 0x%08lx\n", port, addr);
@@ -95,7 +91,7 @@ void hd64465_port_unmap(unsigned short b
     	    hd64465_iomap_lo[port>>HD64465_IOMAP_LO_SHIFT] = 0;
 	}
 
-	for (port = MAX(baseport, HD64465_IOMAP_LO_THRESH) ;
+	for (port = max_t(unsigned int, baseport, HD64465_IOMAP_LO_THRESH);
 	     port < endport && port < HD64465_IOMAP_HI_THRESH ;
 	     port += (1<<HD64465_IOMAP_HI_SHIFT)) {
     	    hd64465_iomap_hi[port>>HD64465_IOMAP_HI_SHIFT] = 0;

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#8 lore raw

PATCH 1/1 minmax-removal

In reply to Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/um/drivers/mconsole_user.c +2 -4
@@ -67,8 +67,6 @@ static struct mconsole_command *mconsole
 	return(NULL);
 }
 
-#define MIN(a,b) ((a)<(b) ? (a):(b))
-
 #define STRINGX(x) #x
 #define STRING(x) STRINGX(x)
 
@@ -86,7 +84,7 @@ int mconsole_get_request(int fd, struct 
 
 	if(req->request.magic != MCONSOLE_MAGIC){
 		/* Unversioned request */
-		len = MIN(sizeof(req->request.data) - 1, 
+		len = min_t(int, sizeof(req->request.data) - 1, 
 			  strlen((char *) &req->request));
 		memmove(req->request.data, &req->request, len);
 		req->request.data[len] = '\0';
@@ -131,7 +129,7 @@ int mconsole_reply(struct mc_request *re
 		/* err can only be true on the first packet */
 		err = 0;
 
-		len = MIN(total, MCONSOLE_MAX_DATA - 1);
+		len = min(total, MCONSOLE_MAX_DATA - 1);
 
 		if(len == total) reply.more = more;
 		else reply.more = 1;

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#10 lore raw
In reply to Michael Veeck
Quoted 35 lines · Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/um/drivers/mconsole_user.c +1 -3
@@ -67,8 +67,6 @@ static struct mconsole_command *mconsole
 	return(NULL);
 }
 
-#define MIN(a,b) ((a)<(b) ? (a):(b))
-
 #define STRINGX(x) #x
 #define STRING(x) STRINGX(x)
 
@@ -86,7 +84,7 @@ int mconsole_get_request(int fd, struct 
 
 	if(req->request.magic != MCONSOLE_MAGIC){
 		/* Unversioned request */
-		len = MIN(sizeof(req->request.data) - 1, 
+		len = min_t(int, sizeof(req->request.data) - 1, 
 			  strlen((char *) &req->request));
 		memmove(req->request.data, &req->request, len);
 		req->request.data[len] = '\0';

arch/um/drivers/mconsole_user.c int mconsole_reply(struct mc_request *re · line 135

Quoted 8 lines
arch/um/drivers/mconsole_user.c +1 -1
@@ -131,7 +129,7 @@ int mconsole_reply(struct mc_request *re
 		/* err can only be true on the first packet */
 		err = 0;
 
-		len = MIN(total, MCONSOLE_MAX_DATA - 1);
+		len = min(total, MCONSOLE_MAX_DATA - 1);
 
 		if(len == total) reply.more = more;
 		else reply.more = 1;

no idea why that file is in the kernel,
it's a userspace programm dropping this patch.

a++ maks

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#11 lore raw
In reply to Michael Veeck

Hmm, so who's then to ask for permission to throw it out since we are the janitors?

Quoted 44 lines · maximilian attems
Quoted 41 lines · Michael Veeck

Patch (against 2.6.8.1) removes unnecessary min/max macros and changes calls to use kernel.h macros instead.

Since I dont have the hardware those patches are not tested.

Best regards
Veeck

arch/um/drivers/mconsole_user.c +2 -4
@@ -67,8 +67,6 @@ static struct mconsole_command *mconsole
 	return(NULL);
 }
 
-#define MIN(a,b) ((a)<(b) ? (a):(b))
-
 #define STRINGX(x) #x
 #define STRING(x) STRINGX(x)
 
@@ -86,7 +84,7 @@ int mconsole_get_request(int fd, struct 
 
 	if(req->request.magic != MCONSOLE_MAGIC){
 		/* Unversioned request */
-		len = MIN(sizeof(req->request.data) - 1, 
+		len = min_t(int, sizeof(req->request.data) - 1, 
 			  strlen((char *) &req->request));
 		memmove(req->request.data, &req->request, len);
 		req->request.data[len] = '\0';
@@ -131,7 +129,7 @@ int mconsole_reply(struct mc_request *re
 		/* err can only be true on the first packet */
 		err = 0;
 
-		len = MIN(total, MCONSOLE_MAX_DATA - 1);
+		len = min(total, MCONSOLE_MAX_DATA - 1);
 
Quoted 10 lines

arch/um/drivers/mconsole_user.c int mconsole_reply(struct mc_request *re · line 135

Quoted 2 lines
arch/um/drivers/mconsole_user.c +0 -0
 		if(len == total) reply.more = more;
 		else reply.more = 1;

no idea why that file is in the kernel,
it's a userspace programm dropping this patch.

a++ maks

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors