MIN/MAX cleanup
Subsystems (4)
PATCH 1/1 MIN/MAX cleanup
Cleanups done to use min/max macros from kernel.h. Handcrafted MIN/MAX macros in some drivers are changed to use macros from kernel.h
Tested for allmodconfig and allnoconfig configurations.
---
drivers/isdn/hardware/eicon/debug.c | 4 +- drivers/isdn/hardware/eicon/di.c | 6 ++-- drivers/isdn/hardware/eicon/istream.c | 2 - drivers/isdn/hardware/eicon/platform.h | 4 +- drivers/scsi/aic7xxx/aic79xx.h | 6 ++-- drivers/scsi/aic7xxx/aic79xx_core.c | 12 ++++---- drivers/scsi/aic7xxx/aic79xx_osm.c | 2 - drivers/scsi/aic7xxx/aic7xxx.h | 6 ++-- drivers/scsi/aic7xxx/aic7xxx_core.c | 12 ++++---- drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 - fs/xfs/xfs_btree.h | 34 ++++++----------------- fs/xfs/xfs_rtalloc.c | 16 +++++----- fs/xfs/xfs_rtalloc.h | 6 ++-- include/linux/utsrelease.h | 1 14 files changed, 53 insertions(+), 60 deletions(-)
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), (size_t ) (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), (size_t ) (data_length-2 )))) {memcpy (p, clients[id].hDbg->drvTag, to_copy); p += to_copy; data_length -= to_copy;
drivers/isdn/hardware/eicon/di.c +3 -3
@@ -133,7 +133,7 @@ void pr_out(ADAPTER * a) 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),(word) (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 @@ byte isdn_ind(ADAPTER * a,sizeof (a->stream_buffer), &final, NULL, NULL); } - IoAdapter->RBuffer.length =MIN (MLength,270 ); + IoAdapter->RBuffer.length =MIN (MLength, (word )270 );if (IoAdapter->RBuffer.length != MLength) { this->complete =0 ; }else {
@@ -676,7 +676,7 @@ byte isdn_ind(ADAPTER * a, this->RCurrent++; }if (cma) { - clength =MIN (MLength,R [this->RCurrent].PLength-this->ROffset); + clength =MIN (MLength, (word) (R [this->RCurrent].PLength-this->ROffset)); }else { clength =MIN (a->ram_inw (a, &RBuffer->length)-offset,R [this->RCurrent].PLength-this->ROffset);
drivers/isdn/hardware/eicon/istream.c +1 -1
@@ -176,7 +176,7 @@ int diva_istream_read (void* context,return (-1 );/* was not able to read */ break ; } - to_read =MIN (max_length, tmp[1 ]); + to_read =MIN (max_length, (int ) tmp[1 ]);if (to_read) { a->ram_in_buffer(a,#ifdef PLATFORM_GT_32BIT
drivers/isdn/hardware/eicon/platform.h +2 -2
@@ -84,11 +84,11 @@#endif #ifndef MIN -#define MIN (a,b) ((a)>(b) ? (b) : (a)) +#define MIN (a,b) (min(a,b))#endif #ifndef MAX -#define MAX (a,b) ((a)>(b) ? (a) : (b)) +#define MAX (a,b) (max(a,b))#endif #ifndef far
drivers/scsi/aic7xxx/aic79xx.h +4 -2
@@ -45,6 +45,8 @@#ifndef _AIC79XX_H_#define _AIC79XX_H_ +#include <linux/kernel.h> +/* Register Definitions */ #include "aic79xx_reg.h"
@@ -54,11 +56,11 @@ struct scb_platform_data;/****************************** Useful Macros *********************************/ #ifndef MAX -#define MAX (a,b) (((a) > (b)) ? (a) : (b)) +#define MAX (a,b) (max(a,b))#endif #ifndef MIN -#define MIN (a,b) (((a) < (b)) ? (a) : (b)) +#define MIN (a,b) (min(a,b))#endif #ifndef TRUE
drivers/scsi/aic7xxx/aic79xx_core.c +6 -6
@@ -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, (u_int )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, (u_int ) transinfo->period);ahd_find_syncrate (ahd, period, ppr_options, maxsync); } }
@@ -2927,9 +2927,9 @@ ahd_validate_offset(struct ahd_softc *ah *offset =MIN (*offset, maxoffset);if (tinfo !=NULL ) {if (role ==ROLE_TARGET ) - *offset =MIN (*offset, tinfo->user.offset); + *offset =MIN (*offset, (u_int ) tinfo->user.offset);else - *offset =MIN (*offset, tinfo->goal.offset); + *offset =MIN (*offset, (u_int ) 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 ((u_int ) tinfo->user.width, *bus_width);else - *bus_width =MIN (tinfo->goal.width, *bus_width); + *bus_width =MIN ((u_int ) tinfo->goal.width, *bus_width); } }
drivers/scsi/aic7xxx/aic79xx_osm.c +1 -1
@@ -1815,7 +1815,7 @@ ahd_linux_handle_scsi_status(struct ahd_if (scb->flags &SCB_SENSE ) { sense_size =MIN (sizeof (struct scsi_sense_data ) -ahd_get_sense_residual (scb), -sizeof (cmd->sense_buffer)); + (u_long )sizeof (cmd->sense_buffer)); sense_offset =0 ; }else {/*
drivers/scsi/aic7xxx/aic7xxx.h +4 -2
@@ -45,6 +45,8 @@#ifndef _AIC7XXX_H_#define _AIC7XXX_H_ +#include <linux/kernel.h> +/* Register Definitions */ #include "aic7xxx_reg.h"
@@ -55,11 +57,11 @@ struct seeprom_descriptor;/****************************** Useful Macros *********************************/ #ifndef MAX -#define MAX (a,b) (((a) > (b)) ? (a) : (b)) +#define MAX (a,b) (max(a,b))#endif #ifndef MIN -#define MIN (a,b) (((a) < (b)) ? (a) : (b)) +#define MIN (a,b) (min(a,b))#endif #ifndef TRUE
drivers/scsi/aic7xxx/aic7xxx_core.c +6 -6
@@ -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, (u_int )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, (u_int ) transinfo->period);return (ahc_find_syncrate (ahc, period, ppr_options, maxsync)); }
@@ -1807,9 +1807,9 @@ ahc_validate_offset(struct ahc_softc *ah *offset =MIN (*offset, maxoffset);if (tinfo !=NULL ) {if (role ==ROLE_TARGET ) - *offset =MIN (*offset, tinfo->user.offset); + *offset =MIN (*offset, (u_int ) tinfo->user.offset);else - *offset =MIN (*offset, tinfo->goal.offset); + *offset =MIN (*offset, (u_int ) 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 ((u_int ) tinfo->user.width, *bus_width);else - *bus_width =MIN (tinfo->goal.width, *bus_width); + *bus_width =MIN ((u_int ) tinfo->goal.width, *bus_width); } }
drivers/scsi/aic7xxx/aic7xxx_osm.c +1 -1
@@ -1877,7 +1877,7 @@ ahc_linux_handle_scsi_status(struct ahc_ sense_size =MIN (sizeof (struct scsi_sense_data ) -ahc_get_sense_residual (scb), -sizeof (cmd->sense_buffer)); + (u_long )sizeof (cmd->sense_buffer));memcpy (cmd->sense_buffer,ahc_get_sense_buf (ahc, scb), sense_size);if (sense_size <sizeof (cmd->sense_buffer))
fs/xfs/xfs_btree.h +10 -24
@@ -18,6 +18,8 @@#ifndef __XFS_BTREE_H__#define __XFS_BTREE_H__ +#include <linux/kernel.h> +struct xfs_buf ;struct xfs_bmap_free ;struct xfs_inode ;
@@ -441,30 +443,14 @@ xfs_btree_setbuf(/* * Min and max functions for extlen, agblock, fileoff, and filblks types. */ -#define XFS_EXTLEN_MIN (a,b) \ - ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \ - (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) -#define XFS_EXTLEN_MAX (a,b) \ - ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \ - (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) -#define XFS_AGBLOCK_MIN (a,b) \ - ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \ - (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) -#define XFS_AGBLOCK_MAX (a,b) \ - ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \ - (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) -#define XFS_FILEOFF_MIN (a,b) \ - ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \ - (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) -#define XFS_FILEOFF_MAX (a,b) \ - ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \ - (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) -#define XFS_FILBLKS_MIN (a,b) \ - ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \ - (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) -#define XFS_FILBLKS_MAX (a,b) \ - ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \ - (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) +#define XFS_EXTLEN_MIN (a,b) (min_t(xfs_extlen_t,a,b)) +#define XFS_EXTLEN_MAX (a,b) (max_t(xfs_extlen_t,a,b)) +#define XFS_AGBLOCK_MIN (a,b) (min_t(xfs_agblock_t,a,b)) +#define XFS_AGBLOCK_MAX (a,b) (max_t(xfs_agblock_t,a,b)) +#define XFS_FILEOFF_MIN (a,b) (min_t(xfs_fileoff_t,a,b)) +#define XFS_FILEOFF_MAX (a,b) (max_t(xfs_fileoff_t,a,b)) +#define XFS_FILBLKS_MIN (a,b) (min_t(xfs_filblks_t,a,b)) +#define XFS_FILBLKS_MAX (a,b) (max_t(xfs_filblks_t,a,b))#define XFS_FSB_SANITY_CHECK (mp,fsb) \ (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
fs/xfs/xfs_rtalloc.c +8 -8
@@ -699,8 +699,8 @@ xfs_rtallocate_extent_size(* this summary level. */ error =xfs_rtallocate_extent_block (mp, tp, i, -XFS_RTMAX (minlen,1 << l), -XFS_RTMIN (maxlen, (1 << (l +1 )) -1 ), +XFS_RTMAX (minlen, (xfs_extlen_t)(1 << l)), +XFS_RTMIN (maxlen, (xfs_extlen_t)(1 << (l +1 )) -1 ), len, &n, rbpp, rsb, prod, &r);if (error) {return error;
@@ -1020,7 +1020,7 @@ xfs_rtcheck_range(/* * Compute first bit not examined. */ - lastbit =XFS_RTMIN (bit + len,XFS_NBWORD ); + lastbit =XFS_RTMIN (bit + len, (xfs_extlen_t )XFS_NBWORD );/* * Mask of relevant bits. */
@@ -1238,7 +1238,7 @@ xfs_rtfind_back(* Calculate first (leftmost) bit number to look at, * and mask for all the relevant bits in this word. */ - firstbit =XFS_RTMAX ((xfs_srtblock_t)(bit - len +1 ),0 ); + firstbit =XFS_RTMAX ((xfs_srtblock_t)(bit - len +1 ), (xfs_srtblock_t )0 ); mask = (((xfs_rtword_t )1 << (bit - firstbit +1 )) -1 ) << firstbit;/*
@@ -1413,7 +1413,7 @@ xfs_rtfind_forw(* Calculate last (rightmost) bit number to look at, * and mask for all the relevant bits in this word. */ - lastbit =XFS_RTMIN (bit + len,XFS_NBWORD ); + lastbit =XFS_RTMIN (bit + len, (xfs_rtblock_t )XFS_NBWORD ); mask = (((xfs_rtword_t )1 << (lastbit - bit)) -1 ) << bit;/* * Calculate the difference between the value there
@@ -1724,7 +1724,7 @@ xfs_rtmodify_range(/* * Compute first bit not changed and mask of relevant bits. */ - lastbit =XFS_RTMIN (bit + len,XFS_NBWORD ); + lastbit =XFS_RTMIN (bit + len, (xfs_extlen_t )XFS_NBWORD ); mask = (((xfs_rtword_t )1 << (lastbit - bit)) -1 ) << bit;/* * Set/clear the active bits.
@@ -2000,8 +2000,8 @@ xfs_growfs_rt( nsbp->sb_rbmblocks = bmbno +1 ; nsbp->sb_rblocks =XFS_RTMIN (nrblocks, - nsbp->sb_rbmblocks *NBBY * - nsbp->sb_blocksize * nsbp->sb_rextsize); + (xfs_drfsbno_t)(nsbp->sb_rbmblocks *NBBY * + nsbp->sb_blocksize * nsbp->sb_rextsize)); nsbp->sb_rextents = nsbp->sb_rblocks;do_div (nsbp->sb_rextents, nsbp->sb_rextsize); nsbp->sb_rextslog =xfs_highbit32 (nsbp->sb_rextents);
fs/xfs/xfs_rtalloc.h +4 -2
@@ -18,6 +18,8 @@#ifndef __XFS_RTALLOC_H__#define __XFS_RTALLOC_H__ +#include <linux/kernel.h> +struct xfs_mount ;struct xfs_trans ;
@@ -57,8 +59,8 @@ struct xfs_trans;#define XFS_BITTOWORD (mp,bi) \ ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp))) -#define XFS_RTMIN (a,b) ((a) < (b) ? (a) : (b)) -#define XFS_RTMAX (a,b) ((a) > (b) ? (a) : (b)) +#define XFS_RTMIN (a,b) (min(a,b)) +#define XFS_RTMAX (a,b) (max(a,b))#define XFS_RTLOBIT (w) xfs_lowbit32(w)#define XFS_RTHIBIT (w) xfs_highbit32(w)
include/linux/utsrelease.h +1 -0
@@ -0,0 +1 @@ +#define UTS_RELEASE "2.6.18-rc5"
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 5 lines · Amol Lad
Cleanups done to use min/max macros from
kernel.h. Handcrafted MIN/MAX macros in some drivers are changed to use macros fromkernel.hTested for allmodconfig and allnoconfig configurations.
Please submit patches inline in the mail, not as attachment. It's a pain to have to download attachment, then cut'n'paste instead of just being able to reply when commenting on a patch.
See http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
drivers/isdn/hardware/eicon/debug.c int diva_get_driver_info (dword id, byte · line 759
Quoted 2 lines
drivers/isdn/hardware/eicon/debug.c +1
-1-if ((to_copy =MIN (strlen (clients[id].drvName), data_length-1 ))) { +if ((to_copy =MIN (strlen (clients[id].drvName), (size_t ) (data_length-1 )))) {
Please don't put spaces after casts - just use "(size_t)(data_length-1)". You do this in several places, I won't point them all out.
drivers/isdn/hardware/eicon/platform.h line 88
Quoted 4 lines
#ifndef MIN
drivers/isdn/hardware/eicon/platform.h +1
-1-#define MIN (a,b) ((a)>(b) ? (b) : (a)) +#define MIN (a,b) (min(a,b))#endif
Why? Why not simply replace all uses of "MIN" with "min"? there's
absolutely no reason to keep "MIN" around just implemented in terms of "min" - just kill it.
drivers/isdn/hardware/eicon/platform.h line 92
Quoted 4 lines
#ifndef MAX
drivers/isdn/hardware/eicon/platform.h +1
-1-#define MAX (a,b) ((a)>(b) ? (a) : (b)) +#define MAX (a,b) (max(a,b))#endif
ditto.
drivers/scsi/aic7xxx/aic79xx.h struct scb_platform_data; · line 64
Quoted 9 lines
#ifndef MAX
drivers/scsi/aic7xxx/aic79xx.h +2
-2-#define MAX (a,b) (((a) > (b)) ? (a) : (b)) +#define MAX (a,b) (max(a,b))#endif #ifndef MIN -#define MIN (a,b) (((a) < (b)) ? (a) : (b)) +#define MIN (a,b) (min(a,b))#endif
ditto.
...
Signature · 7 lines
Jesper Juhl <[email protected]> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html _______________________________________________ Kernel-janitors mailing list [email protected] https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 4 lines · Amol Lad
Cleanups done to use min/max macros from
kernel.h. Handcrafted MIN/MAX macros in some drivers are changed to use macros fromkernel.h+ clength =
MIN((word)(270-length),(word) (X[i].PLength-this->XOffset));
What is the rationale behind all those type casts?
Should we now also write:
if(uint > (unsigned int)300) {
instead of
if(uint > 300) {Can someone explain this?
- rme
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
include/linux/kernel.h:
#define min(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x = &_y); \
_x < _y ? _x : _y; })The casts are required as these macros do very strict type checking (see &_x = &_y compare at line 4).
Compiler throws up a warning if min/max are passed arguments of different types..
Quoted 8 lines · Henk Vergonet
Quoted 4 lines · Amol Lad
Cleanups done to use min/max macros from
kernel.h. Handcrafted MIN/MAX macros in some drivers are changed to use macros fromkernel.h+ clength =
MIN((word)(270-length),(word) (X[i].PLength-this->XOffset));What is the rationale behind all those type casts?
Quoted 8 lines
Should we now also write:
if(uint > (unsigned int)300) { instead of if(uint > 300) {Can someone explain this?
- rme
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
On Fri, 2006-09-08 at 09:49 +0200, Henk Vergonet wrote:
[...]
Quoted 6 lines
Should we now also write:
if(uint > (unsigned int)300) { instead of if(uint > 300) {Can someone explain this?
The "int" constant 300 can be silently promoted to an "unsigned int". If you want an "unsigned int" constant, use "300U".
Bernd
Signature · 8 lines
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitorsIncorporated Jesper's comments.
Cleanups done to use min/max macros from kernel.h. Handcrafted MIN/MAX macros are changed to use macros in kernel.h
Tested for allmodconfig
--- drivers/isdn/hardware/eicon/debug.c | 4 +- drivers/isdn/hardware/eicon/di.c | 8 ++--- drivers/isdn/hardware/eicon/io.c | 2 - drivers/isdn/hardware/eicon/istream.c | 4 +- drivers/isdn/hardware/eicon/platform.h | 8 ----- drivers/scsi/aic7xxx/aic79xx.h | 8 ----- drivers/scsi/aic7xxx/aic79xx_core.c | 22 +++++++------- drivers/scsi/aic7xxx/aic79xx_osm.c | 6 ++-- drivers/scsi/aic7xxx/aic7xxx.h | 8 ----- drivers/scsi/aic7xxx/aic7xxx_core.c | 18 ++++++------ drivers/scsi/aic7xxx/aic7xxx_osm.c | 4 +- fs/xfs/xfs_btree.h | 34 ++++++----------------- fs/xfs/xfs_rtalloc.c | 20 ++++++------- fs/xfs/xfs_rtalloc.h | 3 -- include/linux/utsrelease.h | 1 15 files changed, 55 insertions(+), 95 deletions(-)
---
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), (size_t )(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), (size_t )(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 @@ void pr_out(ADAPTER * a) 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),(word)(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 @@ byte isdn_ind(ADAPTER * a,sizeof (a->stream_buffer), &final, NULL, NULL); } - IoAdapter->RBuffer.length =MIN (MLength,270 ); + IoAdapter->RBuffer.length =min (MLength, (word )270 );if (IoAdapter->RBuffer.length != MLength) { this->complete =0 ; }else {
@@ -676,9 +676,9 @@ byte isdn_ind(ADAPTER * a, this->RCurrent++; }if (cma) { - clength =MIN (MLength,R [this->RCurrent].PLength-this->ROffset); + clength =min (MLength, (word)(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 @@ void request(PISDN_ADAPTER IoAdapter, ENcase 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 @@ int diva_istream_write (void* context,return (-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 @@ int diva_istream_read (void* context,return (-1 );/* was not able to read */ break ; } - to_read =MIN (max_length, tmp[1 ]); + to_read =min (max_length, (int )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 @@#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/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, (u_int )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, (u_int )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, (u_int )tinfo->user.offset);else - *offset =MIN (*offset, tinfo->goal.offset); + *offset =min (*offset, (u_int )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 ((u_int )tinfo->user.width, *bus_width);else - *bus_width =MIN (tinfo->goal.width, *bus_width); + *bus_width =min ((u_int )tinfo->goal.width, *bus_width); } }
@@ -6057,9 +6057,9 @@ ahd_alloc_scbs(struct ahd_softc *ahd)#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 +3 -3
@@ -1813,9 +1813,9 @@ 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)); + (u_long )sizeof (cmd->sense_buffer)); sense_offset =0 ; }else {/*
@@ -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, (u_int )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, (u_int )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, (u_int )tinfo->user.offset);else - *offset =MIN (*offset, tinfo->goal.offset); + *offset =min (*offset, (u_int )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 ((u_int )tinfo->user.width, *bus_width);else - *bus_width =MIN (tinfo->goal.width, *bus_width); + *bus_width =min ((u_int )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 +2 -2
@@ -1875,9 +1875,9 @@ 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)); + (u_long )sizeof (cmd->sense_buffer));memcpy (cmd->sense_buffer,ahc_get_sense_buf (ahc, scb), sense_size);if (sense_size <sizeof (cmd->sense_buffer))
fs/xfs/xfs_btree.h +10 -24
@@ -18,6 +18,8 @@#ifndef __XFS_BTREE_H__#define __XFS_BTREE_H__ +#include <linux/kernel.h> +struct xfs_buf ;struct xfs_bmap_free ;struct xfs_inode ;
@@ -441,30 +443,14 @@ xfs_btree_setbuf(/* * Min and max functions for extlen, agblock, fileoff, and filblks types. */ -#define XFS_EXTLEN_MIN (a,b) \ - ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \ - (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) -#define XFS_EXTLEN_MAX (a,b) \ - ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \ - (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) -#define XFS_AGBLOCK_MIN (a,b) \ - ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \ - (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) -#define XFS_AGBLOCK_MAX (a,b) \ - ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \ - (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) -#define XFS_FILEOFF_MIN (a,b) \ - ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \ - (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) -#define XFS_FILEOFF_MAX (a,b) \ - ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \ - (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) -#define XFS_FILBLKS_MIN (a,b) \ - ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \ - (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) -#define XFS_FILBLKS_MAX (a,b) \ - ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \ - (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) +#define XFS_EXTLEN_MIN (a,b) (min_t(xfs_extlen_t,a,b)) +#define XFS_EXTLEN_MAX (a,b) (max_t(xfs_extlen_t,a,b)) +#define XFS_AGBLOCK_MIN (a,b) (min_t(xfs_agblock_t,a,b)) +#define XFS_AGBLOCK_MAX (a,b) (max_t(xfs_agblock_t,a,b)) +#define XFS_FILEOFF_MIN (a,b) (min_t(xfs_fileoff_t,a,b)) +#define XFS_FILEOFF_MAX (a,b) (max_t(xfs_fileoff_t,a,b)) +#define XFS_FILBLKS_MIN (a,b) (min_t(xfs_filblks_t,a,b)) +#define XFS_FILBLKS_MAX (a,b) (max_t(xfs_filblks_t,a,b))#define XFS_FSB_SANITY_CHECK (mp,fsb) \ (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
fs/xfs/xfs_rtalloc.c +10 -9
@@ -699,8 +699,8 @@ xfs_rtallocate_extent_size(* this summary level. */ error =xfs_rtallocate_extent_block (mp, tp, i, -XFS_RTMAX (minlen,1 << l), -XFS_RTMIN (maxlen, (1 << (l +1 )) -1 ), +max (minlen, (xfs_extlen_t)(1 << l)), +min (maxlen, (xfs_extlen_t)((1 << (l +1 )) -1 )), len, &n, rbpp, rsb, prod, &r);if (error) {return error;
@@ -1020,7 +1020,7 @@ xfs_rtcheck_range(/* * Compute first bit not examined. */ - lastbit =XFS_RTMIN (bit + len,XFS_NBWORD ); + lastbit =min (bit + len, (xfs_extlen_t )XFS_NBWORD );/* * Mask of relevant bits. */
@@ -1238,7 +1238,7 @@ xfs_rtfind_back(* Calculate first (leftmost) bit number to look at, * and mask for all the relevant bits in this word. */ - firstbit =XFS_RTMAX ((xfs_srtblock_t)(bit - len +1 ),0 ); + firstbit =max ((xfs_srtblock_t)(bit - len +1 ), (xfs_srtblock_t )0 ); mask = (((xfs_rtword_t )1 << (bit - firstbit +1 )) -1 ) << firstbit;/*
@@ -1413,7 +1413,7 @@ xfs_rtfind_forw(* Calculate last (rightmost) bit number to look at, * and mask for all the relevant bits in this word. */ - lastbit =XFS_RTMIN (bit + len,XFS_NBWORD ); + lastbit =min (bit + len, (xfs_rtblock_t )XFS_NBWORD ); mask = (((xfs_rtword_t )1 << (lastbit - bit)) -1 ) << bit;/* * Calculate the difference between the value there
@@ -1724,7 +1724,7 @@ xfs_rtmodify_range(/* * Compute first bit not changed and mask of relevant bits. */ - lastbit =XFS_RTMIN (bit + len,XFS_NBWORD ); + lastbit =min (bit + len, (xfs_extlen_t )XFS_NBWORD ); mask = (((xfs_rtword_t )1 << (lastbit - bit)) -1 ) << bit;/* * Set/clear the active bits.
@@ -1999,9 +1999,9 @@ xfs_growfs_rt( nsbp->sb_rextsize = in->extsize; nsbp->sb_rbmblocks = bmbno +1 ; nsbp->sb_rblocks -XFS_RTMIN (nrblocks, - nsbp->sb_rbmblocks *NBBY * - nsbp->sb_blocksize * nsbp->sb_rextsize); +min (nrblocks, + (xfs_drfsbno_t)(nsbp->sb_rbmblocks *NBBY * + nsbp->sb_blocksize * nsbp->sb_rextsize)); nsbp->sb_rextents = nsbp->sb_rblocks;do_div (nsbp->sb_rextents, nsbp->sb_rextsize); nsbp->sb_rextslog =xfs_highbit32 (nsbp->sb_rextents);
@@ -2430,7 +2430,7 @@ xfs_rtprint_summary(if (c) {if (!p) {cmn_err (CE_DEBUG ,"%Ld-%Ld:" ,1LL << l, -XFS_RTMIN ((1LL << l) + +min ((1LL << l) + ((1LL << l) -1LL ), mp->m_sb.sb_rextents)); p =1 ;
fs/xfs/xfs_rtalloc.h +0 -3
@@ -57,9 +57,6 @@ struct xfs_trans;#define XFS_BITTOWORD (mp,bi) \ ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp))) -#define XFS_RTMIN (a,b) ((a) < (b) ? (a) : (b)) -#define XFS_RTMAX (a,b) ((a) > (b) ? (a) : (b)) -#define XFS_RTLOBIT (w) xfs_lowbit32(w)#define XFS_RTHIBIT (w) xfs_highbit32(w)
include/linux/utsrelease.h +1 -0
@@ -0,0 +1 @@ +#define UTS_RELEASE "2.6.18-rc5"
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 7 lines · Henk Vergonet
Quoted 4 lines · Amol Lad
Cleanups done to use min/max macros from
kernel.h. Handcrafted MIN/MAX macros in some drivers are changed to use macros fromkernel.h+ clength =
MIN((word)(270-length),(word) (X[i].PLength-this->XOffset));What is the rationale behind all those type casts?
The rationale is to shut up warning so potential integer overflow won't disturb developer's sleep.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors