From 36fed0e6c6590631c4ce1707c8fe3c3397bcce4d Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 12 Feb 2020 14:08:24 +0100 Subject: [PATCH] zipl/libc: Indicate truncated lines in printf with '...' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Append '...' to lines exceeding the maximum line length instead of silently truncating them. Suggested-by: Marc Hartmayer Signed-off-by: Philipp Rudo Reviewed-by: Marc Hartmayer Reviewed-by: Stefan Haberland Signed-off-by: Jan Höppner --- zipl/boot/libc.c | 10 ++++++++-- zipl/boot/libc.h | 1 + zipl/boot/menu.h | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/zipl/boot/libc.c b/zipl/boot/libc.c index 004a0a55..4db5bab7 100644 --- a/zipl/boot/libc.c +++ b/zipl/boot/libc.c @@ -410,11 +410,17 @@ void snprintf(char *buf, unsigned long size, const char *fmt, ...) */ void printf(const char *fmt, ...) { - char buf[81]; + char buf[LINE_LENGTH + 1]; + int len; va_list va; va_start(va, fmt); - vsnprintf(buf, sizeof(buf), fmt, va); + len = vsnprintf(buf, sizeof(buf), fmt, va); + if (len > LINE_LENGTH) { + buf[LINE_LENGTH - 1] = '.'; + buf[LINE_LENGTH - 2] = '.'; + buf[LINE_LENGTH - 3] = '.'; + } sclp_print(buf); va_end(va); } diff --git a/zipl/boot/libc.h b/zipl/boot/libc.h index 8b0639ed..83ff82bc 100644 --- a/zipl/boot/libc.h +++ b/zipl/boot/libc.h @@ -42,6 +42,7 @@ #define ENOTTY 25 /* Not a typewriter */ #define MIB (1024ULL * 1024) +#define LINE_LENGTH 80 /* max line length printed by printf */ void printf(const char *, ...); void snprintf(char *buf, unsigned long size, const char *fmt, ...); diff --git a/zipl/boot/menu.h b/zipl/boot/menu.h index 1b103a85..ee0f2c5f 100644 --- a/zipl/boot/menu.h +++ b/zipl/boot/menu.h @@ -20,7 +20,6 @@ /* max command line length */ #define COMMAND_LINE_SIZE 896 #define BOOT_MENU_ENTRIES 63 -#define LINE_LENGTH 80 #define PARAM_SIZE 8 #define TEXT_OFFSET 4