mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -18,7 +18,7 @@ void ffPrepareCPUUsage(void) {
|
||||
}
|
||||
|
||||
const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result) {
|
||||
const char* error = NULL;
|
||||
const char* error = nullptr;
|
||||
if (startTime == 0) {
|
||||
ffListInit(&cpuTimes1);
|
||||
error = ffGetCpuUsageInfo(&cpuTimes1);
|
||||
@@ -70,5 +70,5 @@ retry:
|
||||
cpuTime1->totalAll = cpuTime2->totalAll;
|
||||
}
|
||||
startTime = ffTimeGetNow();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -29,5 +29,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
}
|
||||
|
||||
vm_deallocate(mach_task_self(), (vm_address_t) cpuInfo, numCpuInfo * sizeof(integer_t));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
#else
|
||||
int ctls[] = { CTL_KERN, KERN_CP_TIME };
|
||||
#endif
|
||||
if (sysctl(ctls, 2, NULL, &neededLength, NULL, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
|
||||
if (sysctl(ctls, 2, nullptr, &neededLength, nullptr, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, nullptr) failed";
|
||||
}
|
||||
#else
|
||||
if (sysctlbyname("kern.cp_times", NULL, &neededLength, NULL, 0) != 0) {
|
||||
return "sysctlbyname(kern.cp_times, NULL) failed";
|
||||
if (sysctlbyname("kern.cp_times", nullptr, &neededLength, nullptr, 0) != 0) {
|
||||
return "sysctlbyname(kern.cp_times, nullptr) failed";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,11 +33,11 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
FF_AUTO_FREE uint64_t (*cpTimes)[CPUSTATES] = malloc(neededLength);
|
||||
|
||||
#if __OpenBSD__ || __NetBSD__
|
||||
if (sysctl(ctls, 2, cpTimes, &neededLength, NULL, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
|
||||
if (sysctl(ctls, 2, cpTimes, &neededLength, nullptr, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, nullptr) failed";
|
||||
}
|
||||
#else
|
||||
if (sysctlbyname("kern.cp_times", cpTimes, &neededLength, NULL, 0) != 0) {
|
||||
if (sysctlbyname("kern.cp_times", cpTimes, &neededLength, nullptr, 0) != 0) {
|
||||
return "sysctlbyname(kern.cp_times, cpTime) failed";
|
||||
}
|
||||
#endif
|
||||
@@ -54,5 +54,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
};
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
info->totalAll = uptime;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
buf[nRead] = '\0';
|
||||
|
||||
// Skip first line
|
||||
char* start = NULL;
|
||||
if ((start = strchr(buf, '\n')) == NULL) {
|
||||
char* start = nullptr;
|
||||
if ((start = strchr(buf, '\n')) == nullptr) {
|
||||
return "skip first line failed";
|
||||
}
|
||||
++start;
|
||||
|
||||
uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0;
|
||||
char* token = NULL;
|
||||
char* token = nullptr;
|
||||
while ((token = strchr(start, '\n'))) {
|
||||
if (sscanf(start, "cpu%*d%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%*[^\n]\n", &user, &nice, &system, &idle, &iowait, &irq, &softirq) == 7) {
|
||||
uint64_t inUse = user + nice + system + irq + softirq;
|
||||
@@ -42,5 +42,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
start = token + 1;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
}
|
||||
|
||||
for (int i = 0;; ++i) {
|
||||
kstat_t* ks = kstat_lookup(kc, "cpu_stat", i, NULL);
|
||||
kstat_t* ks = kstat_lookup(kc, "cpu_stat", i, nullptr);
|
||||
|
||||
cpu_stat_t cs;
|
||||
if (!ks || kstat_read(kc, ks, &cs) < 0) {
|
||||
@@ -34,5 +34,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
.totalAll = total,
|
||||
};
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
static const char* getInfoByNqsi(FFlist* cpuTimes) {
|
||||
ULONG size = 0;
|
||||
if (NtQuerySystemInformation(SystemProcessorPerformanceInformation, NULL, 0, &size) != STATUS_INFO_LENGTH_MISMATCH) {
|
||||
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, NULL) failed";
|
||||
if (NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr, 0, &size) != STATUS_INFO_LENGTH_MISMATCH) {
|
||||
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr) failed";
|
||||
}
|
||||
|
||||
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* FF_AUTO_FREE pinfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*) malloc(size);
|
||||
@@ -35,13 +35,13 @@ static const char* getInfoByNqsi(FFlist* cpuTimes) {
|
||||
};
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
static HANDLE hQuery = NULL;
|
||||
static HANDLE hQuery = nullptr;
|
||||
|
||||
if (hQuery == NULL) {
|
||||
if (hQuery == nullptr) {
|
||||
struct FFPerfQuerySpec {
|
||||
PERF_COUNTER_IDENTIFIER Identifier;
|
||||
WCHAR Name[16];
|
||||
@@ -57,7 +57,7 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
.Name = PERF_WILDCARD_INSTANCE,
|
||||
};
|
||||
|
||||
if (PerfOpenQueryHandle(NULL, &hQuery) != ERROR_SUCCESS) {
|
||||
if (PerfOpenQueryHandle(nullptr, &hQuery) != ERROR_SUCCESS) {
|
||||
PerfCloseQueryHandle(hQuery);
|
||||
hQuery = INVALID_HANDLE_VALUE;
|
||||
return "PerfOpenQueryHandle() failed";
|
||||
@@ -81,8 +81,8 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
}
|
||||
|
||||
DWORD dataSize = 0;
|
||||
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)) {
|
||||
@@ -133,7 +133,7 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
pCounterData = (PERF_COUNTER_DATA*) ((BYTE*) pCounterData + pCounterData->dwSize);
|
||||
}
|
||||
|
||||
if (wcschr(instanceName, L'_') == NULL /* ignore `_Total` */) {
|
||||
if (wcschr(instanceName, L'_') == nullptr /* ignore `_Total` */) {
|
||||
if (processorUtility == UINT64_MAX) {
|
||||
return "Counter \"% Processor Utility\" are not supported";
|
||||
}
|
||||
@@ -148,17 +148,17 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
pInstanceHeader = (PERF_INSTANCE_HEADER*) pCounterData;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
const char* error = NULL;
|
||||
const char* error = nullptr;
|
||||
|
||||
if (ffIsWindows10OrGreater()) {
|
||||
error = getInfoByPerflib(cpuTimes);
|
||||
FF_DEBUG("Get CPU usage info by Perflib: %s", error ?: "success");
|
||||
if (!error) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
ffListClear(cpuTimes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user