Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Dec 2005 01:42:09 +0100
From:      "Marius  Nuennerich" <marius.nuennerich@gmx.net>
To:        "FreeBSD gnats submit" <FreeBSD-gnats-submit@FreeBSD.org>
Cc:        marius.nuennerich@gmx.net
Subject:   bin/90130: [patch] sysctl(8): print temperature in celsius only when -h is specified
Message-ID:  <1134088929.0@sol.hackerzberg.local>
Resent-Message-ID: <200512090050.jB90o35g023120@freefall.freebsd.org>

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

>Number:         90130
>Category:       bin
>Synopsis:       [patch] sysctl(8): print temperature in celsius only when -h is specified
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 09 00:50:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Marius  Nuennerich
>Release:        FreeBSD 7-CURRENT
>Organization:
>Environment:





>Description:


By defaul sysctl(8) prints values in human-readable format only 
if -h is specified and machine-readable format otherwise.
IMO this should be true for temperature values also.


>How-To-Repeat:





>Fix:


--- sysctl.diff begins here ---
diff -ru current-20051202/sbin/sysctl/sysctl.c current/sbin/sysctl/sysctl.c
--- current-20051202/sbin/sysctl/sysctl.c	Fri Dec  2 21:52:57 2005
+++ current/sbin/sysctl/sysctl.c	Tue Dec  6 14:52:18 2005
@@ -580,7 +580,7 @@
 			if(*fmt == 'U')
 				printf(hflag ? "%'u" : "%u", *(unsigned int *)p);
 			else if (*fmt == 'K') {
-				if (*(int *)p < 0)
+				if ((*(int *)p < 0) || !hflag)
 					printf("%d", *(int *)p);
 				else
 					printf("%d.%dC", (*(int *)p - 2732) / 10, (*(int *)p - 2732) % 10);
@@ -602,7 +602,7 @@
 			if(*fmt == 'U')
 				printf(hflag ? "%'lu" : "%lu", *(unsigned long *)p);
 			else if (*fmt == 'K') {
-				if (*(long *)p < 0)
+				if ((*(long *)p < 0) || !hflag)
 					printf("%ld", *(long *)p);
 				else
 					printf("%ld.%ldC", (*(long *)p - 2732) / 10, (*(long *)p - 2732) % 10);
--- sysctl.diff ends here ---



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



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