From tedm@atlas.ipinc.net  Wed Oct  8 22:43:23 2003
Return-Path: <tedm@atlas.ipinc.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id BCD1E16A4B3
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  8 Oct 2003 22:43:23 -0700 (PDT)
Received: from atlas.ipinc.net (atlas.ipinc.net [205.139.120.59])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1AC9943F75
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  8 Oct 2003 22:43:23 -0700 (PDT)
	(envelope-from tedm@atlas.ipinc.net)
Received: from atlas.ipinc.net (localhost.ipinc.net [127.0.0.1])
	by atlas.ipinc.net (8.12.8p1/8.12.8) with ESMTP id h995hM0D025350
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 8 Oct 2003 22:43:22 -0700 (PDT)
	(envelope-from tedm@atlas.ipinc.net)
Received: (from tedm@localhost)
	by atlas.ipinc.net (8.12.8p1/8.12.8/Submit) id h995hMPa025349;
	Wed, 8 Oct 2003 22:43:22 -0700 (PDT)
Message-Id: <200310090543.h995hMPa025349@atlas.ipinc.net>
Date: Wed, 8 Oct 2003 22:43:22 -0700 (PDT)
From: Ted Mittelstaedt <tedm@ipinc.net>
Reply-To: Ted Mittelstaedt <tedm@ipinc.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: UINT32_MAX is missing from FreeBSD 4.X
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         57783
>Category:       i386
>Synopsis:       UINT32_MAX is missing from FreeBSD 4.X
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-i386
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 08 22:50:19 PDT 2003
>Closed-Date:    Sun Aug 22 09:49:57 GMT 2004
>Last-Modified:  Sun Aug 22 09:49:57 GMT 2004
>Originator:     Ted Mittelstaedt
>Release:        FreeBSD 4.8-RELEASE i386
>Organization:
Internet Partners Inc.
>Environment:
System: FreeBSD atlas.ipinc.net 4.8-RELEASE FreeBSD 4.8-RELEASE #1: Sun Oct 5 01:40:14 PDT 2003 tedm@atlas.ipinc.net:/usr/src/sys/compile/ATLASKER i386


	
>Description:

A definition of UINT32_MAX is missing from /usr/include/machine/limits.h

This is an obvious oversight as the manpage for arc4random() shows it
returning u_int32_t

I found a note on Usenet to the effect that this was (may have been?)
fixed in FreeBSD 5?
	
>How-To-Repeat:
	
>Fix:

I think that adding

#define UINT32_MAX      0xffffffffU     /* max value for an unsigned int */

to limits.h will fix this.

Note also that /usr/src/usr.bin/jot/jot.c uses the UINT32_MAX on line
number 280, but someone has replaced this with the actual constant.
(If jot.c is ever updated this may be a problem again)

	


>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: Ted Mittelstaedt <tedm@ipinc.net>
Cc: FreeBSD-gnats-submit@freebsd.org, freebsd-i386@freebsd.org
Subject: Re: i386/57783: UINT32_MAX is missing from FreeBSD 4.X
Date: Thu, 9 Oct 2003 18:13:13 +1000 (EST)

 On Wed, 8 Oct 2003, Ted Mittelstaedt wrote:
 
 > >Description:
 >
 > A definition of UINT32_MAX is missing from /usr/include/machine/limits.h
 
 UINT32_MAX is part of C99, and most of C99 including this part is not
 supported in RELENG_4.
 
 > This is an obvious oversight as the manpage for arc4random() shows it
 > returning u_int32_t
 
 u_int32_t is not part of C99.  It is the same as uint32_t if C99 is
 supported and uint32_t is supported.  There are no U_FOOn_MAX macros
 corresponding to the u_fooN_t types, and such macros are mostly not
 needed since the maximums are easily calculated.  (C99 needs them more
 because the maximums are not so easily calculated for implementation-defined
 types larger than long.)
 
 > I found a note on Usenet to the effect that this was (may have been?)
 > fixed in FreeBSD 5?
 
 Sort of.  More parts of C99 including limits for fixed-width types are
 supported, but arc4random() is still documented to return u_int32_t so
 using UINT32_MAX with it is still an anachronism.
 
 > >How-To-Repeat:
 >
 > >Fix:
 >
 > I think that adding
 >
 > #define UINT32_MAX      0xffffffffU     /* max value for an unsigned int */
 >
 > to limits.h will fix this.
 
 This would add some bugs:
 - namespace pollution.  <limits.h> is not permitted to define UINT32_MAX.
   In C99, UINT32_MAX is only defined in <stdint.h> (and inttypes.h>).
 - the cloned comment is wrong in this context.
 - the U suffix is not quite right in this context.  It is correct but
   redundant for UINT_MAX on 32-bit machines.  I think it is wrong on
   machines with UINT32_MAX < INT_MAX.  In current, all UFOO_MAX's are
   defined in MD files so that we don't have to worry about the delicate
   considerations needed to define them in an MI way using something
   like the above.
 
 > Note also that /usr/src/usr.bin/jot/jot.c uses the UINT32_MAX on line
 > number 280, but someone has replaced this with the actual constant.
 
 This is the correct fix in -current too.  It avoids the anachronism.
 
 > (If jot.c is ever updated this may be a problem again)
 
 Not unless arc4random()'s interface is changed to return.  32 won't change,
 and hard-coding it in the name "UINT32_MAX" is little different from
 hard-coding it in "0xffffffff".
 
 Bruce
State-Changed-From-To: open->closed 
State-Changed-By: tjr 
State-Changed-When: Sun Aug 22 09:48:42 GMT 2004 
State-Changed-Why:  
There are no plans to merge this, or any other C99 conformance fixes back 
into RELENG_4. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=57783 
>Unformatted:
