[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250308093452.3742-6-david.laight.linux@gmail.com>
Date: Sat, 8 Mar 2025 09:34:49 +0000
From: David Laight <david.laight.linux@...il.com>
To: linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>
Cc: David Laight <david.laight.linux@...il.com>,
Arnd Bergmann <arnd@...db.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Christophe Leroy <christophe.leroy@....fr>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
nnac123@...ux.ibm.com,
horms@...nel.org
Subject: [PATCH next 5/8] test_hexdump: Fix sample output if zero bytes requested
If 'len' is zero the expected output is an empty string even if
'ascii' is requested.
Signed-off-by: David Laight <david.laight.linux@...il.com>
---
lib/test_hexdump.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c
index ed6f0b0a1bb3..07a8cc7e9088 100644
--- a/lib/test_hexdump.c
+++ b/lib/test_hexdump.c
@@ -29,6 +29,11 @@ static size_t __init test_hexdump_prepare_test(size_t len, size_t rowsize,
char *p;
size_t byteswap, i, j;
+ if (!len) {
+ test[0] = 0;
+ return 0;
+ }
+
if (rowsize != 16 && rowsize != 32)
rowsize = 16;
@@ -58,8 +63,7 @@ static size_t __init test_hexdump_prepare_test(size_t len, size_t rowsize,
*p++ = ' ';
}
}
- if (i)
- p--;
+ p--;
/* ASCII part */
if (ascii) {
--
2.39.5
Powered by blists - more mailing lists