From 7e1dde3c7154e50c9fac7c8871cbdd5f7606db18 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Fri, 6 Aug 2021 09:37:03 +0200 Subject: [PATCH] [v0.98][PPC] Check if udev functions failed --- src/ppc/ppc.c | 10 ++++++++-- src/ppc/udev.c | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ppc/ppc.c b/src/ppc/ppc.c index 242dddd..8da5b7b 100644 --- a/src/ppc/ppc.c +++ b/src/ppc/ppc.c @@ -59,8 +59,14 @@ struct topology* get_topology_info(struct cache* cach) { int* core_ids = emalloc(sizeof(int) * topo->total_cores); int* package_ids = emalloc(sizeof(int) * topo->total_cores); - fill_core_ids_from_sys(core_ids, topo->total_cores); - fill_package_ids_from_sys(package_ids, topo->total_cores); + if(!fill_core_ids_from_sys(core_ids, topo->total_cores)) { + printWarn("fill_core_ids_from_sys failed, output may be incomplete/invalid"); + for(int i=0; i < topo->total_cores; i++) core_ids[i] = 0; + } + if(!fill_package_ids_from_sys(package_ids, topo->total_cores)) { + printWarn("fill_package_ids_from_sys failed, output may be incomplete/invalid"); + for(int i=0; i < topo->total_cores; i++) package_ids[i] = 0; + } // 2. Socket detection int *package_ids_count = emalloc(sizeof(int) * topo->total_cores); diff --git a/src/ppc/udev.c b/src/ppc/udev.c index b39a3f4..315d7d7 100644 --- a/src/ppc/udev.c +++ b/src/ppc/udev.c @@ -1,3 +1,6 @@ +#include + +#include "../common/global.h" #include "udev.h" #define _PATH_TOPO_CORE_ID "topology/core_id" @@ -12,14 +15,14 @@ bool fill_array_from_sys(int *core_ids, int total_cores, char* SYS_PATH) { for(int i=0; i < total_cores; i++) { sprintf(path, "%s%s/cpu%d/%s", _PATH_SYS_SYSTEM, _PATH_SYS_CPU, i, SYS_PATH); if((buf = read_file(path, &filelen)) == NULL) { - perror("open"); + printWarn("fill_array_from_sys: %s: %s", path, strerror(errno)); return false; } errno = 0; core_ids[i] = strtol(buf, &end, 10); if(errno != 0) { - perror("strtol"); + printWarn("fill_array_from_sys: %s:", strerror(errno)); return false; } free(buf);