From: Thomas Weißschuh Date: Tue, 19 Mar 2024 21:49:31 +0000 (+0100) Subject: lscpu: restructure op-mode printing X-Git-Tag: v2.42-start~478^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0477ce4805de4f0f01e98b04ed9acf4168ed805e;p=thirdparty%2Futil-linux.git lscpu: restructure op-mode printing The existing logic can confuse ASAN. Restructure it so it is shorter and easer to understand for humans. Signed-off-by: Thomas Weißschuh --- diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index a65ccad5e..c073fc0dc 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -990,18 +990,16 @@ static void print_summary(struct lscpu_cxt *cxt) /* Section: architecture */ sec = add_summary_s(tb, NULL, _("Architecture:"), cxt->arch->name); if (cxt->arch->bit32 || cxt->arch->bit64) { - char buf[32], *p = buf; + const char *p; - if (cxt->arch->bit32) { - strcpy(p, "32-bit, "); - p += 8; - } - if (cxt->arch->bit64) { - strcpy(p, "64-bit, "); - p += 8; - } - *(p - 2) = '\0'; - add_summary_s(tb, sec, _("CPU op-mode(s):"), buf); + if (cxt->arch->bit32 && cxt->arch->bit64) + p = "32-bit, 64-bit"; + else if (cxt->arch->bit32) + p = "32-bit"; + else + p = "64-bit"; + + add_summary_s(tb, sec, _("CPU op-mode(s):"), p); } if (ct && ct->addrsz) add_summary_s(tb, sec, _("Address sizes:"), ct->addrsz);