Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Jan 2012 08:45:02 GMT
From:      Marcus Reid <marcus@blazingdot.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   standards/164049: getconf returns bad value for ULLONG_MAX
Message-ID:  <201201120845.q0C8j27e017516@red.freebsd.org>
Resent-Message-ID: <201201120850.q0C8oAG9018549@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         164049
>Category:       standards
>Synopsis:       getconf returns bad value for ULLONG_MAX
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 12 08:50:10 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Marcus Reid
>Release:        9-STABLE
>Organization:
>Environment:
FreeBSD seabug.megapath.biz 9.0-STABLE FreeBSD 9.0-STABLE #0: Mon Jan  9 10:53:27 PST 2012     root@seabug.megapath.biz:/usr/obj/usr/src/sys/FARK  amd64

>Description:
getconf outputs -1 for ULLONG_MAX (and ULONG_MAX on amd64), which seems strange.  Another implementation that I checked outputs 18446744073709551615 like it should.
>How-To-Repeat:
getconf ULLONG_MAX
>Fix:
Patch attached.  It creates a couple of compiler warnings but fixes the problem, maybe there is a better way to do it.

Patch attached with submission follows:

--- usr.bin/getconf/getconf.c.orig	2011-09-27 01:42:06.444544408 -0700
+++ usr.bin/getconf/getconf.c	2012-01-12 00:15:50.000000000 -0800
@@ -98,7 +98,10 @@
 	if (argv[optind + 1] == NULL) { /* confstr or sysconf */
 		if ((valid = find_limit(name, &limitval)) != 0) {
 			if (valid > 0)
-				printf("%" PRIdMAX "\n", limitval);
+				if((long long)limitval == -1)
+					printf("%llu\n", limitval);
+				else
+					printf("%lld\n", limitval);
 			else
 				printf("undefined\n");
 
--- usr.bin/getconf/getconf.h.orig	2011-09-27 01:42:06.444544408 -0700
+++ usr.bin/getconf/getconf.h	2012-01-12 00:15:51.000000000 -0800
@@ -31,7 +31,6 @@
 
 #ifdef STABLE
 typedef long long intmax_t;
-#define	PRIdMAX	"lld"
 #else
 #include <inttypes.h>
 #endif


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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201120845.q0C8j27e017516>