]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: restructure op-mode printing
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 19 Mar 2024 21:49:31 +0000 (22:49 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 19 Mar 2024 21:50:56 +0000 (22:50 +0100)
The existing logic can confuse ASAN.
Restructure it so it is shorter and easer to understand for humans.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
sys-utils/lscpu.c

index a65ccad5e435b93686c478aa197adb7dc71fa28c..c073fc0dc45484ccfe6db38400a97486c86e8f3d 100644 (file)
@@ -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);