Module Name:    src
Committed By:   skrll
Date:           Sat Mar  6 13:21:26 UTC 2021

Modified Files:
        src/sys/dev/fdt: fdt_ddb.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/fdt_ddb.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/fdt/fdt_ddb.c
diff -u src/sys/dev/fdt/fdt_ddb.c:1.1 src/sys/dev/fdt/fdt_ddb.c:1.2
--- src/sys/dev/fdt/fdt_ddb.c:1.1	Fri Oct 30 16:08:45 2020
+++ src/sys/dev/fdt/fdt_ddb.c	Sat Mar  6 13:21:26 2021
@@ -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 @@ fdt_isprint(const void *data, int len)
 	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;

Reply via email to