Bug 116413 - incorrect getconf(1) handling of unsigned constants gives -1 for ULLONG_MAX
Summary: incorrect getconf(1) handling of unsigned constants gives -1 for ULLONG_MAX
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 6.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-17 08:40 UTC by Ighighi
Modified: 2017-12-31 22:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ighighi 2007-09-17 08:40:01 UTC
The code /usr/src/usr.bin/getconf/limits.gperf doesn't correctly handle
unsigned constants.  Since it uses an intmax_t for all included variables,
any value larger than INTMAX_MAX is printed incorrectly.  So, on my machine
it prints -1 for ULLONG_MAX when it should print:

18446744073709551615 (defined in <machine/_limits.h> to be 0xffffffffffffffffULL)
if the desktop calculator isn't fooling me

Fix: 

I could submit a patch if there's a minimal guarantee that I won't lose
my time...
How-To-Repeat: getconf ULLONG_MAX
Comment 1 Garrett Wollman 2007-09-17 17:45:14 UTC
In article <mit.lcs.mail.freebsd-bugs/200709170733.l8H7XRmS067276@www.freebsd.org> you write:

>The code /usr/src/usr.bin/getconf/limits.gperf doesn't correctly handle
>unsigned constants.

It is not clear to me that the POSIX specification allows it to
"correctly handle unsigned constants".

XCU6 page 516 lines 18634ff:

	Otherwise, if the specified variable is defined on the system, its
	value shall be written in the following format:

	"%d\n", <value>

The description of "%d\n" in XBD6 chapter 5 ("File Format Notation")
clearly requires it to output <value> as a signed integer.  This fits
with the definition of the sysconf() function as returning a signed
long.

Having said that, supporting these non-sysconf() limits such as these
is a FreeBSD extension and we need not be bound by POSIX when (and
only when) querying non-POSIX values.

-GAWollman

-- 
Garrett A. Wollman   | The real tragedy of human existence is not that we are
wollman@csail.mit.edu| nasty by nature, but that a cruel structural asymmetry
Opinions not those   | grants to rare events of meanness such power to shape
of MIT or CSAIL.     | our history. - S.J. Gould, Ten Thousand Acts of Kindness
Comment 2 Robert Watson freebsd_committer freebsd_triage 2008-03-09 13:08:39 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-standards

Over to the standards folks as they may want to opine on the issue Garrett 
raised with this change request.
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:33 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped