[v0.98][PPC] Check if udev functions failed

This commit is contained in:
Dr-Noob
2021-08-06 09:37:03 +02:00
parent 44d4b3b553
commit 7e1dde3c71
2 changed files with 13 additions and 4 deletions

View File

@@ -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);

View File

@@ -1,3 +1,6 @@
#include <errno.h>
#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);