Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/sysmon Remove trailing white space(s) from name of r...



details:   https://anonhg.NetBSD.org/src/rev/4462a4058d5f
branches:  trunk
changeset: 782963:4462a4058d5f
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Nov 29 10:29:45 2012 +0000

description:
Remove trailing white space(s) from name of random source.
And also, changind space(s) in the middle with '-'.
PR#47232.

diffstat:

 sys/dev/sysmon/sysmon_envsys.c |  21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diffs (44 lines):

diff -r 358adcc9de42 -r 4462a4058d5f sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c    Thu Nov 29 09:13:44 2012 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c    Thu Nov 29 10:29:45 2012 +0000
@@ -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 @@
                 */
                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);
                        }



Home | Main Index | Thread Index | Old Index