diff options
| author | msaitoh <msaitoh@NetBSD.org> | 2012-11-29 10:29:45 +0000 |
|---|---|---|
| committer | msaitoh <msaitoh@NetBSD.org> | 2012-11-29 10:29:45 +0000 |
| commit | c2fcd9e94725d2632b88e016bfa00eb528c93131 (patch) | |
| tree | 9ffe8b509b2eccc62059bb3da147d82f818defe9 /sys/dev/sysmon | |
| parent | 744f510792e2d961f6e2cb766cd0a5f9cebced90 (diff) | |
Remove trailing white space(s) from name of random source.
And also, changind space(s) in the middle with '-'.
PR#47232.
Diffstat (limited to 'sys/dev/sysmon')
| -rw-r--r-- | sys/dev/sysmon/sysmon_envsys.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sys/dev/sysmon/sysmon_envsys.c b/sys/dev/sysmon/sysmon_envsys.c index 69e3400cbd5..16e8604aced 100644 --- a/sys/dev/sysmon/sysmon_envsys.c +++ b/sys/dev/sysmon/sysmon_envsys.c @@ -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); } |
