NetBSD Problem Report #47232
From msaitoh@execsw.org Wed Nov 21 17:34:27 2012
Return-Path: <msaitoh@execsw.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id 195F063DCB2
for <gnats-bugs@gnats.NetBSD.org>; Wed, 21 Nov 2012 17:34:27 +0000 (UTC)
Message-Id: <20121121173423.B300E43985B@vslock.execsw.org>
Date: Thu, 22 Nov 2012 02:34:23 +0900 (JST)
From: msaitoh@execsw.org
Reply-To: msaitoh@execsw.org
To: gnats-bugs@gnats.NetBSD.org
Subject: Trailing whilte space(s) of rnd source is hard to know
X-Send-Pr-Version: 3.95
>Number: 47232
>Category: kern
>Synopsis: Trailing whilte space(s) of rnd source is hard to know
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Nov 21 17:35:01 +0000 2012
>Closed-Date: Sat Jan 12 06:55:31 +0000 2013
>Last-Modified: Sat Jan 12 06:55:31 +0000 2013
>Originator: SAITOH Masanobu
>Release: NetBSD 6.0
>Organization:
>Environment:
Architecture: all
>Description:
Sensor name may include white space.
e.g.:
# envstat
Current CritMax WarnMax WarnMin CritMin Unit
[coretemp0]
cpu0 temperature: 42.000 degC
[coretemp1]
cpu1 temperature: 41.000 degC
"cpu0 temperature" includes space.
sysmon_envsys_register() automatically call rnd_attach_source()
with using the following string:
snprintf(rnd_name, sizeof(rnd_name), "%s-%s",
sme->sme_name, edata->desc);
In this case sme->sme_name is "coretemp0" and edata->desc is
"cpu0 temperature". "%s-%s" becomes "coretemp0-cpu0 temperature".
The length is limited to 16, so the resul is "coretemp0-cpu0 ".
Note that there is a white space.
And then,
# rndctl -l
Source Bits Type Flags
wd1 56 disk estimate, collect
wd0 9124 disk estimate, collect
cpu1 149 vm estimate, collect
cpu0 43 vm estimate, collect
coretemp1-cpu1 3 env estimate, collect
coretemp0-cpu0 4 env estimate, collect
wm2 0 net
wm1 0 net
wm0 0 net
mskc0 0 net
system-power 0 power estimate, collect
callout 0 skew collect
# rndctl -EC -d coretemp1-cpu1
rndctl: ioctl(RNDCTL): No such file or directory <=== FAIL
# rndctl -EC -d "coretemp1-cpu1 " <=== With a white space
# <=== SUCCESS
It's hard to know.
>How-To-Repeat:
See above.
>Fix:
Remove trailing white space.
And also, changind space(s) in the middle with '-' is better (IMHO).
Index: sysmon_envsys.c
===================================================================
RCS file: /cvsroot/src/sys/dev/sysmon/sysmon_envsys.c,v
retrieving revision 1.125
diff -u -r1.125 sysmon_envsys.c
--- sysmon_envsys.c 6 Sep 2012 12:21:40 -0000 1.125
+++ sysmon_envsys.c 21 Nov 2012 17:35:16 -0000
@@ -778,8 +778,25 @@
*/
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
if (edata->flags & ENVSYS_FHAS_ENTROPY) {
+ size_t n;
+ int tail = 1;
+
snprintf(rnd_name, sizeof(rnd_name), "%s-%s",
sme->sme_name, edata->desc);
+ n = strlen(rnd_name);
+ /*
+ * 1) Remove trailing white space(s).
+ * 2) If space exist, replace it with '-'
+ */
+ while (--n) {
+ if (rnd_name[n] == ' ') {
+ if (tail != 0)
+ rnd_name[n] = '\0';
+ else
+ rnd_name[n] = '-';
+ } else
+ tail = 0;
+ }
rnd_attach_source(&edata->rnd_src, rnd_name,
RND_TYPE_ENV, 0);
}
>Release-Note:
>Audit-Trail:
From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47232 CVS commit: src/sys/dev/sysmon
Date: Thu, 29 Nov 2012 10:29:46 +0000
Module Name: src
Committed By: msaitoh
Date: Thu Nov 29 10:29:46 UTC 2012
Modified Files:
src/sys/dev/sysmon: sysmon_envsys.c
Log Message:
Remove trailing white space(s) from name of random source.
And also, changind space(s) in the middle with '-'.
PR#47232.
To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/dev/sysmon/sysmon_envsys.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 12 Jan 2013 06:55:31 +0000
State-Changed-Why:
Fixed by submitter.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.