Subject: kern/13687: socketvar.h / sbspace macro uses imin() instead of lmin()
To: None <gnats-bugs@gnats.netbsd.org>
From: None <sb125499@oak.cats.ohiou.edu>
List: netbsd-bugs
Date: 08/11/2001 16:05:26
>Number:         13687
>Category:       kern
>Synopsis:       socketvar.h / sbspace macro uses imin() instead of lmin()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 11 16:02:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Scott Barron
>Release:        1.5.1
>Organization:
>Environment:
NetBSD unixbrewers.org 1.5.1 NetBSD 1.5.1 (GENERIC) #56: Mon Jul  2 15:54:23 CEST 2001     he@nsa.uninett.no:/usr/src/sys/arch/i386/compile/GENERIC i386

>Description:
The sbspace macro in sys/socketvar.h uses imin() and casts unsigned
long variables to int.  The comment above it states that it should 
use lmin() but it doesn't exist.  lmin() is available in libkern so it 
should probably be used instead of imin().
>How-To-Repeat:
Look at /sys/sys/socketvar.h

>Fix:
A patch against -current from cvs on 8/11/01

Index: socketvar.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/socketvar.h,v
retrieving revision 1.49
diff -r1.49 socketvar.h
161,163d160
<  * This is problematical if the fields are unsigned, as the space might
<  * still be negative (cc > hiwat or mbcnt > mbmax).  Should detect
<  * overflow and return 0.  Should use "lmin" but it doesn't exist now.
166,167c163,164
<       ((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \
<        (int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
---
>       (lmin(((sb)->sb_hiwat - (sb)->sb_cc), \
>             ((sb)->sb_mbmax - (sb)->sb_mbcnt)))


>Release-Note:
>Audit-Trail:
>Unformatted: