NetBSD Problem Report #24522

Received: (qmail 20710 invoked by uid 605); 22 Feb 2004 07:34:00 -0000
Message-Id: <200402220734.i1M7Y5MY025952@neptune.terran>
Date: Sat, 21 Feb 2004 23:34:06 -0800 (PST)
From: bp007@terran.org
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: bp007@terran.org (bryan007@terran.org)
To: gnats-bugs@gnats.NetBSD.org
Subject: fix for -i option to envstat in -current
X-Send-Pr-Version: 3.95

>Number:         24522
>Category:       bin
>Synopsis:       fix for -i option to envstat in -current
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mrg
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 22 07:35:00 +0000 2004
>Closed-Date:    Thu Mar 25 01:27:12 +0000 2004
>Last-Modified:  Thu Mar 25 01:28:00 +0000 2004
>Originator:     Bryan J. Phillippe
>Release:        NetBSD 1.6ZH
>Organization:
>Environment:


System: NetBSD neptune 1.6ZH NetBSD 1.6ZH (Neptune 20031230) #22: Fri Jan 23 11:18:55 PST 2004 bryan@neptune:/usr/home/bryan/etc/src/NetBSD/current/src/sys/arch/i386/compile/neptune i386
Architecture: i386
Machine: i386
>Description:
	The -i option, for controlling loop interval display, does not
	operate when the -r option, for displaying row-format output,
	is also specified.  There is no reason for this.
>How-To-Repeat:
	envstat -ri 2 # will display output only once
>Fix:
	The patch included below is one possible solution.  Also included
	in the patch are some whitespace corrections for style
	conformance (spaces to tabs).

Index: envstat.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/envstat/envstat.c,v
retrieving revision 1.17
diff -u -r1.17 envstat.c
--- envstat.c	2 Feb 2004 10:36:19 -0000	1.17
+++ envstat.c	22 Feb 2004 07:19:10 -0000
@@ -162,12 +162,13 @@
 	if (rflag) {
 		int i;

+rflag_loop:
 		for (i = 0 ; i < ns ; i++) {
 			if ((etds[i].validflags & ENVSYS_FCURVALID) == 0)
 				continue;

 			if (ebis[i].units == ENVSYS_INDICATOR &&
-			    etds[i].cur.data_s == 0)
+				etds[i].cur.data_s == 0)
 				continue;

 			printf("%*.*s", (int)width, (int)width, ebis[i].desc);
@@ -180,8 +181,8 @@
 				printf(": %10d", etds[i].cur.data_s);
 				break;
 			case ENVSYS_STEMP: {
-			     	double temp = (etds[i].cur.data_s / 1000000.0)
-				    - 273.15;
+				double temp = (etds[i].cur.data_s / 1000000.0)
+					- 273.15;
 				if (celsius)
 					printf(": %10.3f degC", temp);
 				else {
@@ -195,19 +196,25 @@
 				break;
 			default:
 				printf(": %10.3f %s",
-				    etds[i].cur.data_s / 1000000.0,
-				    envsysunitnames[ebis[i].units]);
+					etds[i].cur.data_s / 1000000.0,
+					envsysunitnames[ebis[i].units]);
 				break;
 			}

 			if (etds[i].validflags & ENVSYS_FFRACVALID) {
 				printf(" (%5.2f%%)",
-				    (etds[i].cur.data_s * 100.0) /
-				    etds[i].max.data_s);
+					(etds[i].cur.data_s * 100.0) /
+					etds[i].max.data_s);
 			}

 			printf("\n");
 		}
+		if (interval) {
+			sleep(interval);
+			fillsensors(fd, etds, ebis, ns);
+			printf("\n");
+			goto rflag_loop;
+		}
 		exit(0);
 	}

@@ -226,7 +233,7 @@
 	if (headrep)
 		header(width, celsius, ebis, cetds, ns);

-        for (;;) {
+	for (;;) {
 		values(width, celsius, etds, cetds, ns);
 		if (headrep && (++headcnt == headrep)) {
 			headcnt = 0;
@@ -264,8 +271,7 @@
 	/* units */
 	for (i = 0; i < ns; ++i)
 		if (cetds[i]) {
-			if ((ebis[i].units == ENVSYS_STEMP) &&
-			    !celsius)
+			if ((ebis[i].units == ENVSYS_STEMP) && !celsius)
 				s = "degF";
 			else if (ebis[i].units >= ENVSYS_NSENSORS)
 				s = envsysunitnames[ENVSYS_NSENSORS];
@@ -296,11 +302,11 @@
 			switch(etds[i].units) {
 			case ENVSYS_INDICATOR:
 				printf(" %*.*s", (int)width, (int)width,
-				    etds[i].cur.data_us ? "ON" : "OFF");
+					etds[i].cur.data_us ? "ON" : "OFF");
 				break;
 			case ENVSYS_STEMP:
 				temp = (etds[i].cur.data_us / 1000000.0) -
-				    273.15;
+					273.15;
 				if (!celsius)
 					temp = (9.0 / 5.0) * temp + 32.0;
 				printf(" %*.2f", (int)width, temp);
@@ -309,8 +315,8 @@
 				printf(" %*u", (int)width, etds[i].cur.data_us);
 				break;
 			default:
-				printf(" %*.2f", (int)width, etds[i].cur.data_s /
-				       1000000.0);
+				printf(" %*.2f", (int)width,
+						etds[i].cur.data_s / 1000000.0);
 				break;
 			}
 		}
>Release-Note:
>Audit-Trail:

From: matthew green <mrg@eterna.com.au>
To: bryan007@terran.org
Cc: gnats-bugs@gnats.NetBSD.org
Subject: re: bin/24522: fix for -i option to envstat in -current 
Date: Sun, 22 Feb 2004 18:37:57 +1100

 thanks..


 note that a significant portion of this patch includes whitespace
 "fixes" that are in fact against the style guide.  there does appear
 to be one valid one, plus the real bug fix as well...


 .mrg.

Responsible-Changed-From-To: bin-bug-people->mrg 
Responsible-Changed-By: fair 
Responsible-Changed-When: Wed Mar 24 21:34:52 UTC 2004 
Responsible-Changed-Why:  

Matthew, can you apply a corrected patch and resolve this PR? 
State-Changed-From-To: open->closed 
State-Changed-By: mrg 
State-Changed-When: Thu Mar 25 01:25:19 UTC 2004 
State-Changed-Why:  
i've applied a different change that has the same effect. 

thanks. 

From: matthew green <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/24522 CVS commit: src/usr.sbin/envstat
Date: Thu, 25 Mar 2004 01:26:57 +0000 (UTC)

 Module Name:	src
 Committed By:	mrg
 Date:		Thu Mar 25 01:26:57 UTC 2004

 Modified Files:
 	src/usr.sbin/envstat: envstat.c

 Log Message:
 - move the row printing code into it's own function.
 - pay attention to interval processing with row printing (-r -iN).

 the latter fixes PR#24522.


 To generate a diff of this commit:
 cvs rdiff -r1.18 -r1.19 src/usr.sbin/envstat/envstat.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.