mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
[v0.98][PPC] Check if udev functions failed
This commit is contained in:
@@ -59,8 +59,14 @@ struct topology* get_topology_info(struct cache* cach) {
|
|||||||
int* core_ids = emalloc(sizeof(int) * topo->total_cores);
|
int* core_ids = emalloc(sizeof(int) * topo->total_cores);
|
||||||
int* package_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);
|
if(!fill_core_ids_from_sys(core_ids, topo->total_cores)) {
|
||||||
fill_package_ids_from_sys(package_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
|
// 2. Socket detection
|
||||||
int *package_ids_count = emalloc(sizeof(int) * topo->total_cores);
|
int *package_ids_count = emalloc(sizeof(int) * topo->total_cores);
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "../common/global.h"
|
||||||
#include "udev.h"
|
#include "udev.h"
|
||||||
|
|
||||||
#define _PATH_TOPO_CORE_ID "topology/core_id"
|
#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++) {
|
for(int i=0; i < total_cores; i++) {
|
||||||
sprintf(path, "%s%s/cpu%d/%s", _PATH_SYS_SYSTEM, _PATH_SYS_CPU, i, SYS_PATH);
|
sprintf(path, "%s%s/cpu%d/%s", _PATH_SYS_SYSTEM, _PATH_SYS_CPU, i, SYS_PATH);
|
||||||
if((buf = read_file(path, &filelen)) == NULL) {
|
if((buf = read_file(path, &filelen)) == NULL) {
|
||||||
perror("open");
|
printWarn("fill_array_from_sys: %s: %s", path, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
core_ids[i] = strtol(buf, &end, 10);
|
core_ids[i] = strtol(buf, &end, 10);
|
||||||
if(errno != 0) {
|
if(errno != 0) {
|
||||||
perror("strtol");
|
printWarn("fill_array_from_sys: %s:", strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user