From: Karel Zak Date: Mon, 2 Nov 2020 09:34:53 +0000 (+0100) Subject: lscpu: fix last caches separator in -e and -p output X-Git-Tag: v2.37-rc1~309 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e07cca6b8595224578376d3f0be25df663a47274;p=thirdparty%2Futil-linux.git lscpu: fix last caches separator in -e and -p output Note that cxt->ncaches is number of all instances, but we split output according to split output according to caches names. Signed-off-by: Karel Zak --- diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 654c3b5140..50412b859d 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -362,14 +362,14 @@ static char *get_cell_data( return NULL; p += x; sz -= x; - if (i + 1 < cxt->ncaches) { - if (sz < 2) - return NULL; - *p++ = cxt->show_compatible ? ',' : ':'; - *p = '\0'; - sz--; - } + if (sz < 2) + return NULL; + *p++ = cxt->show_compatible ? ',' : ':'; + *p = '\0'; + sz--; } + if (p > buf && (*(p - 1) == ',' || *(p - 1) == ':')) + *(p - 1) = '\0'; break; } case COL_CPU_POLARIZATION: @@ -442,14 +442,14 @@ static char *get_cell_header( return NULL; sz -= x; p += x; - if (i + 1 < cxt->ncaches) { - if (sz < 2) - return NULL; - *p++ = cxt->show_compatible ? ',' : ':'; - *p = '\0'; - sz--; - } + if (sz < 2) + return NULL; + *p++ = cxt->show_compatible ? ',' : ':'; + *p = '\0'; + sz--; } + if (p > buf && (*(p - 1) == ',' || *(p - 1) == ':')) + *(p - 1) = '\0'; if (cxt->ncaches) return buf; } diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h index 935734ce7f..d76e137902 100644 --- a/sys-utils/lscpu.h +++ b/sys-utils/lscpu.h @@ -50,7 +50,6 @@ struct lscpu_cache { unsigned int number_of_sets; unsigned int coherency_line_size; - size_t nsharedmaps; cpu_set_t *sharedmap; };