Global: replaces NULL to nullptr

This commit is contained in:
李通洲
2026-07-10 18:08:04 +08:00
parent 873454191f
commit ba18705d2e
387 changed files with 2411 additions and 2411 deletions
+30 -30
View File
@@ -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