Subject: bin/20316: systat interrupt counters
To: None <gnats-bugs@gnats.netbsd.org>
From: None <root@Krille.Update.UU.SE>
List: netbsd-bugs
Date: 02/12/2003 16:47:27
>Number:         20316
>Category:       bin
>Synopsis:       systat interrupt counter name truncation bad
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 12 07:48:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Johnny Billquist
>Release:        NetBSD 1.6N
>Organization:
Update
>Environment:
System: NetBSD Krille.Update.UU.SE 1.6N NetBSD 1.6N (Krille) #51: Thu Feb 6 20:02:21 CET 2003 root@Krille.Update.UU.SE:/sys/arch/vax/compile/Krille vax
Architecture: vax
Machine: vax
>Description:
systat have recently had the "new" interrupt counters added.
However, when displaying the names of these counters, systat prefers
displaying the counter name to the counter group name.
This is wrong, I believe.
The counter name is group specific, and is not guaranteed to be unique.
By prefering to show this string if both strings don't fit, you get a list
that is difficult to decipher.
In addition systat also truncates group and name if they don't fit, which
removed important information.
The group name is usually the device name, as told during autoconf. The last
letter is usually a number for the device, which is the first thing dropped
by systat in this case. The name of the event counter is often just "intr"
(atleast on VAXen), which means you just get a lists with "intr".
>How-To-Repeat:
Run systat vmstat, and look at the interrupt counter list.
>Fix:
Index: vmstat.c
===================================================================
RCS file: /cvsroot/src/usr.bin/systat/vmstat.c,v
retrieving revision 1.46
diff -r1.46 vmstat.c
290,303c290,296
< 	group_width = strlen(ie_head[i].ie_group);
< 	name_width = strlen(ie_head[i].ie_name);
< 	width -= group_width + 1 + name_width;
< 	if (width < 0) {
< 		/* screen to narrow for full strings */
< 		width = -width;
< 		group_width -= (width + 1) / 2;
< 		name_width -= width / 2;
< 		if (group_width <= 3 || name_width < 0) {
< 			/* don't display group */
< 			name_width += group_width + 1;
< 			group_width = 0;
< 		}
< 	}
---
> 
> #define min(a,b) ((a)<(b) ? (a) : (b))
> 
> 	group_width = min(strlen(ie_head[i].ie_group), width);
> 	width -= group_width + 1;
> 	if (width == -1) width = 0;
> 	name_width = min(strlen(ie_head[i].ie_name), width);
307c300,301
< 	printw("%-.*s", name_width, ie_head[i].ie_name);
---
> 	if (name_width)
> 		printw("%-.*s", name_width, ie_head[i].ie_name);

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