bin/90130: [patch] sysctl(8): print temperature in celsius only when -h is specified

Marius Nuennerich marius.nuennerich at gmx.net
Thu Dec 8 16:50:04 PST 2005


>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:


More information about the freebsd-bugs mailing list