Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Improve fdt_isprint so that it returns false if ...



details:   https://anonhg.NetBSD.org/src/rev/b6f3b259483b
branches:  trunk
changeset: 981261:b6f3b259483b
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat Mar 06 13:21:26 2021 +0000

description:
Improve fdt_isprint so that it returns false if there are consecutive
zeroes.

diffstat:

 sys/dev/fdt/fdt_ddb.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r bcc05c53fd20 -r b6f3b259483b sys/dev/fdt/fdt_ddb.c
--- a/sys/dev/fdt/fdt_ddb.c     Sat Mar 06 08:34:58 2021 +0000
+++ b/sys/dev/fdt/fdt_ddb.c     Sat Mar 06 13:21:26 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdt_ddb.c,v 1.1 2020/10/30 16:08:45 skrll Exp $        */
+/*     $NetBSD: fdt_ddb.c,v 1.2 2021/03/06 13:21:26 skrll Exp $        */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_ddb.c,v 1.1 2020/10/30 16:08:45 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_ddb.c,v 1.2 2021/03/06 13:21:26 skrll Exp $");
 
 #include <sys/param.h>
 
@@ -49,8 +49,16 @@
        if (len == 0)
                return false;
 
+       /* Count consecutive zeroes */
+       int cz = 0;
        for (size_t j = 0; j < len; j++) {
-               if (!(isprint(c[j]) || c[j] == '\0'))
+               if (c[j] == '\0')
+                       cz++;
+               else if (isprint(c[j]))
+                       cz = 0;
+               else
+                       return false;
+               if (cz > 1)
                        return false;
        }
        return true;



Home | Main Index | Thread Index | Old Index