Use standard min/max macros [1/3]
Subsystems (14)
PATCH 1/1 Use standard min/max macros [1/3]
Remove some custom type-unsafe MIN/MAX macros in favor of type-checking min/max from kernel.h
---
This is my very first patch submission, reviews are welcome.
As this patch switches to type-checking macros, it reveals a number of warnings due to bogus comparisons (mostly signed/unsigned). I plan to do another set of patches for some of these.
drivers/isdn/hardware/eicon/debug.c +2 -2
@@ -756,14 +756,14 @@ int diva_get_driver_info (dword id, byte data_length -=9 ; -if ((to_copy =MIN (strlen (clients[id].drvName), data_length-1 ))) { +if ((to_copy =min (strlen (clients[id].drvName), data_length-1 ))) {memcpy (p, clients[id].drvName, to_copy); p += to_copy; data_length -= to_copy;if ((data_length >=4 ) && clients[id].hDbg->drvTag[0 ]) { *p++ ='(' ; data_length -=1 ; -if ((to_copy =MIN (strlen (clients[id].hDbg->drvTag), data_length-2 ))) { +if ((to_copy =min (strlen (clients[id].hDbg->drvTag), data_length-2 ))) {memcpy (p, clients[id].hDbg->drvTag, to_copy); p += to_copy; data_length -= to_copy;
drivers/isdn/hardware/eicon/di.c +4 -4
@@ -133,7 +133,7 @@ #endif i = this->XCurrent;X =PTR_X (a,this);while (i<this->XNum && length<270 ) { - clength =MIN ((word)(270 -length),X [i].PLength-this->XOffset); + clength =min ((word)(270 -length),X [i].PLength-this->XOffset); a->ram_out_buffer(a, &ReqOut->XBuffer.P[length], PTR_P(a,this,&X[i].P[this->XOffset]),
@@ -622,7 +622,7 @@ #endifsizeof (a->stream_buffer), &final, NULL, NULL); } - IoAdapter->RBuffer.length =MIN (MLength,270 ); + IoAdapter->RBuffer.length =min (MLength,270 );if (IoAdapter->RBuffer.length != MLength) { this->complete =0 ; }else {
@@ -676,9 +676,9 @@ #endif this->RCurrent++; }if (cma) { - clength =MIN (MLength,R [this->RCurrent].PLength-this->ROffset); + clength =min (MLength,R [this->RCurrent].PLength-this->ROffset); }else { - clength =MIN (a->ram_inw (a, &RBuffer->length)-offset, + clength =min (a->ram_inw (a, &RBuffer->length)-offset,R [this->RCurrent].PLength-this->ROffset); }if (R [this->RCurrent].P) {
drivers/isdn/hardware/eicon/io.c +1 -1
@@ -262,7 +262,7 @@ #endifcase IDI_SYNC_REQ_XDI_GET_CAPI_PARAMS : {diva_xdi_get_capi_parameters_t prms, *pI = &syncReq->xdi_capi_prms.info;memset (&prms,0x00 ,sizeof (prms)); - prms.structure_length =MIN (sizeof (prms), pI->structure_length); + prms.structure_length =min (sizeof (prms), pI->structure_length);memset (pI,0x00 , pI->structure_length); prms.flag_dynamic_l1_down = (IoAdapter->capi_cfg.cfg_1 & \DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON ) ?1 :0 ;
drivers/isdn/hardware/eicon/istream.c +2 -2
@@ -92,7 +92,7 @@ #endifreturn (-1 );/* was not able to write */ break ;/* only part of message was written */ } - to_write =MIN (length,DIVA_DFIFO_DATA_SZ ); + to_write =min (length,DIVA_DFIFO_DATA_SZ );if (to_write) { a->ram_out_buffer (a,#ifdef PLATFORM_GT_32BIT
@@ -176,7 +176,7 @@ #endifreturn (-1 );/* was not able to read */ break ; } - to_read =MIN (max_length, tmp[1 ]); + to_read =min (max_length, tmp[1 ]);if (to_read) { a->ram_in_buffer(a,#ifdef PLATFORM_GT_32BIT
drivers/isdn/hardware/eicon/platform.h +0 -8
@@ -83,14 +83,6 @@ #ifndef NULL#define NULL ((void *) 0)#endif -#ifndef MIN -#define MIN (a,b) ((a)>(b) ? (b) : (a)) -#endif - -#ifndef MAX -#define MAX (a,b) ((a)>(b) ? (a) : (b)) -#endif -#ifndef far#define far#endif
drivers/net/wan/pc300_drv.c +1 -8
@@ -270,13 +270,6 @@ static struct pci_device_id cpc_pci_dev_ };MODULE_DEVICE_TABLE (pci, cpc_pci_dev_id); -#ifndef cpc_min -#define cpc_min (a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef cpc_max -#define cpc_max (a,b) (((a)>(b))?(a):(b)) -#endif -/* prototypes */ static void tx_dma_buf_pt_init (pc300_t *,int );static void tx_dma_buf_init (pc300_t *,int );
@@ -477,7 +470,7 @@ static int dma_buf_write(pc300_t * card,for (i =0 ; i < nbuf; i++) { ptdescr = (card->hw.rambase +TX_BD_ADDR (ch, card->chan[ch].tx_next_bd)); - nchar =cpc_min (BD_DEF_LEN , tosend); + nchar =min (BD_DEF_LEN , tosend);if (cpc_readb (&ptdescr->status) &DST_OSB ) {memcpy_toio ((card->hw.rambase +cpc_readl (&ptdescr->ptbuf)), &ptdata[len - tosend], nchar);
include/net/irda/irda.h +0 -4
@@ -46,10 +46,6 @@ #ifndef SMALL#define SMALL 5#endif -#ifndef IRDA_MIN /* Lets not mix this MIN with other header files */ -#define IRDA_MIN (a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef IRDA_ALIGN # define IRDA_ALIGN __attribute__((aligned))#endif
net/irda/ircomm/ircomm_tty.c +2 -2
@@ -854,7 +854,7 @@ static void ircomm_tty_wait_until_sent(s orig_jiffies = jiffies;/* Set poll time to 200 ms */ - poll_time =IRDA_MIN (timeout,msecs_to_jiffies (200 )); + poll_time =min (timeout,msecs_to_jiffies (200 ));spin_lock_irqsave (&self->spinlock, flags);while (self->tx_skb && self->tx_skb->len) {
@@ -1201,7 +1201,7 @@ static int ircomm_tty_control_indication clen = skb->data[0 ]; -irda_param_extract_all (self, skb->data+1 ,IRDA_MIN (skb->len-1 , clen), +irda_param_extract_all (self, skb->data+1 ,min (skb->len-1 , clen), &ircomm_param_info);/* No need to kfree_skb - see ircomm_control_indication() */
net/irda/ircomm/ircomm_tty_attach.c +1 -1
@@ -543,7 +543,7 @@ void ircomm_tty_connect_indication(void clen = skb->data[0 ];if (clen)irda_param_extract_all (self, skb->data+1 , -IRDA_MIN (skb->len, clen), +min (skb->len, clen), &ircomm_param_info);ircomm_tty_do_event (self,IRCOMM_TTY_CONNECT_INDICATION ,NULL ,NULL );
net/irda/irlap_frame.c +1 -1
@@ -378,7 +378,7 @@ void irlap_send_discovery_xid_frame(stru info =skb_put (tx_skb,1 ); info[0 ] = discovery->data.charset; - len =IRDA_MIN (discovery->name_len,skb_tailroom (tx_skb)); + len =min (discovery->name_len,skb_tailroom (tx_skb)); info =skb_put (tx_skb, len);memcpy (info, discovery->data.info, len); }
net/irda/irttp.c +4 -4
@@ -1216,7 +1216,7 @@ static void irttp_connect_confirm(void * plen = skb->data[0 ]; ret =irda_param_extract_all (self, skb->data+1 , -IRDA_MIN (skb->len-1 , plen), +min (skb->len-1 , plen), ¶m_info);/* Any errors in the parameter list? */
@@ -1229,7 +1229,7 @@ static void irttp_connect_confirm(void *return ; }/* Remove parameters */ -skb_pull (skb,IRDA_MIN (skb->len, plen+1 )); +skb_pull (skb,min (skb->len, plen+1 )); } IRDA_DEBUG(4, "%s() send=%d,avail=%d,remote=%d\n", __FUNCTION__,
@@ -1293,7 +1293,7 @@ void irttp_connect_indication(void *inst plen = skb->data[0 ]; ret =irda_param_extract_all (self, skb->data+1 , -IRDA_MIN (skb->len-1 , plen), +min (skb->len-1 , plen), ¶m_info);/* Any errors in the parameter list? */
@@ -1307,7 +1307,7 @@ void irttp_connect_indication(void *inst }/* Remove parameters */ -skb_pull (skb,IRDA_MIN (skb->len, plen+1 )); +skb_pull (skb,min (skb->len, plen+1 )); }if (self->notify.connect_indication) {
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 Use standard min/max macros [2/3]
Remove some custom type-unsafe MIN/MAX macros in favor of type-checking min/max from kernel.h
---
drivers/scsi/aic7xxx/aic79xx.h +0 -8
@@ -53,14 +53,6 @@ struct ahd_platform_data;struct scb_platform_data ;/****************************** Useful Macros *********************************/ -#ifndef MAX -#define MAX (a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN (a,b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef TRUE #define TRUE 1#endif
drivers/scsi/aic7xxx/aic79xx_core.c +11 -11
@@ -2850,14 +2850,14 @@ ahd_devlimited_syncrate(struct ahd_softc transinfo = &tinfo->goal; *ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN );if (transinfo->width =MSG_EXT_WDTR_BUS_8_BIT ) { - maxsync =MAX (maxsync,AHD_SYNCRATE_ULTRA2 ); + maxsync =max (maxsync,AHD_SYNCRATE_ULTRA2 ); *ppr_options &= ~MSG_EXT_PPR_DT_REQ ; }if (transinfo->period =0 ) { *period =0 ; *ppr_options =0 ; }else { - *period =MAX (*period, transinfo->period); + *period =max (*period, transinfo->period);ahd_find_syncrate (ahd, period, ppr_options, maxsync); } }
@@ -2924,12 +2924,12 @@ ahd_validate_offset(struct ahd_softc *ah maxoffset =MAX_OFFSET_PACED ; }else maxoffset =MAX_OFFSET_NON_PACED ; - *offset =MIN (*offset, maxoffset); + *offset =min (*offset, maxoffset);if (tinfo !=NULL ) {if (role =ROLE_TARGET ) - *offset =MIN (*offset, tinfo->user.offset); + *offset =min (*offset, tinfo->user.offset);else - *offset =MIN (*offset, tinfo->goal.offset); + *offset =min (*offset, tinfo->goal.offset); } }
@@ -2955,9 +2955,9 @@ ahd_validate_width(struct ahd_softc *ahd }if (tinfo !=NULL ) {if (role =ROLE_TARGET ) - *bus_width =MIN (tinfo->user.width, *bus_width); + *bus_width =min (tinfo->user.width, *bus_width);else - *bus_width =MIN (tinfo->goal.width, *bus_width); + *bus_width =min (tinfo->goal.width, *bus_width); } }
@@ -6057,9 +6057,9 @@ #ifdef AHD_DEBUG#endif } - newcount =MIN (scb_data->sense_left, scb_data->scbs_left); - newcount =MIN (newcount, scb_data->sgs_left); - newcount =MIN (newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs)); + newcount =min (scb_data->sense_left, scb_data->scbs_left); + newcount =min (newcount, scb_data->sgs_left); + newcount =min (newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));for (i =0 ; i < newcount; i++) {struct scb_platform_data *pdata;u_int col_tag;
@@ -8668,7 +8668,7 @@ ahd_resolve_seqaddr(struct ahd_softc *ahif (skip_addr > i) {int end_addr; - end_addr =MIN (address, skip_addr); + end_addr =min (address, skip_addr); address_offset += end_addr - i; i = skip_addr; }else {
drivers/scsi/aic7xxx/aic79xx_osm.c +2 -2
@@ -1813,7 +1813,7 @@ ahd_linux_handle_scsi_status(struct ahd_u_int sense_offset;if (scb->flags &SCB_SENSE ) { - sense_size =MIN (sizeof (struct scsi_sense_data ) + sense_size =min (sizeof (struct scsi_sense_data ) -ahd_get_sense_residual (scb),sizeof (cmd->sense_buffer)); sense_offset =0 ;
@@ -1824,7 +1824,7 @@ ahd_linux_handle_scsi_status(struct ahd_*/ siu = (struct scsi_status_iu_header *) scb->sense_data; - sense_size =MIN (scsi_4btoul (siu->sense_length), + sense_size =min (scsi_4btoul (siu->sense_length),sizeof (cmd->sense_buffer)); sense_offset =SIU_SENSE_OFFSET (siu); }
drivers/scsi/aic7xxx/aic7xxx.h +0 -8
@@ -54,14 +54,6 @@ struct scb_platform_data;struct seeprom_descriptor ;/****************************** Useful Macros *********************************/ -#ifndef MAX -#define MAX (a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN (a,b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef TRUE #define TRUE 1#endif
drivers/scsi/aic7xxx/aic7xxx_core.c +9 -9
@@ -1671,7 +1671,7 @@ ahc_devlimited_syncrate(struct ahc_softc transinfo = &tinfo->goal; *ppr_options &= transinfo->ppr_options;if (transinfo->width =MSG_EXT_WDTR_BUS_8_BIT ) { - maxsync =MAX (maxsync,AHC_SYNCRATE_ULTRA2 ); + maxsync =max (maxsync,AHC_SYNCRATE_ULTRA2 ); *ppr_options &= ~MSG_EXT_PPR_DT_REQ ; }if (transinfo->period =0 ) {
@@ -1679,7 +1679,7 @@ ahc_devlimited_syncrate(struct ahc_softc *ppr_options =0 ;return (NULL ); } - *period =MAX (*period, transinfo->period); + *period =max (*period, transinfo->period);return (ahc_find_syncrate (ahc, period, ppr_options, maxsync)); }
@@ -1804,12 +1804,12 @@ ahc_validate_offset(struct ahc_softc *ahelse maxoffset =MAX_OFFSET_8BIT ; } - *offset =MIN (*offset, maxoffset); + *offset =min (*offset, maxoffset);if (tinfo !=NULL ) {if (role =ROLE_TARGET ) - *offset =MIN (*offset, tinfo->user.offset); + *offset =min (*offset, tinfo->user.offset);else - *offset =MIN (*offset, tinfo->goal.offset); + *offset =min (*offset, tinfo->goal.offset); } }
@@ -1835,9 +1835,9 @@ ahc_validate_width(struct ahc_softc *ahc }if (tinfo !=NULL ) {if (role =ROLE_TARGET ) - *bus_width =MIN (tinfo->user.width, *bus_width); + *bus_width =min (tinfo->user.width, *bus_width);else - *bus_width =MIN (tinfo->goal.width, *bus_width); + *bus_width =min (tinfo->goal.width, *bus_width); } }
@@ -4406,7 +4406,7 @@ ahc_alloc_scbs(struct ahc_softc *ahc) physaddr = sg_map->sg_physaddr; newcount = (PAGE_SIZE / (AHC_NSEG *sizeof (struct ahc_dma_seg ))); - newcount =MIN (newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs)); + newcount =min (newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs));for (i =0 ; i < newcount; i++) {struct scb_platform_data *pdata;#ifndef __linux__
@@ -6442,7 +6442,7 @@ ahc_download_instr(struct ahc_softc *ahcif (skip_addr > i) {int end_addr; - end_addr =MIN (address, skip_addr); + end_addr =min (address, skip_addr); address_offset += end_addr - i; i = skip_addr; }else {
drivers/scsi/aic7xxx/aic7xxx_osm.c +1 -1
@@ -1875,7 +1875,7 @@ ahc_linux_handle_scsi_status(struct ahc_if (scb->flags &SCB_SENSE ) {u_int sense_size; - sense_size =MIN (sizeof (struct scsi_sense_data ) + sense_size =min (sizeof (struct scsi_sense_data ) -ahc_get_sense_residual (scb),sizeof (cmd->sense_buffer)); memcpy(cmd->sense_buffer,
drivers/scsi/ips.h +0 -4
@@ -120,10 +120,6 @@ #include <linux/version.h>#define MDELAY mdelay#endif -#ifndef min -#define min (x,y) ((x) < (y) ? x : y) -#endif -#ifndef __iomem/* For clean compiles in earlier kernels without __iomem annotations */ #define __iomem#endif
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 Use standard min/max macros [3/3]
In reply to Clément StenacRemove some custom type-unsafe MIN/MAX macros in favor of type-checking min/max from kernel.h
---
drivers/acpi/executer/exfldio.c +3 -3
@@ -752,7 +752,7 @@ acpi_ex_extract_from_field(union acpi_op/* Write merged datum to target buffer */ ACPI_MEMCPY (((char *)buffer) + buffer_offset, &merged_datum, -ACPI_MIN (obj_desc->common_field.access_byte_width, +min (obj_desc->common_field.access_byte_width, buffer_length - buffer_offset)); buffer_offset += obj_desc->common_field.access_byte_width;
@@ -771,7 +771,7 @@ acpi_ex_extract_from_field(union acpi_op/* Write the last datum to the buffer */ ACPI_MEMCPY (((char *)buffer) + buffer_offset, &merged_datum, -ACPI_MIN (obj_desc->common_field.access_byte_width, +min (obj_desc->common_field.access_byte_width, buffer_length - buffer_offset));return_ACPI_STATUS (AE_OK );
@@ -850,7 +850,7 @@ acpi_ex_insert_into_field(union acpi_ope/* Get initial Datum from the input buffer */ ACPI_MEMCPY (&raw_datum, buffer, -ACPI_MIN (obj_desc->common_field.access_byte_width, +min (obj_desc->common_field.access_byte_width, buffer_length - buffer_offset)); merged_datum @@ -903,7 +903,7 @@ acpi_ex_insert_into_field(union acpi_ope
buffer_offset += obj_desc->common_field.access_byte_width; ACPI_MEMCPY(&raw_datum, ((char *)buffer) + buffer_offset,
- ACPI_MIN(obj_desc->common_field.access_byte_width,
+ min(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
merged_datum | raw_datum << obj_desc->common_field.start_field_bit_offset;
drivers/char/istallion.c +11 -13
@@ -627,8 +627,6 @@ static unsigned int stli_baudrates[] = {/* * Define some handy local macros... */ -#undef MIN -#define MIN (a,b) (((a) <= (b)) ? (a) : (b))#undef TOLOWER#define TOLOWER (x) ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
@@ -1455,12 +1453,12 @@ static int stli_write(struct tty_struct stlen = len; } - len =MIN (len, count); + len =min (len, count); count =0 ; shbuf = (char __iomem *)EBRDGETMEMPTR (brdp, portp->txoffset);while (len >0 ) { - stlen =MIN (len, stlen); + stlen =min (len, stlen);memcpy_toio (shbuf + head, chbuf, stlen); chbuf += stlen; len -= stlen;
@@ -1574,13 +1572,13 @@ static void stli_flushchars(struct tty_s stlen = len; } - len =MIN (len, cooksize); + len =min (len, cooksize); count =0 ; shbuf = (char *)EBRDGETMEMPTR (brdp, portp->txoffset); buf = stli_txcookbuf;while (len >0 ) { - stlen =MIN (len, stlen); + stlen =min (len, stlen);memcpy_toio (shbuf + head, buf, stlen); buf += stlen; len -= stlen;
@@ -2416,7 +2414,7 @@ static void stli_read(stlibrd_t *brdp, swhile (len >0 ) {unsigned char *cptr; - stlen =MIN (len, stlen); + stlen =min (len, stlen);tty_prepare_flip_string (tty, &cptr, stlen);memcpy_fromio (cptr, shbuf + tail, stlen); len -= stlen;
@@ -4219,7 +4217,7 @@ static ssize_t stli_memread(struct fileif (off >= brdp->memsize || off + count < off)return 0 ; - size =MIN (count, (brdp->memsize - off)); + size =min (count, (brdp->memsize - off));/* * Copy the data a page at a time
@@ -4233,8 +4231,8 @@ static ssize_t stli_memread(struct filespin_lock_irqsave (&brd_lock, flags);EBRDENABLE (brdp); memptr = (void *)EBRDGETMEMPTR (brdp, off); - n =MIN (size, (brdp->pagesize - (((unsigned long ) off) % brdp->pagesize))); - n =MIN (n,PAGE_SIZE ); + n =min (size, (brdp->pagesize - (((unsigned long ) off) % brdp->pagesize))); + n =min (n,PAGE_SIZE );memcpy_fromio (p, memptr, n);EBRDDISABLE (brdp);spin_unlock_irqrestore (&brd_lock, flags);
@@ -4285,7 +4283,7 @@ static ssize_t stli_memwrite(struct filereturn 0 ; chbuf = (char __user *) buf; - size =MIN (count, (brdp->memsize - off)); + size =min (count, (brdp->memsize - off));/* * Copy the data a page at a time
@@ -4296,8 +4294,8 @@ static ssize_t stli_memwrite(struct filereturn -ENOMEM ;while (size >0 ) { - n =MIN (size, (brdp->pagesize - (((unsigned long ) off) % brdp->pagesize))); - n =MIN (n,PAGE_SIZE ); + n =min (size, (brdp->pagesize - (((unsigned long ) off) % brdp->pagesize))); + n =min (n,PAGE_SIZE );if (copy_from_user (p, chbuf, n)) {if (count =0 ) count = -EFAULT ;
drivers/char/stallion.c +10 -13
@@ -445,9 +445,6 @@ static unsigned int stl_baudrates[] = {/* * Define some handy local macros... */ -#undef MIN -#define MIN (a,b) (((a) <= (b)) ? (a) : (b)) -#undef TOLOWER#define TOLOWER (x) ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
@@ -1201,10 +1198,10 @@ #endif stlen = len; } - len =MIN (len, count); + len =min (len, count); count =0 ;while (len >0 ) { - stlen =MIN (len, stlen); + stlen =min (len, stlen);memcpy (head, chbuf, stlen); len -= stlen; chbuf += stlen;
@@ -3936,9 +3933,9 @@ #endif }outb (srer, (ioaddr +EREG_DATA )); }else { - len =MIN (len,CD1400_TXFIFOSIZE ); + len =min (len,CD1400_TXFIFOSIZE ); portp->stats.txtotal += len; - stlen =MIN (len, ((portp->tx.buf +STL_TXBUFSIZE ) - tail)); + stlen =min (len, ((portp->tx.buf +STL_TXBUFSIZE ) - tail));outb ((TDR + portp->uartaddr), ioaddr);outsb ((ioaddr +EREG_DATA ), tail, stlen); len -= stlen;
@@ -3993,13 +3990,13 @@ #endifoutb ((RDCR + portp->uartaddr), ioaddr); len =inb (ioaddr +EREG_DATA );if (tty =NULL || (buflen =tty_buffer_request_room (tty, len)) =0 ) { - len =MIN (len,sizeof (stl_unwanted)); + len =min (len,sizeof (stl_unwanted));outb ((RDSR + portp->uartaddr), ioaddr);insb ((ioaddr +EREG_DATA ), &stl_unwanted[0 ], len); portp->stats.rxlost += len; portp->stats.rxtotal += len; }else { - len =MIN (len, buflen); + len =min (len, buflen);if (len >0 ) {unsigned char *ptr;outb ((RDSR + portp->uartaddr), ioaddr);
@@ -4897,9 +4894,9 @@ #endifoutb (mr0, (ioaddr +XP_DATA )); } }else { - len =MIN (len,SC26198_TXFIFOSIZE ); + len =min (len,SC26198_TXFIFOSIZE ); portp->stats.txtotal += len; - stlen =MIN (len, ((portp->tx.buf +STL_TXBUFSIZE ) - tail)); + stlen =min (len, ((portp->tx.buf +STL_TXBUFSIZE ) - tail));outb (GTXFIFO , (ioaddr +XP_ADDR ));outsb ((ioaddr +XP_DATA ), tail, stlen); len -= stlen;
@@ -4942,13 +4939,13 @@ #endifif ((iack &IVR_TYPEMASK ) =IVR_RXDATA ) {if (tty =NULL || (buflen =tty_buffer_request_room (tty, len)) =0 ) { - len =MIN (len,sizeof (stl_unwanted)); + len =min (len,sizeof (stl_unwanted));outb (GRXFIFO , (ioaddr +XP_ADDR ));insb ((ioaddr +XP_DATA ), &stl_unwanted[0 ], len); portp->stats.rxlost += len; portp->stats.rxtotal += len; }else { - len =MIN (len, buflen); + len =min (len, buflen);if (len >0 ) {unsigned char *ptr;outb (GRXFIFO , (ioaddr +XP_ADDR ));
drivers/pcmcia/cistpl.c +1 -3
@@ -590,8 +590,6 @@ EXPORT_SYMBOL(pccard_get_next_tuple);/*==================================*/ -#define _MIN (a, b) (((a) < (b)) ? (a) : (b)) -int pccard_get_tuple_data (struct pcmcia_socket *s,tuple_t *tuple) {u_int len;
@@ -607,7 +605,7 @@ int pccard_get_tuple_data(struct pcmcia_return CS_SUCCESS ;read_cis_cache (s,SPACE (tuple->Flags), tuple->CISOffset + tuple->TupleOffset, -_MIN (len, tuple->TupleDataMax), tuple->TupleData); +min (len, tuple->TupleDataMax), tuple->TupleData);return CS_SUCCESS ; }EXPORT_SYMBOL (pccard_get_tuple_data);
drivers/s390/crypto/z90common.h +0 -1
@@ -160,7 +160,6 @@ #else #define PDEBUG(fmt, args...) do {} while (0)#endif -#define UMIN (a,b) ((a) < (b) ? (a) : (b))#define IS_EVEN (x) ((x) = (2 * ((x) / 2)))#endif
drivers/s390/crypto/z90main.c +1 -1
@@ -2119,7 +2119,7 @@ #define LBUFSIZE 1200if (count <=0 )return 0 ; - local_count =UMIN ((unsigned int )count,LBUFSIZE -1 ); + local_count =min ((unsigned int )count,LBUFSIZE -1 );if (copy_from_user (lbuf, buffer, local_count) !=0 ) {kfree (lbuf);
include/acpi/acmacros.h +0 -1
@@ -54,7 +54,6 @@ #define ACPI_HIBYTE(l)#define ACPI_SET_BIT (target,bit) ((target) |= (bit))#define ACPI_CLEAR_BIT (target,bit) ((target) &= ~(bit)) -#define ACPI_MIN (a,b) (((a)<(b))?(a):(b))/* Size calculation */
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [PATCH] Use standard min/max macros [3/3]
In reply to Clément StenacQuoted 33 lines · Clément Stenac
Remove some custom type-unsafe MIN/MAX macros in favor of type-checking min/max from
kernel.hdrivers/acpi/executer/exfldio.c +3
-3@@ -752,7 +752,7 @@ acpi_ex_extract_from_field(union acpi_op/* Write merged datum to target buffer */ ACPI_MEMCPY (((char *)buffer) + buffer_offset, &merged_datum, -ACPI_MIN (obj_desc->common_field.access_byte_width, +min (obj_desc->common_field.access_byte_width, buffer_length - buffer_offset)); buffer_offset += obj_desc->common_field.access_byte_width;@@ -771,7 +771,7 @@ acpi_ex_extract_from_field(union acpi_op/* Write the last datum to the buffer */ ACPI_MEMCPY (((char *)buffer) + buffer_offset, &merged_datum, -ACPI_MIN (obj_desc->common_field.access_byte_width, +min (obj_desc->common_field.access_byte_width, buffer_length - buffer_offset));return_ACPI_STATUS (AE_OK );@@ -850,7 +850,7 @@ acpi_ex_insert_into_field(union acpi_ope/* Get initial Datum from the input buffer */ ACPI_MEMCPY (&raw_datum, buffer, -ACPI_MIN (obj_desc->common_field.access_byte_width, +min (obj_desc->common_field.access_byte_width, buffer_length - buffer_offset)); merged_datum > @@ -903,7 +903,7 @@ acpi_ex_insert_into_field(union acpi_ope
drivers/acpi/executer/exfldio.c
Quoted 6 lines
drivers/acpi/executer/exfldio.c +1
-1buffer_offset += obj_desc->common_field.access_byte_width;ACPI_MEMCPY (&raw_datum, ((char *)buffer) + buffer_offset, -ACPI_MIN (obj_desc->common_field.access_byte_width, +min (obj_desc->common_field.access_byte_width, buffer_length - buffer_offset)); merged_datum |> raw_datum << obj_desc->common_field.start_field_bit_offset;
ACPI wants to keep code shared between multiple OSms so save this part for better day. :-(
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [PATCH] Use standard min/max macros [3/3]
In reply to Clément StenacRemove some custom type-unsafe MIN/MAX macros in favor of type-checking min/max from kernel.h
---
This version removes the ACPI part so as to keep it totally OS-independent.
Should I copy the macro itself or just let it as such ?
drivers/char/istallion.c +11 -13
@@ -627,8 +627,6 @@ static unsigned int stli_baudrates[] = {/* * Define some handy local macros... */ -#undef MIN -#define MIN (a,b) (((a) <= (b)) ? (a) : (b))#undef TOLOWER#define TOLOWER (x) ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
@@ -1455,12 +1453,12 @@ static int stli_write(struct tty_struct stlen = len; } - len =MIN (len, count); + len =min (len, count); count =0 ; shbuf = (char __iomem *)EBRDGETMEMPTR (brdp, portp->txoffset);while (len >0 ) { - stlen =MIN (len, stlen); + stlen =min (len, stlen);memcpy_toio (shbuf + head, chbuf, stlen); chbuf += stlen; len -= stlen;
@@ -1574,13 +1572,13 @@ static void stli_flushchars(struct tty_s stlen = len; } - len =MIN (len, cooksize); + len =min (len, cooksize); count =0 ; shbuf = (char *)EBRDGETMEMPTR (brdp, portp->txoffset); buf = stli_txcookbuf;while (len >0 ) { - stlen =MIN (len, stlen); + stlen =min (len, stlen);memcpy_toio (shbuf + head, buf, stlen); buf += stlen; len -= stlen;
@@ -2416,7 +2414,7 @@ static void stli_read(stlibrd_t *brdp, swhile (len >0 ) {unsigned char *cptr; - stlen =MIN (len, stlen); + stlen =min (len, stlen);tty_prepare_flip_string (tty, &cptr, stlen);memcpy_fromio (cptr, shbuf + tail, stlen); len -= stlen;
@@ -4219,7 +4217,7 @@ static ssize_t stli_memread(struct fileif (off >= brdp->memsize || off + count < off)return 0 ; - size =MIN (count, (brdp->memsize - off)); + size =min (count, (brdp->memsize - off));/* * Copy the data a page at a time
@@ -4233,8 +4231,8 @@ static ssize_t stli_memread(struct filespin_lock_irqsave (&brd_lock, flags);EBRDENABLE (brdp); memptr = (void *)EBRDGETMEMPTR (brdp, off); - n =MIN (size, (brdp->pagesize - (((unsigned long ) off) % brdp->pagesize))); - n =MIN (n,PAGE_SIZE ); + n =min (size, (brdp->pagesize - (((unsigned long ) off) % brdp->pagesize))); + n =min (n,PAGE_SIZE );memcpy_fromio (p, memptr, n);EBRDDISABLE (brdp);spin_unlock_irqrestore (&brd_lock, flags);
@@ -4285,7 +4283,7 @@ static ssize_t stli_memwrite(struct filereturn 0 ; chbuf = (char __user *) buf; - size =MIN (count, (brdp->memsize - off)); + size =min (count, (brdp->memsize - off));/* * Copy the data a page at a time
@@ -4296,8 +4294,8 @@ static ssize_t stli_memwrite(struct filereturn -ENOMEM ;while (size >0 ) { - n =MIN (size, (brdp->pagesize - (((unsigned long ) off) % brdp->pagesize))); - n =MIN (n,PAGE_SIZE ); + n =min (size, (brdp->pagesize - (((unsigned long ) off) % brdp->pagesize))); + n =min (n,PAGE_SIZE );if (copy_from_user (p, chbuf, n)) {if (count =0 ) count = -EFAULT ;
drivers/char/stallion.c +10 -13
@@ -445,9 +445,6 @@ static unsigned int stl_baudrates[] = {/* * Define some handy local macros... */ -#undef MIN -#define MIN (a,b) (((a) <= (b)) ? (a) : (b)) -#undef TOLOWER#define TOLOWER (x) ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
@@ -1201,10 +1198,10 @@ #endif stlen = len; } - len =MIN (len, count); + len =min (len, count); count =0 ;while (len >0 ) { - stlen =MIN (len, stlen); + stlen =min (len, stlen);memcpy (head, chbuf, stlen); len -= stlen; chbuf += stlen;
@@ -3936,9 +3933,9 @@ #endif }outb (srer, (ioaddr +EREG_DATA )); }else { - len =MIN (len,CD1400_TXFIFOSIZE ); + len =min (len,CD1400_TXFIFOSIZE ); portp->stats.txtotal += len; - stlen =MIN (len, ((portp->tx.buf +STL_TXBUFSIZE ) - tail)); + stlen =min (len, ((portp->tx.buf +STL_TXBUFSIZE ) - tail));outb ((TDR + portp->uartaddr), ioaddr);outsb ((ioaddr +EREG_DATA ), tail, stlen); len -= stlen;
@@ -3993,13 +3990,13 @@ #endifoutb ((RDCR + portp->uartaddr), ioaddr); len =inb (ioaddr +EREG_DATA );if (tty =NULL || (buflen =tty_buffer_request_room (tty, len)) =0 ) { - len =MIN (len,sizeof (stl_unwanted)); + len =min (len,sizeof (stl_unwanted));outb ((RDSR + portp->uartaddr), ioaddr);insb ((ioaddr +EREG_DATA ), &stl_unwanted[0 ], len); portp->stats.rxlost += len; portp->stats.rxtotal += len; }else { - len =MIN (len, buflen); + len =min (len, buflen);if (len >0 ) {unsigned char *ptr;outb ((RDSR + portp->uartaddr), ioaddr);
@@ -4897,9 +4894,9 @@ #endifoutb (mr0, (ioaddr +XP_DATA )); } }else { - len =MIN (len,SC26198_TXFIFOSIZE ); + len =min (len,SC26198_TXFIFOSIZE ); portp->stats.txtotal += len; - stlen =MIN (len, ((portp->tx.buf +STL_TXBUFSIZE ) - tail)); + stlen =min (len, ((portp->tx.buf +STL_TXBUFSIZE ) - tail));outb (GTXFIFO , (ioaddr +XP_ADDR ));outsb ((ioaddr +XP_DATA ), tail, stlen); len -= stlen;
@@ -4942,13 +4939,13 @@ #endifif ((iack &IVR_TYPEMASK ) =IVR_RXDATA ) {if (tty =NULL || (buflen =tty_buffer_request_room (tty, len)) =0 ) { - len =MIN (len,sizeof (stl_unwanted)); + len =min (len,sizeof (stl_unwanted));outb (GRXFIFO , (ioaddr +XP_ADDR ));insb ((ioaddr +XP_DATA ), &stl_unwanted[0 ], len); portp->stats.rxlost += len; portp->stats.rxtotal += len; }else { - len =MIN (len, buflen); + len =min (len, buflen);if (len >0 ) {unsigned char *ptr;outb (GRXFIFO , (ioaddr +XP_ADDR ));
drivers/pcmcia/cistpl.c +1 -3
@@ -590,8 +590,6 @@ EXPORT_SYMBOL(pccard_get_next_tuple);/*==================================*/ -#define _MIN (a, b) (((a) < (b)) ? (a) : (b)) -int pccard_get_tuple_data (struct pcmcia_socket *s,tuple_t *tuple) {u_int len;
@@ -607,7 +605,7 @@ int pccard_get_tuple_data(struct pcmcia_return CS_SUCCESS ;read_cis_cache (s,SPACE (tuple->Flags), tuple->CISOffset + tuple->TupleOffset, -_MIN (len, tuple->TupleDataMax), tuple->TupleData); +min (len, tuple->TupleDataMax), tuple->TupleData);return CS_SUCCESS ; }EXPORT_SYMBOL (pccard_get_tuple_data);
drivers/s390/crypto/z90common.h +0 -1
@@ -160,7 +160,6 @@ #else #define PDEBUG(fmt, args...) do {} while (0)#endif -#define UMIN (a,b) ((a) < (b) ? (a) : (b))#define IS_EVEN (x) ((x) = (2 * ((x) / 2)))#endif
drivers/s390/crypto/z90main.c +1 -1
@@ -2119,7 +2119,7 @@ #define LBUFSIZE 1200if (count <=0 )return 0 ; - local_count =UMIN ((unsigned int )count,LBUFSIZE -1 ); + local_count =min ((unsigned int )count,LBUFSIZE -1 );if (copy_from_user (lbuf, buffer, local_count) !=0 ) {kfree (lbuf);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors