From 83cc57700f1e2c37c889279f724f0f51dcd9ffc5 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 4 Dec 2024 21:22:03 -0500 Subject: [PATCH] fixup! cmd_format: fix --version Signed-off-by: Kent Overstreet --- c_src/tools-util.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/c_src/tools-util.c b/c_src/tools-util.c index 3df2b004..1a749858 100644 --- a/c_src/tools-util.c +++ b/c_src/tools-util.c @@ -734,9 +734,16 @@ unsigned version_parse(char *buf) unsigned major, minor; - if (kstrtouint(major_str, 10, &major) || - kstrtouint(minor_str, 10, &minor)) - die("invalid version"); + if (!minor_str) { + major = 0; + if (kstrtouint(major_str, 10, &minor)) + die("invalid version %s", buf); + } else { + + if (kstrtouint(major_str, 10, &major) || + kstrtouint(minor_str, 10, &minor)) + die("invalid version %s", buf); + } return BCH_VERSION(major, minor); }