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.
Modified files:
Index: src/sys/dev/sysmon/sysmon_envsys.c
diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.125 src/sys/dev/sysmon/sysmon_envsys.c:1.126
--- src/sys/dev/sysmon/sysmon_envsys.c:1.125 Thu Sep 6 12:21:40 2012
+++ src/sys/dev/sysmon/sysmon_envsys.c Thu Nov 29 10:29:45 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.125 2012/09/06 12:21:40 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.126 2012/11/29 10:29:45 msaitoh Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.125 2012/09/06 12:21:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.126 2012/11/29 10:29:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -778,8 +778,25 @@ out:
*/
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);
}