Subject: kern/13687: socketvar.h / sbspace macro uses imin() instead of lmin()
To: None <>
From: None <>
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
>Originator:     Scott Barron
>Release:        1.5.1
NetBSD 1.5.1 NetBSD 1.5.1 (GENERIC) #56: Mon Jul  2 15:54:23 CEST 2001 i386

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().
Look at /sys/sys/socketvar.h

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
<  * 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.
<       ((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)))