mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -27,7 +27,7 @@ const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
ffCPUDetectX86Specific(cpu);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffCPUAppleCodeToName(uint32_t code) {
|
||||
@@ -63,7 +63,7 @@ const char* ffCPUAppleCodeToName(uint32_t code) {
|
||||
case 6041:
|
||||
return "Apple M4 Max";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ const char* ffCPUQualcommCodeToName(uint32_t code) {
|
||||
case 8280:
|
||||
return "Qualcomm Snapdragon 8cx Gen 3";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
|
||||
uint64_t caps[2] = { 0 }; // 80-bit capability mask, split into two 64-bit values
|
||||
size_t size = sizeof(caps);
|
||||
|
||||
if (sysctlbyname("hw.optional.arm.caps", caps, &size, NULL, 0) != 0) {
|
||||
if (sysctlbyname("hw.optional.arm.caps", caps, &size, nullptr, 0) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
static double detectCpuTemp(const FFCPUOptions* options, const FFstrbuf* cpuName) {
|
||||
double result = 0;
|
||||
|
||||
const char* error = NULL;
|
||||
const char* error = nullptr;
|
||||
|
||||
if (options->tempSensor.length) {
|
||||
error = ffDetectSmcSpecificTemp(options->tempSensor.chars, &result);
|
||||
} else {
|
||||
if (ffStrbufStartsWithS(cpuName, "Apple M")) {
|
||||
switch (strtol(cpuName->chars + strlen("Apple M"), NULL, 10)) {
|
||||
switch (strtol(cpuName->chars + strlen("Apple M"), nullptr, 10)) {
|
||||
case 1:
|
||||
error = ffDetectSmcTemps(FF_TEMP_CPU_M1X, &result);
|
||||
break;
|
||||
@@ -83,7 +83,7 @@ static const char* detectFrequency(FFCPUResult* cpu) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
static const char* detectFrequency(FFCPUResult* cpu) {
|
||||
@@ -92,11 +92,11 @@ static const char* detectFrequency(FFCPUResult* cpu) {
|
||||
if (cpu->frequencyBase == 0) {
|
||||
unsigned current = 0;
|
||||
size_t size = sizeof(current);
|
||||
if (sysctl((int[]) { CTL_HW, HW_CPU_FREQ }, 2, ¤t, &size, NULL, 0) == 0) {
|
||||
if (sysctl((int[]) { CTL_HW, HW_CPU_FREQ }, 2, ¤t, &size, nullptr, 0) == 0) {
|
||||
cpu->frequencyBase = (uint32_t) (current / 1000 / 1000);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -117,11 +117,11 @@ static const char* detectCoreCount(FFCPUResult* cpu) {
|
||||
.count = (uint32_t) ffSysctlGetInt(sysctlKey, 0),
|
||||
};
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
if (ffSysctlGetString("machdep.cpu.brand_string", &cpu->name) != NULL) {
|
||||
if (ffSysctlGetString("machdep.cpu.brand_string", &cpu->name) != nullptr) {
|
||||
return "sysctlbyname(machdep.cpu.brand_string) failed";
|
||||
}
|
||||
|
||||
@@ -154,5 +154,5 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
|
||||
cpu->temperature = options->temp ? detectCpuTemp(options, &cpu->name) : FF_CPU_TEMP_UNSET;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+17
-17
@@ -221,7 +221,7 @@ static const char* armPartId2name(uint32_t partId) {
|
||||
case 0xd90:
|
||||
return "C1-Premium";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ static const char* brcmPartId2name(uint32_t partId) {
|
||||
case 0x516:
|
||||
return "ThunderX2";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ static const char* decPartId2name(uint32_t partId) {
|
||||
case 0xa11:
|
||||
return "SA1100";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ static const char* caviumPartId2name(uint32_t partId) {
|
||||
case 0x0b8:
|
||||
return "ThunderX3-T110";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ static const char* apmPartId2name(uint32_t partId) {
|
||||
case 0x000:
|
||||
return "X-Gene";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ static const char* qcomPartId2name(uint32_t partId) {
|
||||
case 0xc01:
|
||||
return "Saphira";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ static const char* samsungPartId2name(uint32_t partId) {
|
||||
case 0x004:
|
||||
return "Exynos-M5";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ static const char* nvidiaPartId2name(uint32_t partId) {
|
||||
case 0x010:
|
||||
return "Olympus";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ static const char* marvellPartId2name(uint32_t partId) {
|
||||
case 0x584:
|
||||
return "PJ4B-MP";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ static const char* applePartId2name(uint32_t partId) {
|
||||
case 0x049:
|
||||
return "Everest-M3-Max";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ static const char* faradayPartId2name(uint32_t partId) {
|
||||
case 0x626:
|
||||
return "FA626";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ static const char* intelPartId2name(uint32_t partId) {
|
||||
case 0xc12:
|
||||
return "IPX1200";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ static const char* fujitsuPartId2name(uint32_t partId) {
|
||||
case 0x003:
|
||||
return "MONAKA";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ static const char* hisiPartId2name(uint32_t partId) {
|
||||
case 0xd41:
|
||||
return "Cortex-A77"; /* HiSilicon uses this ID though advertises A77 */
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ static const char* amperePartId2name(uint32_t partId) {
|
||||
case 0xac4:
|
||||
return "Ampere-1a";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +574,7 @@ static const char* ftPartId2name(uint32_t partId) {
|
||||
case 0x862:
|
||||
return "FTC862";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,6 +583,6 @@ static const char* msPartId2name(uint32_t partId) {
|
||||
case 0xd49:
|
||||
return "Azure-Cobalt-100";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
|
||||
// In tenth of degrees Kelvin
|
||||
*current = (double) temp / 10 - 273.15;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
if (ffSysctlGetString("hw.model", &cpu->name) != NULL) {
|
||||
if (ffSysctlGetString("hw.model", &cpu->name) != nullptr) {
|
||||
return "sysctlbyname(hw.model) failed";
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
cpu->coresOnline = (uint16_t) ffSysctlGetInt("kern.smp.cpus", cpu->coresLogical);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
if (ffSysctlGetString("kern.sched.topology_spec", &buffer) == NULL && buffer.length > 0) {
|
||||
if (ffSysctlGetString("kern.sched.topology_spec", &buffer) == nullptr && buffer.length > 0) {
|
||||
// <groups>
|
||||
// <group level="1" cache-level="3">
|
||||
// <cpu count="4" mask="f,0,0,0">0, 1, 2, 3</cpu>
|
||||
@@ -82,13 +82,13 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
ffStrbufClear(&buffer);
|
||||
char key[32];
|
||||
snprintf(key, sizeof(key), "dev.cpu.%u.freq_levels", i);
|
||||
if (ffSysctlGetString(key, &buffer) == NULL) {
|
||||
if (ffSysctlGetString(key, &buffer) == nullptr) {
|
||||
if (buffer.length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// MHz/Watts pairs like: 2501/32000 2187/27125 2000/24000
|
||||
uint32_t fmax = (uint32_t) strtoul(buffer.chars, NULL, 10);
|
||||
uint32_t fmax = (uint32_t) strtoul(buffer.chars, nullptr, 10);
|
||||
if (cpu->frequencyMax < fmax) {
|
||||
cpu->frequencyMax = fmax;
|
||||
}
|
||||
@@ -105,5 +105,5 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
|
||||
cpu->numaNodes = (uint16_t) ffSysctlGetInt("vm.ndomains", 0);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FFCPUResult
|
||||
}
|
||||
|
||||
uint32 topoNodeCount = 0;
|
||||
get_cpu_topology_info(NULL, &topoNodeCount);
|
||||
get_cpu_topology_info(nullptr, &topoNodeCount);
|
||||
if (topoNodeCount == 0) {
|
||||
return "get_cpu_topology_info(NULL) failed";
|
||||
return "get_cpu_topology_info(nullptr) failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE cpu_topology_node_info* topology = malloc(sizeof(*topology) * topoNodeCount);
|
||||
@@ -64,5 +64,5 @@ const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FFCPUResult
|
||||
cpu->packages = packages;
|
||||
cpu->coresPhysical = cores;
|
||||
cpu->coresOnline = cpu->coresLogical = (uint16_t) sysInfo.cpu_count;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ static double detectCPUTemp(const FFCPUOptions* options) {
|
||||
|
||||
if (options->tempSensor.length > 0) {
|
||||
FF_AUTO_CLOSE_FD int subfd = -1;
|
||||
const char* fileName = NULL;
|
||||
const char* fileName = nullptr;
|
||||
if (ffStrbufStartsWithS(&options->tempSensor, "hwmon") && ffCharIsDigit(options->tempSensor.chars[strlen("hwmon")])) {
|
||||
FF_AUTO_CLOSE_FD int dfd = open("/sys/class/hwmon/", O_PATH | O_CLOEXEC);
|
||||
subfd = openat(dfd, options->tempSensor.chars, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
@@ -115,7 +115,7 @@ static double detectCPUTemp(const FFCPUOptions* options) {
|
||||
int dfd = dirfd(dirp);
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ static double detectCPUTemp(const FFCPUOptions* options) {
|
||||
if (dirp) {
|
||||
int dfd = dirfd(dirp);
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ static double detectCPUTemp(const FFCPUOptions* options) {
|
||||
if (dirp) {
|
||||
int dfd = dirfd(dirp);
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ static void detectNumaNodes(FFCPUResult* cpu) {
|
||||
}
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (entry->d_type != DT_DIR && entry->d_type != DT_UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
@@ -210,8 +210,8 @@ static void detectQualcomm(FFCPUResult* cpu) {
|
||||
// https://en.wikipedia.org/wiki/List_of_Qualcomm_Snapdragon_systems_on_chips
|
||||
|
||||
assert(cpu->name.length >= 2);
|
||||
uint32_t code = (uint32_t) strtoul(cpu->name.chars + 2, NULL, 10);
|
||||
const char* name = NULL;
|
||||
uint32_t code = (uint32_t) strtoul(cpu->name.chars + 2, nullptr, 10);
|
||||
const char* name = nullptr;
|
||||
|
||||
switch (code) {
|
||||
case 8845:
|
||||
@@ -300,8 +300,8 @@ static void detectMediaTek(FFCPUResult* cpu) {
|
||||
// https://en.wikipedia.org/wiki/List_of_MediaTek_systems_on_chips
|
||||
|
||||
assert(cpu->name.length >= 2);
|
||||
uint32_t code = (uint32_t) strtoul(cpu->name.chars + 2, NULL, 10);
|
||||
const char* name = NULL;
|
||||
uint32_t code = (uint32_t) strtoul(cpu->name.chars + 2, nullptr, 10);
|
||||
const char* name = nullptr;
|
||||
|
||||
switch (code) // The SOC code of MTK Dimensity series is full of mess
|
||||
{
|
||||
@@ -353,8 +353,8 @@ static void detectExynos(FFCPUResult* cpu) {
|
||||
// https://en.wikipedia.org/wiki/Exynos
|
||||
|
||||
assert(cpu->name.length > 3);
|
||||
uint32_t code = (uint32_t) strtoul(cpu->name.chars + 3, NULL, 10);
|
||||
const char* name = NULL;
|
||||
uint32_t code = (uint32_t) strtoul(cpu->name.chars + 3, nullptr, 10);
|
||||
const char* name = nullptr;
|
||||
|
||||
switch (code) {
|
||||
case 9965:
|
||||
@@ -458,15 +458,15 @@ static void detectAndroid(FFCPUResult* cpu) {
|
||||
#include "cpu_arm.h"
|
||||
|
||||
static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId) {
|
||||
char* line = NULL;
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
uint32_t lastPartId = UINT32_MAX;
|
||||
while (ffStrbufGetline(&line, &len, cpuinfo)) {
|
||||
if (!ffStrStartsWith(line, "CPU part\t: ")) {
|
||||
continue;
|
||||
}
|
||||
uint32_t partId = (uint32_t) strtoul(line + strlen("CPU part\t: "), NULL, 16);
|
||||
const char* name = NULL;
|
||||
uint32_t partId = (uint32_t) strtoul(line + strlen("CPU part\t: "), nullptr, 16);
|
||||
const char* name = nullptr;
|
||||
switch (implId) {
|
||||
case 0x41:
|
||||
name = armPartId2name(partId);
|
||||
@@ -551,7 +551,7 @@ static const char* parseCpuInfo(
|
||||
FF_A_UNUSED FFstrbuf* cpuIsa,
|
||||
FF_A_UNUSED FFstrbuf* cpuUarch,
|
||||
FF_A_UNUSED FFstrbuf* cpuImplementer) {
|
||||
char* line = NULL;
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
|
||||
while (ffStrbufGetline(&line, &len, cpuinfo)) {
|
||||
@@ -606,7 +606,7 @@ static const char* parseCpuInfo(
|
||||
false);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static uint32_t getFrequency(int policyFd, const char* cpuinfoFileName, const char* scalingFileName, FFstrbuf* buffer) {
|
||||
@@ -636,7 +636,7 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (ffStrStartsWith(entry->d_name, "policy") && ffCharIsDigit(entry->d_name[strlen("policy")])) {
|
||||
FF_AUTO_CLOSE_FD int policyFd = openat(freqFd, entry->d_name, O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_PATH);
|
||||
if (policyFd < 0) {
|
||||
@@ -656,7 +656,7 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options) {
|
||||
cpu->frequencyMax = fmax;
|
||||
}
|
||||
|
||||
uint32_t fbase = getFrequency(policyFd, "base_frequency", NULL, &buffer);
|
||||
uint32_t fbase = getFrequency(policyFd, "base_frequency", nullptr, &buffer);
|
||||
if (fbase > 0) {
|
||||
cpu->frequencyBase = cpu->frequencyBase > fbase ? cpu->frequencyBase : fbase;
|
||||
}
|
||||
@@ -708,7 +708,7 @@ FF_A_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFCPURe
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY physicalCoresBuffer = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY cpuMHz = ffStrbufCreate();
|
||||
const char* error = parseCpuInfo(&cpuinfo, cpu, &physicalCoresBuffer, &cpuMHz, NULL, NULL, NULL);
|
||||
const char* error = parseCpuInfo(&cpuinfo, cpu, &physicalCoresBuffer, &cpuMHz, nullptr, nullptr, nullptr);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
@@ -729,7 +729,7 @@ FF_A_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFCPURe
|
||||
|
||||
detectNumaNodes(cpu);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -750,7 +750,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) {
|
||||
|
||||
struct dirent* entry;
|
||||
FF_LIST_AUTO_DESTROY cpuList = ffListCreate();
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (entry->d_type != DT_DIR || !ffStrStartsWith(entry->d_name, "cpu") || !ffCharIsDigit(entry->d_name[strlen("cpu")])) {
|
||||
continue;
|
||||
}
|
||||
@@ -768,7 +768,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) {
|
||||
ssize_t len = ffReadFileDataRelative(cpuxfd, "topology/physical_package_id", sizeof(buf) - 1, buf);
|
||||
if (len > 0) {
|
||||
buf[len] = '\0';
|
||||
unsigned long long id = strtoull(buf, NULL, 10);
|
||||
unsigned long long id = strtoull(buf, nullptr, 10);
|
||||
if (__builtin_expect(id < 128, true)) {
|
||||
// Do 129-socket boards exist?
|
||||
if (__builtin_expect(id >= 64, false)) {
|
||||
@@ -810,7 +810,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) {
|
||||
|
||||
cpu->coresPhysical = (uint16_t) cpuList.length;
|
||||
cpu->packages = (uint16_t) (__builtin_popcountll(pkgLow) + __builtin_popcountll(pkgHigh));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_A_UNUSED static void parseIsa(FFstrbuf* cpuIsa) {
|
||||
@@ -851,8 +851,8 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
|
||||
|
||||
--length;
|
||||
|
||||
char* vendor = NULL;
|
||||
char* model = NULL;
|
||||
char* vendor = nullptr;
|
||||
char* model = nullptr;
|
||||
|
||||
for (char* p; length > 0; length = p ? (ssize_t) (p - content) - 1 : 0) {
|
||||
p = memrchr(content, '\0', (size_t) length);
|
||||
@@ -899,7 +899,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
|
||||
else if (ffStrEquals(vendor, "apple")) {
|
||||
// https://elixir.bootlin.com/linux/v6.11/source/arch/arm64/boot/dts/apple
|
||||
if (model[0] == 't') {
|
||||
uint32_t deviceId = (uint32_t) strtoul(model + 1, NULL, 10);
|
||||
uint32_t deviceId = (uint32_t) strtoul(model + 1, nullptr, 10);
|
||||
ffStrbufSetStatic(&cpu->name, ffCPUAppleCodeToName(deviceId));
|
||||
|
||||
if (!cpu->name.length) {
|
||||
@@ -922,7 +922,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
|
||||
}
|
||||
} else if (ffStrStartsWith(model, "sc")) {
|
||||
const char* code = model + 2;
|
||||
uint32_t deviceId = (uint32_t) strtoul(code, NULL, 10);
|
||||
uint32_t deviceId = (uint32_t) strtoul(code, nullptr, 10);
|
||||
ffStrbufSetStatic(&cpu->name, ffCPUQualcommCodeToName(deviceId));
|
||||
if (!cpu->name.length) {
|
||||
ffStrbufAppendS(&cpu->name, "Qualcomm Snapdragon SC");
|
||||
@@ -997,7 +997,7 @@ FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCP
|
||||
FF_STRBUF_AUTO_DESTROY cpuUarch = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY cpuImplementerStr = ffStrbufCreate();
|
||||
|
||||
const char* error = parseCpuInfo(&cpuinfo, cpu, NULL, &cpuMHz, &cpuIsa, &cpuUarch, &cpuImplementerStr);
|
||||
const char* error = parseCpuInfo(&cpuinfo, cpu, nullptr, &cpuMHz, &cpuIsa, &cpuUarch, &cpuImplementerStr);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
@@ -1007,7 +1007,7 @@ FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCP
|
||||
}
|
||||
|
||||
#if __arm__ || __aarch64__
|
||||
uint32_t cpuImplementer = (uint32_t) strtoul(cpuImplementerStr.chars, NULL, 16);
|
||||
uint32_t cpuImplementer = (uint32_t) strtoul(cpuImplementerStr.chars, nullptr, 16);
|
||||
ffStrbufSetStatic(&cpu->vendor, hwImplId2Vendor(cpuImplementer));
|
||||
|
||||
if (cpu->name.length == 0) {
|
||||
@@ -1050,7 +1050,7 @@ FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCP
|
||||
ffCPUDetectByCpuid(cpu);
|
||||
detectNumaNodes(cpu);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
static void freePropDict(prop_dictionary_t* pdict) {
|
||||
assert(pdict != NULL);
|
||||
if (*pdict == NULL) {
|
||||
assert(pdict != nullptr);
|
||||
if (*pdict == nullptr) {
|
||||
return;
|
||||
}
|
||||
prop_object_release(*pdict);
|
||||
@@ -23,7 +23,7 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed";
|
||||
}
|
||||
|
||||
FF_A_CLEANUP(freePropDict) prop_dictionary_t root = NULL;
|
||||
FF_A_CLEANUP(freePropDict) prop_dictionary_t root = nullptr;
|
||||
if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &root) < 0) {
|
||||
return "prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed";
|
||||
}
|
||||
@@ -67,18 +67,18 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
|
||||
*current = temp / 1e6 - 273.15;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
if (ffSysctlGetString("machdep.cpu_brand", &cpu->name) != NULL &&
|
||||
ffSysctlGetString("machdep.dmi.processor-version", &cpu->name) != NULL &&
|
||||
ffSysctlGetString("hw.cpu0.name", &cpu->name) != NULL &&
|
||||
ffSysctlGetString("hw.model", &cpu->name) != NULL) {
|
||||
if (ffSysctlGetString("machdep.cpu_brand", &cpu->name) != nullptr &&
|
||||
ffSysctlGetString("machdep.dmi.processor-version", &cpu->name) != nullptr &&
|
||||
ffSysctlGetString("hw.cpu0.name", &cpu->name) != nullptr &&
|
||||
ffSysctlGetString("hw.model", &cpu->name) != nullptr) {
|
||||
ffStrbufSetS(&cpu->name, "Unknown CPU");
|
||||
}
|
||||
|
||||
if (ffSysctlGetString("machdep.dmi.processor-vendor", &cpu->vendor) == NULL) {
|
||||
if (ffSysctlGetString("machdep.dmi.processor-vendor", &cpu->vendor) == nullptr) {
|
||||
ffStrbufTrimRightSpace(&cpu->vendor);
|
||||
}
|
||||
|
||||
@@ -105,5 +105,5 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
detectCpuTemp(options, &cpu->temperature);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ static const char* detectCPUTemp(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
for (mib[2] = 0; mib[2] < 1024; mib[2]++) {
|
||||
struct sensordev sensordev;
|
||||
size_t sdlen = sizeof(struct sensordev);
|
||||
if (sysctl(mib, 3, &sensordev, &sdlen, NULL, 0) < 0) {
|
||||
if (sysctl(mib, 3, &sensordev, &sdlen, nullptr, 0) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
break;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ static const char* detectCPUTemp(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
for (mib[4] = 0; mib[4] < sensordev.maxnumt[SENSOR_TEMP]; mib[4]++) {
|
||||
struct sensor sensor;
|
||||
size_t slen = sizeof(struct sensor);
|
||||
if (sysctl(mib, 5, &sensor, &slen, NULL, 0) < 0) {
|
||||
if (sysctl(mib, 5, &sensor, &slen, nullptr, 0) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
return "sysctl(sensor) failed";
|
||||
}
|
||||
@@ -46,7 +46,7 @@ static const char* detectCPUTemp(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
}
|
||||
|
||||
cpu->temperature = (double) (sensor.value - 273150000) / 1E6;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,5 +74,5 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
detectCPUTemp(options, cpu);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -4,28 +4,28 @@
|
||||
#include <kstat.h>
|
||||
|
||||
static const char* detectCPUTempByKstat(const FFCPUOptions* options, kstat_ctl_t* kc, FFCPUResult* cpu) {
|
||||
const char* possibleModules[] = { "temperature", "cpu_temp", "acpi_thermal", NULL };
|
||||
const char* possibleModules[] = { "temperature", "cpu_temp", "acpi_thermal", nullptr };
|
||||
|
||||
if (options->tempSensor.length > 0) {
|
||||
possibleModules[0] = options->tempSensor.chars;
|
||||
possibleModules[1] = NULL;
|
||||
possibleModules[1] = nullptr;
|
||||
}
|
||||
|
||||
for (int i = 0; possibleModules[i] != NULL; i++) {
|
||||
kstat_t* ks = kstat_lookup(kc, possibleModules[i], -1, NULL);
|
||||
if (ks && kstat_read(kc, ks, NULL) >= 0) {
|
||||
for (int i = 0; possibleModules[i] != nullptr; i++) {
|
||||
kstat_t* ks = kstat_lookup(kc, possibleModules[i], -1, nullptr);
|
||||
if (ks && kstat_read(kc, ks, nullptr) >= 0) {
|
||||
kstat_named_t* kn = kstat_data_lookup(ks, "temperature");
|
||||
if (kn) {
|
||||
switch (kn->data_type) {
|
||||
case KSTAT_DATA_INT32:
|
||||
cpu->temperature = (float) kn->value.i32;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
case KSTAT_DATA_UINT32:
|
||||
cpu->temperature = (float) kn->value.ui32;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
case KSTAT_DATA_FLOAT:
|
||||
cpu->temperature = kn->value.f;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,17 +36,17 @@ static const char* detectCPUTempByKstat(const FFCPUOptions* options, kstat_ctl_t
|
||||
|
||||
static const char* detectCPUTempByIpmiTool(FFCPUResult* cpu) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
const char* error = ffProcessAppendStdOut(&buffer, (char* const[]) { "ipmitool", "-c", "sdr", "list", NULL });
|
||||
const char* error = ffProcessAppendStdOut(&buffer, (char* const[]) { "ipmitool", "-c", "sdr", "list", nullptr });
|
||||
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
char* line = NULL;
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
while (ffStrbufGetline(&line, &len, &buffer)) {
|
||||
if (sscanf(line, "CPU%*d Temp,%lf,degrees C,ok", &cpu->temperature) == 1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ static inline uint16_t countTypeId(kstat_ctl_t* kc, const char* type) {
|
||||
uint64_t low = 0, high = 0;
|
||||
for (kstat_t* ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
|
||||
if (ffStrStartsWith(ksp->ks_module, "cpu_info")) {
|
||||
if (kstat_read(kc, ksp, NULL) < 0) {
|
||||
if (kstat_read(kc, ksp, nullptr) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -104,12 +104,12 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
kstat_t* ks = kstat_lookup(kc, "cpu_info", -1, NULL);
|
||||
kstat_t* ks = kstat_lookup(kc, "cpu_info", -1, nullptr);
|
||||
if (!ks) {
|
||||
return "kstat_lookup() failed";
|
||||
}
|
||||
|
||||
if (kstat_read(kc, ks, NULL) < 0) {
|
||||
if (kstat_read(kc, ks, nullptr) < 0) {
|
||||
return "kstat_read() failed";
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
}
|
||||
|
||||
ks = kstat_lookup(kc, "unix", -1, "system_misc");
|
||||
if (ks && kstat_read(kc, ks, NULL) >= 0) {
|
||||
if (ks && kstat_read(kc, ks, nullptr) >= 0) {
|
||||
kstat_named_t* kn = kstat_data_lookup(ks, "ncpus");
|
||||
if (kn) {
|
||||
cpu->coresLogical = cpu->coresOnline = (uint16_t) kn->value.ui32;
|
||||
@@ -145,10 +145,10 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
cpu->coresPhysical = countTypeId(kc, "core_id");
|
||||
|
||||
if (options->temp) {
|
||||
if (detectCPUTempByKstat(options, kc, cpu) != NULL) {
|
||||
if (detectCPUTempByKstat(options, kc, cpu) != nullptr) {
|
||||
detectCPUTempByIpmiTool(cpu);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include <wchar.h>
|
||||
|
||||
static inline void ffPerfCloseQueryHandle(HANDLE* phQuery) {
|
||||
if (*phQuery != NULL) {
|
||||
if (*phQuery != nullptr) {
|
||||
PerfCloseQueryHandle(*phQuery);
|
||||
*phQuery = NULL;
|
||||
*phQuery = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
|
||||
};
|
||||
|
||||
if (options->tempSensor.length > 0) {
|
||||
if (!NT_SUCCESS(RtlUTF8ToUnicodeN(querySpec.Name, (ULONG) sizeof(querySpec.Name), NULL, options->tempSensor.chars, (ULONG) options->tempSensor.length + 1))) {
|
||||
if (!NT_SUCCESS(RtlUTF8ToUnicodeN(querySpec.Name, (ULONG) sizeof(querySpec.Name), nullptr, options->tempSensor.chars, (ULONG) options->tempSensor.length + 1))) {
|
||||
return "Invalid temp sensor string";
|
||||
}
|
||||
}
|
||||
|
||||
DWORD dataSize = 0;
|
||||
if (PerfEnumerateCounterSetInstances(NULL, &querySpec.Identifier.CounterSetGuid, NULL, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
|
||||
if (PerfEnumerateCounterSetInstances(nullptr, &querySpec.Identifier.CounterSetGuid, nullptr, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
|
||||
return "PerfEnumerateCounterSetInstances() failed";
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
|
||||
|
||||
{
|
||||
FF_AUTO_FREE PERF_INSTANCE_HEADER* const pHead = malloc(dataSize);
|
||||
if (PerfEnumerateCounterSetInstances(NULL, &querySpec.Identifier.CounterSetGuid, pHead, dataSize, &dataSize) != ERROR_SUCCESS) {
|
||||
if (PerfEnumerateCounterSetInstances(nullptr, &querySpec.Identifier.CounterSetGuid, pHead, dataSize, &dataSize) != ERROR_SUCCESS) {
|
||||
return "PerfEnumerateCounterSetInstances() failed to get instance headers";
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
|
||||
}
|
||||
|
||||
FF_A_CLEANUP(ffPerfCloseQueryHandle)
|
||||
HANDLE hQuery = NULL;
|
||||
HANDLE hQuery = nullptr;
|
||||
|
||||
if (PerfOpenQueryHandle(NULL, &hQuery) != ERROR_SUCCESS) {
|
||||
if (PerfOpenQueryHandle(nullptr, &hQuery) != ERROR_SUCCESS) {
|
||||
return "PerfOpenQueryHandle() failed";
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
|
||||
return "PerfAddCounters() reports invalid identifier";
|
||||
}
|
||||
|
||||
if (PerfQueryCounterData(hQuery, NULL, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
|
||||
return "PerfQueryCounterData(NULL) failed";
|
||||
if (PerfQueryCounterData(hQuery, nullptr, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
|
||||
return "PerfQueryCounterData(nullptr) failed";
|
||||
}
|
||||
|
||||
if (dataSize <= sizeof(PERF_DATA_HEADER) + sizeof(PERF_COUNTER_HEADER)) { // PERF_ERROR_RETURN, should not happen
|
||||
@@ -135,7 +135,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
|
||||
pCounterData = (PERF_COUNTER_DATA*) ((BYTE*) pCounterData + pCounterData->dwSize);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 7.5
|
||||
@@ -213,7 +213,7 @@ static const char* detectMaxSpeedBySmbios(FFCPUResult* cpu) {
|
||||
|
||||
cpu->frequencyMax = speed;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static uint32_t getNumLogicalCores(const SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr) {
|
||||
@@ -233,9 +233,9 @@ static uint32_t getNumLogicalCores(const SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
|
||||
static const char* detectNCores(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
LOGICAL_PROCESSOR_RELATIONSHIP lpr = RelationAll;
|
||||
ULONG length = 0;
|
||||
NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), NULL, 0, &length);
|
||||
NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), nullptr, 0, &length);
|
||||
if (length == 0) {
|
||||
return "GetLogicalProcessorInformationEx(RelationAll, NULL, &length) failed";
|
||||
return "GetLogicalProcessorInformationEx(RelationAll, nullptr, &length) failed";
|
||||
}
|
||||
|
||||
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
|
||||
@@ -276,13 +276,13 @@ static const char* detectNCores(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* detectByRegistry(FFCPUResult* cpu) {
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = NULL;
|
||||
if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL)) {
|
||||
return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, NULL) failed";
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
|
||||
if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, nullptr)) {
|
||||
return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, nullptr) failed";
|
||||
}
|
||||
|
||||
if (ffRegReadValues(hKey, 3, (FFRegValueArg[]){
|
||||
@@ -290,13 +290,13 @@ static const char* detectByRegistry(FFCPUResult* cpu) {
|
||||
FF_ARG(cpu->vendor, L"VendorIdentifier"),
|
||||
FF_ARG(cpu->frequencyBase, L"~MHz"),
|
||||
},
|
||||
NULL)) {
|
||||
nullptr)) {
|
||||
ffStrbufTrimRightSpace(&cpu->vendor);
|
||||
} else {
|
||||
return "ffRegReadValues() failed for CPU registry key";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
@@ -317,5 +317,5 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
detectThermalTemp(options, &cpu->temperature);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1311,7 +1311,7 @@ bool ffCPUDetectX86Specific(FFCPUResult* cpu) {
|
||||
int32_t xmodel = (eax >> 16) & 0xF;
|
||||
int32_t ext_model = model + (xmodel << 4);
|
||||
|
||||
const struct match_entry_t* matchtable = NULL;
|
||||
const struct match_entry_t* matchtable = nullptr;
|
||||
uint32_t count = 0;
|
||||
|
||||
if (ffStrbufEqualS(&cpu->vendor, "GenuineIntel")) {
|
||||
@@ -1327,7 +1327,7 @@ bool ffCPUDetectX86Specific(FFCPUResult* cpu) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const FFCPUX86MatchEntry* bestEntry = NULL;
|
||||
const FFCPUX86MatchEntry* bestEntry = nullptr;
|
||||
int32_t bestScore = -1;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
|
||||
Reference in New Issue
Block a user