mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
[v1.03] Add PPC integrity check
This commit is contained in:
@@ -44,6 +44,17 @@ struct cache* get_cache_info(struct cpuInfo* cpu) {
|
|||||||
return cach;
|
return cach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool check_package_ids_integrity(int* package_ids, int total_cores) {
|
||||||
|
for(int i=0; i < total_cores; i++) {
|
||||||
|
if(package_ids[i] >= total_cores || package_ids[i] < 0) {
|
||||||
|
printBug("check_package_ids_integrity: package_ids[%d]=%d", i, package_ids[i]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
struct topology* get_topology_info(struct cache* cach) {
|
struct topology* get_topology_info(struct cache* cach) {
|
||||||
struct topology* topo = emalloc(sizeof(struct topology));
|
struct topology* topo = emalloc(sizeof(struct topology));
|
||||||
init_topology_struct(topo, cach);
|
init_topology_struct(topo, cach);
|
||||||
@@ -68,6 +79,10 @@ struct topology* get_topology_info(struct cache* cach) {
|
|||||||
for(int i=0; i < topo->total_cores; i++) package_ids[i] = 0;
|
for(int i=0; i < topo->total_cores; i++) package_ids[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!check_package_ids_integrity(package_ids, topo->total_cores)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
for(int i=0; i < topo->total_cores; i++) {
|
for(int i=0; i < topo->total_cores; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user