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
+3 -3
View File
@@ -6,7 +6,7 @@
const char* ffDetectSwap(FFlist* result) {
struct xsw_usage xsw;
size_t size = sizeof(xsw);
if (sysctl((int[]) { CTL_VM, VM_SWAPUSAGE }, 2, &xsw, &size, NULL, 0) != 0) {
if (sysctl((int[]) { CTL_VM, VM_SWAPUSAGE }, 2, &xsw, &size, nullptr, 0) != 0) {
return "Failed to read vm.swapusage";
}
@@ -15,7 +15,7 @@ const char* ffDetectSwap(FFlist* result) {
// "vm.compressor_mode" no longer exists in macOS 26.0
} else {
if (ffSysctlGetInt("vm.compressor_mode", 4) <= 2) {
return NULL; // Swap is disabled
return nullptr; // Swap is disabled
}
}
}
@@ -24,5 +24,5 @@ const char* ffDetectSwap(FFlist* result) {
ffStrbufInitStatic(&swap->name, xsw.xsu_encrypted ? "Encrypted" : "Normal");
swap->bytesTotal = xsw.xsu_total;
swap->bytesUsed = xsw.xsu_used;
return NULL;
return nullptr;
}
+5 -5
View File
@@ -25,7 +25,7 @@ static void addSwapEntry(FFlist* result, struct xswdev* xsw, uint32_t pageSize)
const char* ffDetectSwap(FFlist* result) {
struct xswdev xsws[32];
size_t size = sizeof(xsws);
if (sysctlbyname("vm.swap_info_array", xsws, &size, NULL, 0) < 0) {
if (sysctlbyname("vm.swap_info_array", xsws, &size, nullptr, 0) < 0) {
return "sysctlbyname(\"vm.swap_info_array\") failed";
}
@@ -33,7 +33,7 @@ const char* ffDetectSwap(FFlist* result) {
size_t count = size / sizeof(struct xswdev);
if (count == 0) {
return NULL;
return nullptr;
}
if (xsws->xsw_version != XSWDEV_VERSION) {
@@ -44,7 +44,7 @@ const char* ffDetectSwap(FFlist* result) {
addSwapEntry(result, &xsws[i], pageSize);
}
return NULL;
return nullptr;
}
#elif __FreeBSD__
@@ -62,7 +62,7 @@ const char* ffDetectSwap(FFlist* result) {
mib[mibsize] = n;
struct xswdev xsw;
size_t size = sizeof(xsw);
if (sysctl(mib, (uint32_t) (mibsize + 1), &xsw, &size, NULL, 0) < 0) {
if (sysctl(mib, (uint32_t) (mibsize + 1), &xsw, &size, nullptr, 0) < 0) {
break;
}
if (xsw.xsw_version != XSWDEV_VERSION) {
@@ -72,7 +72,7 @@ const char* ffDetectSwap(FFlist* result) {
addSwapEntry(result, &xsw, pageSize);
}
return NULL;
return nullptr;
}
#endif
+2 -2
View File
@@ -14,7 +14,7 @@ const char* ffDetectSwap(FFlist* result) {
ffStrbufInitStatic(&swap->name, "System");
void* kvms = load_driver_settings("virtual_memory"); // /boot/home/config/settings/kernel/drivers/virtual_memory
if (kvms) {
const char* swapAuto = get_driver_parameter(kvms, "swap_auto", NULL, NULL);
const char* swapAuto = get_driver_parameter(kvms, "swap_auto", nullptr, nullptr);
if (swapAuto) {
ffStrbufSetStatic(&swap->name, swapAuto[0] == 'y' ? "Auto" : "Manual");
}
@@ -23,5 +23,5 @@ const char* ffDetectSwap(FFlist* result) {
swap->bytesTotal = pageSize * (uint64_t) info.max_swap_pages;
swap->bytesUsed = pageSize * (uint64_t) (info.max_swap_pages - info.free_swap_pages);
return NULL;
return nullptr;
}
+10 -10
View File
@@ -17,13 +17,13 @@ static const char* detectByProcMeminfo(FFlist* result) {
uint64_t swapTotal = 0, swapFree = 0;
char* token = NULL;
if ((token = strstr(buf, "SwapTotal:")) != NULL) {
swapTotal = strtoul(token + strlen("SwapTotal:"), NULL, 10);
char* token = nullptr;
if ((token = strstr(buf, "SwapTotal:")) != nullptr) {
swapTotal = strtoul(token + strlen("SwapTotal:"), nullptr, 10);
}
if ((token = strstr(buf, "SwapFree:")) != NULL) {
swapFree = strtoul(token + strlen("SwapFree:"), NULL, 10);
if ((token = strstr(buf, "SwapFree:")) != nullptr) {
swapFree = strtoul(token + strlen("SwapFree:"), nullptr, 10);
}
FFSwapResult* swap = FF_LIST_ADD(FFSwapResult, *result);
@@ -31,7 +31,7 @@ static const char* detectByProcMeminfo(FFlist* result) {
swap->bytesTotal = swapTotal * 1024lu;
swap->bytesUsed = (swapTotal - swapFree) * 1024lu;
return NULL;
return nullptr;
}
static const char* detectByProcSwaps(FFlist* result) {
@@ -59,7 +59,7 @@ static const char* detectByProcSwaps(FFlist* result) {
for (size_t i = 0; i < nameLen; ++i) {
if (name[i] == '\\') {
char octal[4] = { name[i + 1], name[i + 2], name[i + 3], '\0' };
ffStrbufAppendC(&swap->name, (char) strtol(octal, NULL, 8));
ffStrbufAppendC(&swap->name, (char) strtol(octal, nullptr, 8));
i += 3;
} else {
ffStrbufAppendC(&swap->name, name[i]);
@@ -71,12 +71,12 @@ static const char* detectByProcSwaps(FFlist* result) {
line = memchr(line, '\n', (size_t) (nRead - (line - buf)));
}
return NULL;
return nullptr;
}
const char* ffDetectSwap(FFlist* result) {
if (detectByProcSwaps(result) == NULL) {
return NULL;
if (detectByProcSwaps(result) == nullptr) {
return nullptr;
}
return detectByProcMeminfo(result);
}
+2 -2
View File
@@ -13,7 +13,7 @@ const char* ffDetectSwap(FFlist* result) {
return "swapctl(SWAP_NSWAP) failed";
}
if (nswap == 0) {
return NULL;
return nullptr;
}
FF_AUTO_FREE struct swapent* swdev = malloc((uint32_t) nswap * sizeof(*swdev));
@@ -31,5 +31,5 @@ const char* ffDetectSwap(FFlist* result) {
}
}
return NULL;
return nullptr;
}
+1 -1
View File
@@ -28,5 +28,5 @@ const char* ffDetectSwap(FFlist* result) {
swap->bytesUsed = swap->bytesTotal - (uint64_t) table->swt_ent[i].ste_free * pageSize;
}
return NULL;
return nullptr;
}
+2 -2
View File
@@ -15,7 +15,7 @@ const char* ffDetectSwap(FFlist* result) {
}
if (size == 0) {
return NULL;
return nullptr;
}
uint32_t pageSize = instance.state.platform.sysinfo.pageSize;
@@ -31,5 +31,5 @@ const char* ffDetectSwap(FFlist* result) {
break;
}
}
return NULL;
return nullptr;
}