From e9d0e267c58003cca5e8a0ce2838d80a2055210e Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Wed, 8 Jun 2022 14:08:19 +0200 Subject: [PATCH] cpumf/lscpumf: Replace /sys mount point by util_path_sysfs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace hard coded /sys directory by call to util_path_sysfs() function. Signed-off-by: Thomas Richter Reviewed-by: Jan Höppner Signed-off-by: Jan Höppner --- cpumf/lscpumf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cpumf/lscpumf.c b/cpumf/lscpumf.c index 9390d082..311877bc 100644 --- a/cpumf/lscpumf.c +++ b/cpumf/lscpumf.c @@ -26,6 +26,7 @@ #include "lib/util_arch.h" #include "lib/util_base.h" #include "lib/util_opt.h" +#include "lib/util_path.h" #include "lib/util_prg.h" #include "lib/libcpumf.h" @@ -3318,17 +3319,18 @@ static void show_info(struct cpumf_info *p, int details) * counter was renamed from CCERROR to CCFINISH in linux version 5.8. * Check for existence of file /sys/devices/cpum_cf/events/DLFT_CCERROR. */ -#define CCERROR "/sys/devices/cpum_cf/events/DFLT_CCERROR" static void read_ccerror(struct counters *cp, size_t cp_cnt) { + char *ctrname, *path; struct stat sbuf; - char *ctrname; size_t i = 0; - if (!stat(CCERROR, &sbuf)) + path = util_path_sysfs("devices/cpum_cf/events/DFLT_CCERROR"); + if (!stat(path, &sbuf)) ctrname = "DFLT_CCERROR"; else ctrname = "DFLT_CCFINISH"; + free(path); /* Find DFLT_CC{FINISH,ERROR} in table and set name */ for (struct counters *p = cp; i < cp_cnt; ++i, ++p) if (p->ctrnum == 265) {