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:
@@ -15,7 +15,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) {
|
||||
|
||||
size_t length = 0;
|
||||
FF_AUTO_FREE struct kinfo_proc* processes = ffSysctlGetData(request, requestLength, &length);
|
||||
if (processes == NULL) {
|
||||
if (processes == nullptr) {
|
||||
return "sysctl(CTL_KERN, KERN_PROC, KERN_PROC_ALL) failed";
|
||||
}
|
||||
assert(length % sizeof(struct kinfo_proc) == 0);
|
||||
@@ -68,7 +68,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) {
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNUSED FFWMOptions* options) {
|
||||
@@ -90,5 +90,5 @@ const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNU
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+27
-27
@@ -52,7 +52,7 @@ static const char* getHyprland(FFstrbuf* result) {
|
||||
ffStrbufSubstrBeforeFirstC(result, '"');
|
||||
ffStrbufTrimLeft(result, 'v');
|
||||
FF_DEBUG("Extracted version from version.h: %s", result->chars);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
FF_DEBUG("Failed to extract version from version.h");
|
||||
ffStrbufClear(result);
|
||||
@@ -70,11 +70,11 @@ static const char* getHyprland(FFstrbuf* result) {
|
||||
ffBinaryExtractStrings(buffer.chars, extractHyprlandVersion, result, (uint32_t) strlen("v0.0.0"));
|
||||
if (result->length > 0) {
|
||||
FF_DEBUG("Extracted version from binary strings: %s", result->chars);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
FF_DEBUG("Failed to extract version from binary strings, trying --version option");
|
||||
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { buffer.chars, "--version", NULL }) == NULL) {
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { buffer.chars, "--version", nullptr }) == nullptr) {
|
||||
// Hyprland 0.48.1 built from branch at commit 29e2e59...
|
||||
// Date: ...
|
||||
// Tag: v0.48.1, commits: 5937
|
||||
@@ -90,7 +90,7 @@ static const char* getHyprland(FFstrbuf* result) {
|
||||
ffStrbufSubstrBeforeFirstC(result, ' ');
|
||||
FF_DEBUG("Extracted version from output: %s", result->chars);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
FF_DEBUG("Failed to run Hyprland --version command");
|
||||
|
||||
@@ -126,12 +126,12 @@ static const char* getSway(FFstrbuf* result) {
|
||||
|
||||
ffBinaryExtractStrings(path.chars, extractSwayVersion, result, (uint32_t) strlen("sway version 0.0.0"));
|
||||
if (result->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) { path.chars, "--version", NULL }) == NULL) { // sway version 1.10
|
||||
return extractSwayVersion(buffer.chars, buffer.length, result) ? "Failed to parse sway version output" : NULL;
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) { path.chars, "--version", nullptr }) == nullptr) { // sway version 1.10
|
||||
return extractSwayVersion(buffer.chars, buffer.length, result) ? "Failed to parse sway version output" : nullptr;
|
||||
}
|
||||
|
||||
return "Failed to run command `sway --version`";
|
||||
@@ -146,24 +146,24 @@ static const char* getLabwc(FFstrbuf* result) {
|
||||
|
||||
ffBinaryExtractStrings(path.chars, extractCommonWmVersion, result, (uint32_t) strlen("0.0.0"));
|
||||
if (result->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", NULL }) == NULL) { // labwc 0.9.0 (+xwayland +nls +rsvg +libsfdo)
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", nullptr }) == nullptr) { // labwc 0.9.0 (+xwayland +nls +rsvg +libsfdo)
|
||||
ffStrbufSubstrAfterFirstC(result, ' ');
|
||||
ffStrbufSubstrBeforeFirstC(result, ' ');
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return "Failed to run command `labwc --version`";
|
||||
}
|
||||
|
||||
static const char* getNiri(FFstrbuf* result) {
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { "niri", "--version", NULL }) == NULL) { // niri 25.11 (commit b35bcae)
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { "niri", "--version", nullptr }) == nullptr) { // niri 25.11 (commit b35bcae)
|
||||
ffStrbufSubstrAfterFirstC(result, ' ');
|
||||
ffStrbufSubstrBeforeLastC(result, '(');
|
||||
ffStrbufTrimRightSpace(result);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return "Failed to run command `niri --version`";
|
||||
@@ -176,10 +176,10 @@ static const char* getWeston(FFstrbuf* result) {
|
||||
return "Failed to find weston executable path";
|
||||
}
|
||||
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", NULL }) == NULL) { // weston 8.0.0\n...
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", nullptr }) == nullptr) { // weston 8.0.0\n...
|
||||
ffStrbufSubstrBeforeFirstC(result, '\n');
|
||||
ffStrbufSubstrAfterLastC(result, ' ');
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return "Failed to run command `weston --version`";
|
||||
@@ -204,7 +204,7 @@ static const char* getWslg(FFstrbuf* result) {
|
||||
return "Failed to parse WSLg version from /mnt/wslg/versions.txt";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -230,13 +230,13 @@ static const char* getI3(FFstrbuf* result) {
|
||||
|
||||
ffBinaryExtractStrings(path.chars, extractI3Version, result, (uint32_t) strlen("0.0"));
|
||||
if (result->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", NULL }) == NULL) { // i3 version 1.10 C 2009...
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", nullptr }) == nullptr) { // i3 version 1.10 C 2009...
|
||||
ffStrbufSubstrAfterFirstS(result, "version ");
|
||||
ffStrbufSubstrBeforeFirstC(result, ' ');
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return "Failed to run command `i3 --version`";
|
||||
@@ -251,13 +251,13 @@ static const char* getCtwm(FFstrbuf* result) {
|
||||
|
||||
ffBinaryExtractStrings(path.chars, extractCommonWmVersion, result, (uint32_t) strlen("0.0.0"));
|
||||
if (result->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", NULL }) == NULL) { // ctwm version 4.0.1\n...
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", nullptr }) == nullptr) { // ctwm version 4.0.1\n...
|
||||
ffStrbufSubstrBeforeFirstC(result, '\n');
|
||||
ffStrbufSubstrAfterLastC(result, ' ');
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return "Failed to run command `ctwm --version`";
|
||||
@@ -272,13 +272,13 @@ static const char* getFvwm(FFstrbuf* result) {
|
||||
|
||||
ffBinaryExtractStrings(path.chars, extractCommonWmVersion, result, (uint32_t) strlen("0.0.0"));
|
||||
if (result->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "-version", NULL }) == NULL) { // [FVWM][main]: fvwm Version 2.2.5\n...
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "-version", nullptr }) == nullptr) { // [FVWM][main]: fvwm Version 2.2.5\n...
|
||||
ffStrbufSubstrBeforeFirstC(result, '\n');
|
||||
ffStrbufSubstrAfterLastC(result, ' ');
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return "Failed to run command `fvwm -version`";
|
||||
@@ -293,13 +293,13 @@ static const char* getOpenbox(FFstrbuf* result) {
|
||||
|
||||
ffBinaryExtractStrings(path.chars, extractCommonWmVersion, result, (uint32_t) strlen("0.0.0"));
|
||||
if (result->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", NULL }) == NULL) { // Openbox 3.6.1\n...
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { path.chars, "--version", nullptr }) == nullptr) { // Openbox 3.6.1\n...
|
||||
ffStrbufSubstrBeforeFirstC(result, '\n');
|
||||
ffStrbufSubstrAfterLastC(result, ' ');
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return "Failed to run command `openbox --version`";
|
||||
|
||||
@@ -42,15 +42,15 @@ static bool verifySignature(const wchar_t* filePath) {
|
||||
.dwProvFlags = WTD_SAFER_FLAG,
|
||||
};
|
||||
|
||||
LONG status = ffWinVerifyTrustEx(NULL, &actionID, &trustData);
|
||||
LONG status = ffWinVerifyTrustEx(nullptr, &actionID, &trustData);
|
||||
trustData.dwStateAction = WTD_STATEACTION_CLOSE;
|
||||
ffWinVerifyTrustEx(NULL, &actionID, &trustData);
|
||||
ffWinVerifyTrustEx(nullptr, &actionID, &trustData);
|
||||
|
||||
return status == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static bool isProcessTrusted(DWORD processId, FFProcessType processType, UNICODE_STRING* buffer, size_t bufSize) {
|
||||
FF_AUTO_CLOSE_FD HANDLE hProcess = NULL;
|
||||
FF_AUTO_CLOSE_FD HANDLE hProcess = nullptr;
|
||||
if (!NT_SUCCESS(NtOpenProcess(&hProcess, PROCESS_QUERY_LIMITED_INFORMATION, &(OBJECT_ATTRIBUTES) {
|
||||
.Length = sizeof(OBJECT_ATTRIBUTES),
|
||||
},
|
||||
@@ -63,14 +63,14 @@ static bool isProcessTrusted(DWORD processId, FFProcessType processType, UNICODE
|
||||
buffer->Length == 0) {
|
||||
return false;
|
||||
}
|
||||
assert(buffer->MaximumLength >= buffer->Length + 2); // NULL terminated
|
||||
assert(buffer->MaximumLength >= buffer->Length + 2); // nullptr terminated
|
||||
|
||||
if (processType & FF_PROCESS_TYPE_WINDOWS_STORE) {
|
||||
static wchar_t windowsAppsPath[MAX_PATH];
|
||||
static uint32_t windowsAppsPathLen;
|
||||
if (windowsAppsPathLen == 0) {
|
||||
PWSTR pPath = NULL;
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, NULL, &pPath))) {
|
||||
PWSTR pPath = nullptr;
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, nullptr, &pPath))) {
|
||||
windowsAppsPathLen = (uint32_t) wcslen(pPath);
|
||||
memcpy(windowsAppsPath, pPath, windowsAppsPathLen * sizeof(wchar_t));
|
||||
memcpy(windowsAppsPath + windowsAppsPathLen, L"\\WindowsApps\\", sizeof(L"\\WindowsApps\\"));
|
||||
@@ -117,7 +117,7 @@ static bool isProcessTrusted(DWORD processId, FFProcessType processType, UNICODE
|
||||
const char* ffDetectWMPlugin(FFstrbuf* pluginName) {
|
||||
alignas(UNICODE_STRING) uint8_t buffer[4096];
|
||||
UNICODE_STRING* filePath = (UNICODE_STRING*) buffer;
|
||||
SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = NULL;
|
||||
SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = nullptr;
|
||||
|
||||
// Multiple attempts in case processes change while
|
||||
// we are in the middle of querying them.
|
||||
@@ -138,11 +138,11 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) {
|
||||
}
|
||||
|
||||
for (SYSTEM_PROCESS_INFORMATION* ptr = pstart;; ptr = (SYSTEM_PROCESS_INFORMATION*) ((uint8_t*) ptr + ptr->NextEntryOffset)) {
|
||||
assert(ptr->ImageName.Length == 0 || ptr->ImageName.MaximumLength >= ptr->ImageName.Length + 2); // NULL terminated
|
||||
assert(ptr->ImageName.Length == 0 || ptr->ImageName.MaximumLength >= ptr->ImageName.Length + 2); // nullptr terminated
|
||||
if (ptr->ImageName.Length == strlen("FancyWM-GUI.exe") * sizeof(wchar_t) &&
|
||||
ffStrEqualNWS(ptr->ImageName.Buffer, "FancyWM-GUI.exe") &&
|
||||
isProcessTrusted((DWORD) (uintptr_t) ptr->UniqueProcessId, FF_PROCESS_TYPE_WINDOWS_STORE | FF_PROCESS_TYPE_GUI, filePath, sizeof(buffer))) {
|
||||
if (instance.config.general.detectVersion && ffGetFileVersion(filePath->Buffer, NULL, pluginName)) {
|
||||
if (instance.config.general.detectVersion && ffGetFileVersion(filePath->Buffer, nullptr, pluginName)) {
|
||||
ffStrbufPrependS(pluginName, "FancyWM ");
|
||||
} else {
|
||||
ffStrbufSetStatic(pluginName, "FancyWM");
|
||||
@@ -151,7 +151,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) {
|
||||
} else if (ptr->ImageName.Length == strlen("glazewm-watcher.exe") * sizeof(wchar_t) &&
|
||||
ffStrEqualNWS(ptr->ImageName.Buffer, "glazewm-watcher.exe") &&
|
||||
isProcessTrusted((DWORD) (uintptr_t) ptr->UniqueProcessId, FF_PROCESS_TYPE_SIGNED | FF_PROCESS_TYPE_GUI, filePath, sizeof(buffer))) {
|
||||
if (instance.config.general.detectVersion && ffGetFileVersion(filePath->Buffer, NULL, pluginName)) {
|
||||
if (instance.config.general.detectVersion && ffGetFileVersion(filePath->Buffer, nullptr, pluginName)) {
|
||||
ffStrbufPrependS(pluginName, "GlazeWM ");
|
||||
} else {
|
||||
ffStrbufSetStatic(pluginName, "GlazeWM");
|
||||
@@ -165,8 +165,8 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) {
|
||||
if (ffProcessAppendStdOut(pluginName, (char* const[]) {
|
||||
path.chars,
|
||||
"--version",
|
||||
NULL,
|
||||
}) == NULL) {
|
||||
nullptr,
|
||||
}) == nullptr) {
|
||||
ffStrbufSubstrBeforeFirstC(pluginName, '\n');
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNUSED FFWMOptions* options) {
|
||||
@@ -190,15 +190,15 @@ const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNU
|
||||
}
|
||||
|
||||
if (ffStrbufEqualS(wmName, "dwm.exe")) {
|
||||
PWSTR pPath = NULL;
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_System, KF_FLAG_DEFAULT, NULL, &pPath))) {
|
||||
PWSTR pPath = nullptr;
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_System, KF_FLAG_DEFAULT, nullptr, &pPath))) {
|
||||
wchar_t fullPath[MAX_PATH];
|
||||
wcscpy(fullPath, pPath);
|
||||
wcscat(fullPath, L"\\dwm.exe");
|
||||
ffGetFileVersion(fullPath, NULL, result);
|
||||
ffGetFileVersion(fullPath, nullptr, result);
|
||||
}
|
||||
CoTaskMemFree(pPath);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user