Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: kern_physio: Use MIN() to limit b_bcount
To:
Mark Kettenis <mark.kettenis@xs4all.nl>
Cc:
Thorsten Blum <thorsten.blum@toblux.com>, tech@openbsd.org
Date:
Wed, 15 Oct 2025 13:04:34 +0200

Download raw body.

Thread
On Wed, Oct 15, 2025 at 12:44:53PM +0200, Mark Kettenis wrote:
> > From: Thorsten Blum <thorsten.blum@toblux.com>
> > Date: Wed, 15 Oct 2025 11:55:00 +0200
> 
> Sorry, but these arbitrary code changes are not very useful.  They
> just create churn that makes looking at the code history harder.

Agreed, plus on top MIN() is a special snowflake that should not be used.
The macro is not clean, it does multiple evaluations and if you mix types
you can get unexpected results.
 
> > Index: kern/kern_physio.c
> > ===================================================================
> > RCS file: /cvs/src/sys/kern/kern_physio.c,v
> > retrieving revision 1.49
> > diff -u -p -r1.49 kern_physio.c
> > --- kern/kern_physio.c	3 Feb 2024 18:51:58 -0000	1.49
> > +++ kern/kern_physio.c	15 Oct 2025 00:10:04 -0000
> > @@ -115,10 +115,7 @@ physio(void (*strategy)(struct buf *), d
> >  			 * limit b_bcount to LONG_MAX before calling the
> >  			 * provided minphys.
> >  			 */
> > -			if (iovp->iov_len > LONG_MAX)
> > -				bp->b_bcount = LONG_MAX;
> > -			else
> > -				bp->b_bcount = iovp->iov_len;
> > +			bp->b_bcount = MIN(iovp->iov_len, LONG_MAX);
> >  
> >  			/*
> >  			 * [call minphys to bound the transfer size]
> > 
> > 
> 

-- 
:wq Claudio