From 9fe491df276a28ac68a6d9fab9bd8bae861708f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Mon, 26 Oct 2020 02:39:27 +0100 Subject: [PATCH] dasdfmt: Improve error message construction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In check_track_format() the base error message is the same for all cases but has different additional content depending on which mode dasdfmt is running. Currently the message is compiled by using different outputs. To make it a little bit cleaner and for a better error message handling, construct the message string completely before passing it to the error() function for output. Reviewed-by: Stefan Haberland Signed-off-by: Jan Höppner --- dasdfmt/dasdfmt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dasdfmt/dasdfmt.c b/dasdfmt/dasdfmt.c index 86e9330d..94f5d918 100644 --- a/dasdfmt/dasdfmt.c +++ b/dasdfmt/dasdfmt.c @@ -791,19 +791,18 @@ static format_check_t check_track_format(format_data_t *p) .stop_unit = p->stop_unit }, 0 }; + char msg[128] = ""; int err; err = dasd_check_format(g.dev_node, &cdata); if (err != 0) { if (err == ENOTTY) { - ERRMSG("%s: Missing kernel support for format checking", - prog_name); - if (mode == EXPAND) { - ERRMSG(". Mode 'expand' cannot be used"); - } else if (!g.check) { - ERRMSG(" (--force to override)"); - } - error("."); + sprintf(msg, "Missing kernel support for format checking"); + if (mode == EXPAND) + strcat(msg, ". Mode 'expand' cannot be used"); + else if (!g.check) + strcat(msg, " (--force to override)"); + error("%s.", msg); } error("Could not check format: %s", strerror(err)); }