diff --git a/src/common/FFlist.h b/src/common/FFlist.h index b409c6d4b..cdd9a6da4 100644 --- a/src/common/FFlist.h +++ b/src/common/FFlist.h @@ -23,13 +23,13 @@ bool ffListPop(FFlist* list, uint32_t elementSize, void* __restrict result); static inline void ffListInit(FFlist* list) { list->capacity = 0; list->length = 0; - list->data = NULL; + list->data = nullptr; } static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity) { ffListInit(list); list->capacity = capacity; - list->data = __builtin_expect(capacity == 0, 0) ? NULL : (uint8_t*) malloc((size_t) capacity * elementSize); + list->data = __builtin_expect(capacity == 0, 0) ? nullptr : (uint8_t*) malloc((size_t) capacity * elementSize); } FF_A_NODISCARD static inline FFlist ffListCreate() { @@ -87,7 +87,7 @@ static inline void ffListDestroy(FFlist* list) { // Avoid free-after-use. These 3 assignments are cheap so don't remove them list->capacity = list->length = 0; free(list->data); - list->data = NULL; + list->data = nullptr; } static inline void ffListClear(FFlist* list) { diff --git a/src/common/FFstrbuf.h b/src/common/FFstrbuf.h index 4c89b9a32..fff933a1d 100644 --- a/src/common/FFstrbuf.h +++ b/src/common/FFstrbuf.h @@ -90,7 +90,7 @@ void ffStrbufLowerCase(FFstrbuf* strbuf); // Function alters the buffer to extract lines or delimited segments (replaces the delimiter with '\0') // so that buffer MUST be heap allocated (NOT a static string) -// `lineptr` must be `NULL` and `n` MUST be `0` for the first call +// `lineptr` must be `nullptr` and `n` MUST be `0` for the first call // Caller MUST NOT free `*lineptr` bool ffStrbufGetdelim(char** lineptr, size_t* n, char delimiter, FFstrbuf* buffer); void ffStrbufGetdelimRestore(char** lineptr, size_t* n, char delimiter, FFstrbuf* buffer); @@ -103,7 +103,7 @@ void ffStrbufGetdelimRestore(char** lineptr, size_t* n, char delimiter, FFstrbuf * @param[in,out] lineptr The pointer to a pointer that will be set to the start of the line (points to buffer's internal memory address to avoid memory allocation and copy). MUST NOT be freed by the caller, unlike `getline(3)`. - * MUST be NULL for the first call. + * MUST be nullptr for the first call. * @param[in,out] n The pointer to the size of the buffer of lineptr. MUST be 0 for the first call. * @param[in] buffer The buffer to read from. @@ -186,7 +186,7 @@ static inline void ffStrbufDestroy(FFstrbuf* strbuf) { } FF_A_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) { - assert(strbuf != NULL); + assert(strbuf != nullptr); if (strbuf->allocated == 0) { return 0; } @@ -210,7 +210,7 @@ static inline void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free) { static inline void ffStrbufClear(FFstrbuf* strbuf) { - assert(strbuf != NULL); + assert(strbuf != nullptr); extern char* CHAR_NULL_PTR; if (strbuf->allocated == 0) { @@ -244,7 +244,7 @@ static inline void ffStrbufAppendNC(FFstrbuf* strbuf, uint32_t num, char c) { } static inline void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value) { - if (__builtin_expect(value == NULL || length == 0, false)) { + if (__builtin_expect(value == nullptr || length == 0, false)) { return; } if (__builtin_expect(ffStrbufGetFree(strbuf) < length, false)) { @@ -258,7 +258,7 @@ static inline void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const cha static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value) { assert(value != strbuf); - if (value == NULL) { + if (value == nullptr) { return; } ffStrbufAppendNS(strbuf, value->length, value->chars); @@ -269,9 +269,9 @@ static inline void ffStrbufRecalculateLength(FFstrbuf* strbuf) { } static inline void ffStrbufSetS(FFstrbuf* strbuf, const char* value) { - assert(strbuf != NULL); + assert(strbuf != nullptr); - if (value == NULL) { + if (value == nullptr) { ffStrbufClear(strbuf); } else { ffStrbufSetNS(strbuf, (uint32_t) strlen(value), value); @@ -279,7 +279,7 @@ static inline void ffStrbufSetS(FFstrbuf* strbuf, const char* value) { } static inline bool ffStrbufSetJsonVal(FFstrbuf* strbuf, yyjson_val* jsonVal) { - assert(strbuf != NULL); + assert(strbuf != nullptr); if (yyjson_is_str(jsonVal)) { ffStrbufSetNS(strbuf, (uint32_t) unsafe_yyjson_get_len(jsonVal), unsafe_yyjson_get_str(jsonVal)); @@ -291,7 +291,7 @@ static inline bool ffStrbufSetJsonVal(FFstrbuf* strbuf, yyjson_val* jsonVal) { } static inline void ffStrbufAppendS(FFstrbuf* strbuf, const char* value) { - if (value == NULL) { + if (value == nullptr) { return; } ffStrbufAppendNS(strbuf, (uint32_t) strlen(value), value); @@ -339,7 +339,7 @@ static inline void ffStrbufSetStatic(FFstrbuf* strbuf, const char* value) { free(strbuf->chars); } - if (value != NULL) { + if (value != nullptr) { ffStrbufInitStatic(strbuf, value); } else { ffStrbufInit(strbuf); @@ -374,14 +374,14 @@ FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) { } static inline void ffStrbufPrepend(FFstrbuf* strbuf, FFstrbuf* value) { - if (value == NULL) { + if (value == nullptr) { return; } ffStrbufPrependNS(strbuf, value->length, value->chars); } static inline void ffStrbufPrependS(FFstrbuf* strbuf, const char* value) { - if (value == NULL) { + if (value == nullptr) { return; } ffStrbufPrependNS(strbuf, (uint32_t) strlen(value), value); @@ -421,11 +421,11 @@ static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, c } static inline FF_A_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c) { - return memchr(strbuf->chars, c, strbuf->length) != NULL; + return memchr(strbuf->chars, c, strbuf->length) != nullptr; } static inline FF_A_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) { - return strstr(strbuf->chars, str) != NULL; + return strstr(strbuf->chars, str) != nullptr; } static inline FF_A_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) { @@ -433,7 +433,7 @@ static inline FF_A_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const } static inline FF_A_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) { - return strcasestr(strbuf->chars, str) != NULL; + return strcasestr(strbuf->chars, str) != nullptr; } static inline FF_A_NODISCARD bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) { diff --git a/src/common/apple/cf_helpers.c b/src/common/apple/cf_helpers.c index 60e1a1c59..87ea2bbb1 100644 --- a/src/common/apple/cf_helpers.c +++ b/src/common/apple/cf_helpers.c @@ -5,13 +5,13 @@ const char* ffCfNumGetInt64(CFTypeRef cf, int64_t* result) { if (!CFNumberGetValue((CFNumberRef) cf, kCFNumberSInt64Type, result)) { return "Number type is not SInt64"; } - return NULL; + return nullptr; } else if (CFGetTypeID(cf) == CFDataGetTypeID()) { if (CFDataGetLength((CFDataRef) cf) != sizeof(int64_t)) { return "Data length is not sizeof(int64_t)"; } CFDataGetBytes((CFDataRef) cf, CFRangeMake(0, sizeof(int64_t)), (uint8_t*) result); - return NULL; + return nullptr; } return "TypeID is neither 'CFNumber' nor 'CFData'"; @@ -22,13 +22,13 @@ const char* ffCfNumGetInt(CFTypeRef cf, int32_t* result) { if (!CFNumberGetValue((CFNumberRef) cf, kCFNumberSInt32Type, result)) { return "Number type is not SInt32"; } - return NULL; + return nullptr; } else if (CFGetTypeID(cf) == CFDataGetTypeID()) { if (CFDataGetLength((CFDataRef) cf) != sizeof(*result)) { return "Data length is not sizeof(int32_t)"; } CFDataGetBytes((CFDataRef) cf, CFRangeMake(0, sizeof(*result)), (uint8_t*) result); - return NULL; + return nullptr; } return "TypeID is neither 'CFNumber' nor 'CFData'"; @@ -40,7 +40,7 @@ const char* ffCfNumGetDouble(CFTypeRef cf, double* result) { !CFNumberGetValue((CFNumberRef) cf, kCFNumberFloatType, result)) { return "Number type is not Double or Float"; } - return NULL; + return nullptr; } return "TypeID is neither 'CFNumber'"; @@ -54,13 +54,13 @@ const char* ffCfDateGetEpoch(CFTypeRef cf, uint64_t* result) { CFAbsoluteTime absTime = CFDateGetAbsoluteTime((CFDateRef) cf); // Convert from seconds to milliseconds and add the difference between 1970 and 2001 in milliseconds *result = (uint64_t) ((absTime + 978307200 /*kCFAbsoluteTimeIntervalSince1970*/) * 1000); - return NULL; + return nullptr; } const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result) { ffStrbufClear(result); if (!cf) { - return NULL; + return nullptr; } if (CFGetTypeID(cf) == CFStringGetTypeID()) { @@ -72,7 +72,7 @@ const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result) { } else { uint32_t length = (uint32_t) CFStringGetLength(cfStr); if (length == 0) { - return NULL; + return nullptr; } ffStrbufEnsureFixedLengthFree(result, (uint32_t) CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8)); if (!CFStringGetCString(cfStr, result->chars, result->allocated, kCFStringEncodingUTF8)) { @@ -86,7 +86,7 @@ const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result) { CFDataRef cfData = (CFDataRef) cf; uint32_t length = (uint32_t) CFDataGetLength(cfData); if (length == 0) { - return NULL; + return nullptr; } ffStrbufEnsureFixedLengthFree(result, length + 1); CFDataGetBytes(cfData, CFRangeMake(0, length), (uint8_t*) result->chars); @@ -96,20 +96,20 @@ const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result) { return "TypeID is neither 'CFString' nor 'CFData'"; } - return NULL; + return nullptr; } const char* ffCfDataGetDataAsString(CFTypeRef cf, FFstrbuf* result) { ffStrbufClear(result); if (!cf) { - return NULL; + return nullptr; } if (CFGetTypeID(cf) == CFDataGetTypeID()) { CFDataRef cfData = (CFDataRef) cf; uint32_t length = (uint32_t) CFDataGetLength(cfData); if (length == 0) { - return NULL; + return nullptr; } ffStrbufEnsureFixedLengthFree(result, length + 1); CFDataGetBytes(cfData, CFRangeMake(0, length), (uint8_t*) result->chars); @@ -119,12 +119,12 @@ const char* ffCfDataGetDataAsString(CFTypeRef cf, FFstrbuf* result) { return "TypeID is not 'CFData'"; } - return NULL; + return nullptr; } const char* ffCfDictGetString(CFDictionaryRef dict, CFStringRef key, FFstrbuf* result) { CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key); - if (cf == NULL) { + if (cf == nullptr) { return "CFDictionaryGetValue() failed"; } @@ -133,7 +133,7 @@ const char* ffCfDictGetString(CFDictionaryRef dict, CFStringRef key, FFstrbuf* r const char* ffCfDictGetDataAsString(CFDictionaryRef dict, CFStringRef key, FFstrbuf* result) { CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key); - if (cf == NULL) { + if (cf == nullptr) { return "CFDictionaryGetValue() failed"; } @@ -142,7 +142,7 @@ const char* ffCfDictGetDataAsString(CFDictionaryRef dict, CFStringRef key, FFstr const char* ffCfDictGetBool(CFDictionaryRef dict, CFStringRef key, bool* result) { CFBooleanRef cf = (CFBooleanRef) CFDictionaryGetValue(dict, key); - if (cf == NULL) { + if (cf == nullptr) { return "CFDictionaryGetValue() failed"; } @@ -151,12 +151,12 @@ const char* ffCfDictGetBool(CFDictionaryRef dict, CFStringRef key, bool* result) } *result = CFBooleanGetValue(cf); - return NULL; + return nullptr; } const char* ffCfDictGetInt(CFDictionaryRef dict, CFStringRef key, int* result) { CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key); - if (cf == NULL) { + if (cf == nullptr) { return "CFDictionaryGetValue() failed"; } @@ -165,7 +165,7 @@ const char* ffCfDictGetInt(CFDictionaryRef dict, CFStringRef key, int* result) { const char* ffCfDictGetInt64(CFDictionaryRef dict, CFStringRef key, int64_t* result) { CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key); - if (cf == NULL) { + if (cf == nullptr) { return "CFDictionaryGetValue() failed"; } @@ -174,7 +174,7 @@ const char* ffCfDictGetInt64(CFDictionaryRef dict, CFStringRef key, int64_t* res const char* ffCfDictGetDouble(CFDictionaryRef dict, CFStringRef key, double* result) { CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key); - if (cf == NULL) { + if (cf == nullptr) { return "CFDictionaryGetValue() failed"; } @@ -183,7 +183,7 @@ const char* ffCfDictGetDouble(CFDictionaryRef dict, CFStringRef key, double* res const char* ffCfDictGetData(CFDictionaryRef dict, CFStringRef key, uint32_t offset, uint32_t size, uint8_t* result, uint32_t* length) { CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key); - if (cf == NULL) { + if (cf == nullptr) { return "CFDictionaryGetValue() failed"; } @@ -202,22 +202,22 @@ const char* ffCfDictGetData(CFDictionaryRef dict, CFStringRef key, uint32_t offs } CFDataGetBytes((CFDataRef) cf, CFRangeMake(offset, size), result); - return NULL; + return nullptr; } const char* ffCfDictGetDict(CFDictionaryRef dict, CFStringRef key, CFDictionaryRef* result) { CFDictionaryRef cf = (CFDictionaryRef) CFDictionaryGetValue(dict, key); - if (cf == NULL || CFGetTypeID(cf) != CFDictionaryGetTypeID()) { + if (cf == nullptr || CFGetTypeID(cf) != CFDictionaryGetTypeID()) { return "TypeID is not 'CFDictionary'"; } *result = cf; - return NULL; + return nullptr; } const char* ffCfDictGetDateAsEpoch(CFDictionaryRef dict, CFStringRef key, uint64_t* result) { CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key); - if (cf == NULL) { + if (cf == nullptr) { return "CFDictionaryGetValue() failed"; } diff --git a/src/common/apple/cf_helpers.h b/src/common/apple/cf_helpers.h index a929f030e..6801668d4 100644 --- a/src/common/apple/cf_helpers.h +++ b/src/common/apple/cf_helpers.h @@ -4,7 +4,7 @@ #include #include -// Return error info if failed, NULL otherwise +// Return error info if failed, nullptr otherwise const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result); const char* ffCfNumGetInt(CFTypeRef cf, int32_t* result); const char* ffCfNumGetInt64(CFTypeRef cf, int64_t* result); diff --git a/src/common/apple/smc_temps.c b/src/common/apple/smc_temps.c index 6669c3125..74b792925 100644 --- a/src/common/apple/smc_temps.c +++ b/src/common/apple/smc_temps.c @@ -86,7 +86,7 @@ static const char* smcCall(io_connect_t conn, uint32_t selector, SmcKeyData_t* i if (IOConnectCallStructMethod(conn, selector, inputStructure, size, outputStructure, &size) != kIOReturnSuccess) { return "IOConnectCallStructMethod(conn) failed"; } - return NULL; + return nullptr; } // Provides key info, using a cache to dramatically improve the energy impact of smcFanControl @@ -103,7 +103,7 @@ static const char* smcGetKeyInfo(io_connect_t conn, const uint32_t key, SmcKeyDa } *key_info = outputStructure.keyInfo; - return NULL; + return nullptr; } static const char* smcReadSmcVal(io_connect_t conn, const UInt32Char_t key, SmcVal_t* val) { @@ -130,7 +130,7 @@ static const char* smcReadSmcVal(io_connect_t conn, const UInt32Char_t key, SmcV memcpy(val->bytes, outputStructure.bytes, sizeof(outputStructure.bytes)); - return NULL; + return nullptr; } static const char* smcOpen(io_connect_t* conn) { @@ -143,13 +143,13 @@ static const char* smcOpen(io_connect_t* conn) { return "IOServiceOpen() failed"; } - return NULL; + return nullptr; } static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, double* value) { SmcVal_t val = { 0 }; const char* error = smcReadSmcVal(conn, key, &val); - if (error != NULL) { + if (error != nullptr) { return error; } if (val.dataSize == 0) { @@ -270,7 +270,7 @@ static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl default: return "Unsupported SMC data type"; } - return NULL; + return nullptr; } static bool detectTemp(io_connect_t conn, const char* sensor, double* sum) { @@ -291,7 +291,7 @@ static io_connect_t conn; const char* ffDetectSmcSpecificTemp(const char* sensor, double* result) { if (!conn) { - if (smcOpen(&conn) != NULL) { + if (smcOpen(&conn) != nullptr) { conn = (io_connect_t) -1; } } @@ -303,12 +303,12 @@ const char* ffDetectSmcSpecificTemp(const char* sensor, double* result) { return "Could not read SMC temperature"; } - return NULL; + return nullptr; } const char* ffDetectSmcTemps(enum FFTempType type, double* result) { if (!conn) { - if (smcOpen(&conn) != NULL) { + if (smcOpen(&conn) != nullptr) { conn = (io_connect_t) -1; } } @@ -461,5 +461,5 @@ const char* ffDetectSmcTemps(enum FFTempType type, double* result) { *result /= count; - return NULL; + return nullptr; } diff --git a/src/common/binary.h b/src/common/binary.h index 2d2d7849b..b4580e7a0 100644 --- a/src/common/binary.h +++ b/src/common/binary.h @@ -11,7 +11,7 @@ * @param userdata User-provided data passed to the callback function * @param minLength Minimum length of strings to extract * - * @return NULL on success, error message on failure. + * @return nullptr on success, error message on failure. * @note This function won't return an error if no strings are found. * Always check if strings are correctly extracted after this function all. */ diff --git a/src/common/dbus.h b/src/common/dbus.h index e0689c3fe..0c9850ff1 100644 --- a/src/common/dbus.h +++ b/src/common/dbus.h @@ -26,7 +26,7 @@ typedef struct FFDBusData { DBusConnection* connection; } FFDBusData; -const char* ffDBusLoadData(DBusBusType busType, FFDBusData* data); // Returns an error message or NULL on success +const char* ffDBusLoadData(DBusBusType busType, FFDBusData* data); // Returns an error message or nullptr on success bool ffDBusGetString(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result); bool ffDBusGetBool(FFDBusData* dbus, DBusMessageIter* iter, bool* result); bool ffDBusGetUint(FFDBusData* dbus, DBusMessageIter* iter, uint64_t* result); @@ -38,7 +38,7 @@ bool ffDBusGetPropertyUint(FFDBusData* dbus, const char* busName, const char* ob void ffDBusDestroyData(FFDBusData* data); static inline DBusMessage* ffDBusGetAllProperties(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface) { - return ffDBusGetMethodReply(dbus, busName, objectPath, "org.freedesktop.DBus.Properties", "GetAll", interface, NULL); + return ffDBusGetMethodReply(dbus, busName, objectPath, "org.freedesktop.DBus.Properties", "GetAll", interface, nullptr); } #define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData) diff --git a/src/common/debug.h b/src/common/debug.h index d79c48880..ee7f4be04 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -6,11 +6,11 @@ static inline const char* ffFindFileName(const char* file) { const char* lastSlash = __builtin_strrchr(file, '/'); #ifdef _WIN32 - if (lastSlash == NULL) { + if (lastSlash == nullptr) { lastSlash = __builtin_strrchr(file, '\\'); } #endif - if (lastSlash != NULL) { + if (lastSlash != nullptr) { return lastSlash + 1; } return file; diff --git a/src/common/font.h b/src/common/font.h index f9d25e7fd..cdb8b200e 100644 --- a/src/common/font.h +++ b/src/common/font.h @@ -21,5 +21,5 @@ void ffFontInitWithSpace(FFfont* font, const char* rawName); void ffFontDestroy(FFfont* font); static inline void ffFontInitCopy(FFfont* font, const char* name) { - ffFontInitValues(font, name, NULL); + ffFontInitValues(font, name, nullptr); } diff --git a/src/common/impl/FFPlatform_unix.c b/src/common/impl/FFPlatform_unix.c index 3b9c87db7..ec2ef1699 100644 --- a/src/common/impl/FFPlatform_unix.c +++ b/src/common/impl/FFPlatform_unix.c @@ -57,7 +57,7 @@ static void getExePath(FFPlatform* platform) { 4, exePath, &exePathLen, - NULL, + nullptr, 0) < 0) exePathLen = 0; else { @@ -68,7 +68,7 @@ static void getExePath(FFPlatform* platform) { // Current implementation uses argv[0], which can be easily spoofed. // See #2195 size_t exePathLen = 0; - kvm_t* kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL); + kvm_t* kd = kvm_openfiles(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr); if (kd) { int kpCount; struct kinfo_proc* kp = kvm_getprocs(kd, KERN_PROC_PID, (pid_t) platform->pid, sizeof(*kp), &kpCount); @@ -77,7 +77,7 @@ static void getExePath(FFPlatform* platform) { if (argv && argv[0]) { char* arg0 = argv[0]; if (arg0[0]) { - if (strchr(arg0, '/') != NULL) // likely a path (absolute or relative) + if (strchr(arg0, '/') != nullptr) // likely a path (absolute or relative) { exePathLen = strlen(arg0); if (exePathLen < ARRAY_SIZE(exePath)) { @@ -88,7 +88,7 @@ static void getExePath(FFPlatform* platform) { } } else { FF_STRBUF_AUTO_DESTROY tmpPath = ffStrbufCreate(); - if (ffFindExecutableInPath(arg0, &tmpPath) == NULL && tmpPath.length < ARRAY_SIZE(exePath)) { + if (ffFindExecutableInPath(arg0, &tmpPath) == nullptr && tmpPath.length < ARRAY_SIZE(exePath)) { memcpy(exePath, tmpPath.chars, tmpPath.length + 1); exePathLen = tmpPath.length; } @@ -282,7 +282,7 @@ static void getSysinfo(FFPlatformSysinfo* info, const struct utsname* uts) { #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) size_t length = sizeof(info->pageSize); - sysctl((int[]) { CTL_HW, HW_PAGESIZE }, 2, &info->pageSize, &length, NULL, 0); + sysctl((int[]) { CTL_HW, HW_PAGESIZE }, 2, &info->pageSize, &length, nullptr, 0); #else info->pageSize = (uint32_t) sysconf(_SC_PAGESIZE); #endif @@ -290,7 +290,7 @@ static void getSysinfo(FFPlatformSysinfo* info, const struct utsname* uts) { static void getCwd(FFPlatform* platform) { char cwd[PATH_MAX]; - if (getcwd(cwd, sizeof(cwd)) != NULL) { + if (getcwd(cwd, sizeof(cwd)) != nullptr) { ffStrbufSetS(&platform->cwd, cwd); ffStrbufEnsureEndsWithC(&platform->cwd, '/'); } diff --git a/src/common/impl/FFPlatform_windows.c b/src/common/impl/FFPlatform_windows.c index b07e9c8c9..dea4c2deb 100644 --- a/src/common/impl/FFPlatform_windows.c +++ b/src/common/impl/FFPlatform_windows.c @@ -21,10 +21,10 @@ static void getExePath(FFPlatform* platform) { ffGetPeb()->ProcessParameters->ImagePathName.Buffer, GENERIC_READ, FILE_SHARE_READ, - NULL, + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, - NULL); + nullptr); if (hPath != INVALID_HANDLE_VALUE) { DWORD len = GetFinalPathNameByHandleW(hPath, exePathW, MAX_PATH, FILE_NAME_NORMALIZED); if (len > 0 && len < MAX_PATH) { @@ -44,8 +44,8 @@ static void getExePath(FFPlatform* platform) { } static void getHomeDir(FFPlatform* platform) { - PWSTR pPath = NULL; - if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_Profile, KF_FLAG_DEFAULT, NULL, &pPath))) { + PWSTR pPath = nullptr; + if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_Profile, KF_FLAG_DEFAULT, nullptr, &pPath))) { ffStrbufSetWS(&platform->homeDir, pPath); ffStrbufReplaceAllC(&platform->homeDir, '\\', '/'); ffStrbufEnsureEndsWithC(&platform->homeDir, '/'); @@ -58,8 +58,8 @@ static void getHomeDir(FFPlatform* platform) { } static void getCacheDir(FFPlatform* platform) { - PWSTR pPath = NULL; - if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_LocalAppData, KF_FLAG_DEFAULT, NULL, &pPath))) { + PWSTR pPath = nullptr; + if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr, &pPath))) { ffStrbufSetWS(&platform->cacheDir, pPath); ffStrbufReplaceAllC(&platform->cacheDir, '\\', '/'); ffStrbufEnsureEndsWithC(&platform->cacheDir, '/'); @@ -71,8 +71,8 @@ static void getCacheDir(FFPlatform* platform) { } static void platformPathAddKnownFolder(FFlist* dirs, REFKNOWNFOLDERID folderId) { - PWSTR pPath = NULL; - if (SUCCEEDED(SHGetKnownFolderPath(folderId, KF_FLAG_DEFAULT, NULL, &pPath))) { + PWSTR pPath = nullptr; + if (SUCCEEDED(SHGetKnownFolderPath(folderId, KF_FLAG_DEFAULT, nullptr, &pPath))) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateWS(pPath); CoTaskMemFree(pPath); ffStrbufReplaceAllC(&buffer, '\\', '/'); @@ -107,7 +107,7 @@ static void getConfigDirs(FFPlatform* platform) { if (getenv("MSYSTEM")) { // We are in MSYS2 / Git Bash platformPathAddEnvSuffix(&platform->configDirs, "HOME", ".config/"); - platformPathAddEnvSuffix(&platform->configDirs, "HOME", NULL); + platformPathAddEnvSuffix(&platform->configDirs, "HOME", nullptr); platformPathAddEnvSuffix(&platform->configDirs, "MINGW_PREFIX", "etc"); } @@ -122,7 +122,7 @@ static void getDataDirs(FFPlatform* platform) { if (getenv("MSYSTEM") && getenv("HOME")) { // We are in MSYS2 / Git Bash platformPathAddEnvSuffix(&platform->dataDirs, "HOME", ".local/share/"); - platformPathAddEnvSuffix(&platform->dataDirs, "HOME", NULL); + platformPathAddEnvSuffix(&platform->dataDirs, "HOME", nullptr); platformPathAddEnvSuffix(&platform->dataDirs, "MINGW_PREFIX", "share"); } ffPlatformPathAddHome(&platform->dataDirs, platform, ".local/share/"); @@ -142,8 +142,8 @@ static void getUserName(FFPlatform* platform) { NTSYSAPI NTSTATUS NTAPI LsaGetUserName( _Outptr_ PLSA_UNICODE_STRING * UserName, _Outptr_opt_ PLSA_UNICODE_STRING * DomainName); - PLSA_UNICODE_STRING userName = NULL; - if (NT_SUCCESS(LsaGetUserName(&userName, NULL))) { + PLSA_UNICODE_STRING userName = nullptr; + if (NT_SUCCESS(LsaGetUserName(&userName, nullptr))) { ffStrbufSetNWS(&platform->userName, userName->Length / sizeof(wchar_t), userName->Buffer); RtlFreeUnicodeString(userName); // Required. userName.Buffer is allocated separately LsaFreeMemory(userName); @@ -187,18 +187,18 @@ static const char* detectWine(void) { const char* __cdecl wine_get_version(void); void* hntdll = ffLibraryGetModule(L"ntdll.dll"); if (!hntdll) { - return NULL; + return nullptr; } FF_LIBRARY_LOAD_SYMBOL_LAZY(hntdll, wine_get_version); if (!ffwine_get_version) { - return NULL; + return nullptr; } return ffwine_get_version(); } static void getSystemReleaseAndVersion(FFPlatformSysinfo* info) { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey, nullptr)) { return; } @@ -207,7 +207,7 @@ static void getSystemReleaseAndVersion(FFPlatformSysinfo* info) { FF_ARG(ubr, L"UBR"), FF_ARG(info->version, L"BuildLabEx"), }, - NULL); + nullptr); PPEB_FULL peb = ffGetPeb(); @@ -228,7 +228,7 @@ static void getSystemReleaseAndVersion(FFPlatformSysinfo* info) { static void getSystemPageSize(FFPlatformSysinfo* info) { SYSTEM_BASIC_INFORMATION sbi; - if (NT_SUCCESS(NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL))) { + if (NT_SUCCESS(NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), nullptr))) { info->pageSize = sbi.PhysicalPageSize; } else { info->pageSize = 4096; diff --git a/src/common/impl/FFstrbuf.c b/src/common/impl/FFstrbuf.c index 5b392eb8f..35747f8fe 100644 --- a/src/common/impl/FFstrbuf.c +++ b/src/common/impl/FFstrbuf.c @@ -20,9 +20,9 @@ void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate) { } void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments) { - assert(format != NULL); + assert(format != nullptr); - char* buffer = NULL; + char* buffer = nullptr; int len = vasprintf(&buffer, format, arguments); assert(len >= 0); @@ -32,7 +32,7 @@ void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments) { // Takes ownership of `heapStr`. The caller must not free `heapStr` after calling this // function; the memory will be managed and freed via the associated FFstrbuf. void ffStrbufInitMoveNS(FFstrbuf* strbuf, uint32_t length, char* heapStr) { - assert(heapStr != NULL); + assert(heapStr != nullptr); strbuf->length = length; size_t allocSize = ffMallocUsableSize(heapStr); @@ -116,7 +116,7 @@ void ffStrbufEnsureFixedLengthFree(FFstrbuf* strbuf, uint32_t free) { } void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int (*transformFunc)(int)) { - if (value == NULL) { + if (value == nullptr) { return; } @@ -134,7 +134,7 @@ void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int (*transfo } void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments) { - assert(format != NULL); + assert(format != nullptr); va_list copy; va_copy(copy, arguments); @@ -155,12 +155,12 @@ void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments) { } const char* ffStrbufAppendSUntilC(FFstrbuf* strbuf, const char* value, char until) { - if (value == NULL) { - return NULL; + if (value == nullptr) { + return nullptr; } const char* end = strchr(value, until); - if (end == NULL) { + if (end == nullptr) { ffStrbufAppendS(strbuf, value); } else { ffStrbufAppendNS(strbuf, (uint32_t) (end - value), value); @@ -169,7 +169,7 @@ const char* ffStrbufAppendSUntilC(FFstrbuf* strbuf, const char* value, char unti } void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...) { - assert(format != NULL); + assert(format != nullptr); va_list arguments; va_start(arguments, format); @@ -186,7 +186,7 @@ void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...) { } void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...) { - assert(format != NULL); + assert(format != nullptr); va_list arguments; va_start(arguments, format); @@ -195,7 +195,7 @@ void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...) { } void ffStrbufPrependNS(FFstrbuf* strbuf, uint32_t length, const char* value) { - if (value == NULL || length == 0) { + if (value == nullptr || length == 0) { return; } @@ -213,14 +213,14 @@ void ffStrbufPrependC(FFstrbuf* strbuf, char c) { } void ffStrbufSetNS(FFstrbuf* strbuf, uint32_t length, const char* value) { - assert(strbuf != NULL); + assert(strbuf != nullptr); if (length == 0) { ffStrbufClear(strbuf); return; } - assert(value != NULL); + assert(value != nullptr); if (strbuf->allocated <= length) { char* newBuf = malloc(sizeof(char) * (length + 1)); @@ -533,7 +533,7 @@ void ffStrbufAppendSInt(FFstrbuf* strbuf, int64_t value) { unsafe_yyjson_set_sint(&val, value); char* end = yyjson_write_number(&val, start); - assert(end != NULL); + assert(end != nullptr); strbuf->length += (uint32_t) (end - start); } @@ -546,7 +546,7 @@ void ffStrbufAppendUInt(FFstrbuf* strbuf, uint64_t value) { unsafe_yyjson_set_uint(&val, value); char* end = yyjson_write_number(&val, start); - assert(end != NULL); + assert(end != nullptr); strbuf->length += (uint32_t) (end - start); } @@ -713,7 +713,7 @@ bool ffStrbufMatchSeparatedNS(const FFstrbuf* strbuf, uint32_t compLength, const for (const char* p = comp; p < comp + compLength;) { const char* colon = memchr(p, separator, (size_t) (comp + compLength - p)); - if (colon == NULL) { + if (colon == nullptr) { uint32_t remainingLen = (uint32_t) (comp + compLength - p); return strbuf->length == remainingLen && memcmp(strbuf->chars, p, remainingLen) == 0; } @@ -741,7 +741,7 @@ bool ffStrbufMatchSeparatedIgnCaseNS(const FFstrbuf* strbuf, uint32_t compLength for (const char* p = comp; p < comp + compLength;) { const char* colon = memchr(p, separator, (size_t) (comp + compLength - p)); - if (colon == NULL) { + if (colon == nullptr) { uint32_t remainingLen = (uint32_t) (comp + compLength - p); return strbuf->length == remainingLen && strncasecmp(strbuf->chars, p, remainingLen) == 0; } diff --git a/src/common/impl/binary_apple.c b/src/common/impl/binary_apple.c index 84781693a..fce33246d 100644 --- a/src/common/impl/binary_apple.c +++ b/src/common/impl/binary_apple.c @@ -20,7 +20,7 @@ typedef struct { static inline void wrapMunmap(FFMemoryMapping* mapping) { assert(mapping); - if (mapping->data == NULL || mapping->data == MAP_FAILED) { + if (mapping->data == nullptr || mapping->data == MAP_FAILED) { return; } munmap((void*) mapping->data, mapping->length); @@ -31,12 +31,12 @@ static inline void wrapMunmap(FFMemoryMapping* mapping) { */ static inline const void* readData(const FFMemoryMapping* mapping, size_t size, off_t offset) { if (offset < 0) { - return NULL; + return nullptr; } size_t start = (size_t) offset; if (start > mapping->length || size > mapping->length - start) { - return NULL; + return nullptr; } return mapping->data + start; @@ -99,7 +99,7 @@ static bool handleMachSection(const FFMemoryMapping* mapping, const char* name, * @param userdata User data for the callback * @param minLength Minimum string length to extract * - * @return NULL on success, error message on failure + * @return nullptr on success, error message on failure */ static const char* dumpMachHeader(const FFMemoryMapping* mapping, off_t offset, bool is_64, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) { uint32_t ncmds; @@ -124,7 +124,7 @@ static const char* dumpMachHeader(const FFMemoryMapping* mapping, off_t offset, } off_t commandOffset = loadCommandsOffset; - const struct load_command* cmd = NULL; + const struct load_command* cmd = nullptr; for (uint32_t i = 0U; i < ncmds; i++, commandOffset += cmd->cmdsize) { cmd = readData(mapping, sizeof(*cmd), commandOffset); if (!cmd) { @@ -153,7 +153,7 @@ static const char* dumpMachHeader(const FFMemoryMapping* mapping, off_t offset, } if (!handleMachSection(mapping, section->sectname, (off_t) section->offset, (size_t) section->size, cb, userdata, minLength)) { - return NULL; + return nullptr; } } } else if (cmd->cmd == LC_SEGMENT) { @@ -174,13 +174,13 @@ static const char* dumpMachHeader(const FFMemoryMapping* mapping, off_t offset, } if (!handleMachSection(mapping, section->sectname, (off_t) section->offset, (size_t) section->size, cb, userdata, minLength)) { - return NULL; + return nullptr; } } } } - return NULL; + return nullptr; } /** @@ -195,7 +195,7 @@ static const char* dumpMachHeader(const FFMemoryMapping* mapping, off_t offset, * @param userdata User data for the callback * @param minLength Minimum string length to extract * - * @return NULL on success, error message on failure + * @return nullptr on success, error message on failure */ static const char* dumpFatHeader(const FFMemoryMapping* mapping, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) { const struct fat_header* headerRaw = readData(mapping, sizeof(struct fat_header), 0); @@ -274,7 +274,7 @@ const char* ffBinaryExtractStrings(const char* machoFile, bool (*cb)(const char* } FF_A_CLEANUP(wrapMunmap) FFMemoryMapping mapping = { - .data = mmap(NULL, (size_t) st.st_size, PROT_READ, MAP_PRIVATE, fd, 0), + .data = mmap(nullptr, (size_t) st.st_size, PROT_READ, MAP_PRIVATE, fd, 0), .length = (size_t) st.st_size, }; if (mapping.data == MAP_FAILED) { diff --git a/src/common/impl/binary_linux.c b/src/common/impl/binary_linux.c index 9a2421732..2d8d50b19 100644 --- a/src/common/impl/binary_linux.c +++ b/src/common/impl/binary_linux.c @@ -56,10 +56,10 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_strptr) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_end) - libelf = NULL; + libelf = nullptr; } - if (elfData.ffelf_end == NULL) { + if (elfData.ffelf_end == nullptr) { return "load libelf failed"; } @@ -69,8 +69,8 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s return "open() failed"; } - Elf* elf = elfData.ffelf_begin(fd, ELF_C_READ, NULL); - if (elf == NULL) { + Elf* elf = elfData.ffelf_begin(fd, ELF_C_READ, nullptr); + if (elf == nullptr) { return "elf_begin() failed"; } @@ -82,27 +82,27 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s } // Iterate through all sections, looking for .rodata which contains string literals - Elf_Scn* scn = NULL; - while ((scn = elfData.ffelf_nextscn(elf, scn)) != NULL) { + Elf_Scn* scn = nullptr; + while ((scn = elfData.ffelf_nextscn(elf, scn)) != nullptr) { // Try 64-bit section header first, then 32-bit if that fails Elf64_Shdr* shdr64 = elfData.ffelf64_getshdr(scn); - Elf32_Shdr* shdr32 = NULL; - if (shdr64 == NULL) { + Elf32_Shdr* shdr32 = nullptr; + if (shdr64 == nullptr) { shdr32 = elfData.ffelf32_getshdr(scn); - if (shdr32 == NULL) { + if (shdr32 == nullptr) { continue; } } // Get the section name and check if it's .rodata const char* name = elfData.ffelf_strptr(elf, shstrndx, shdr64 ? shdr64->sh_name : shdr32->sh_name); - if (name == NULL || !ffStrEquals(name, ".rodata")) { + if (name == nullptr || !ffStrEquals(name, ".rodata")) { continue; } // Get the section data - Elf_Data* data = elfData.ffelf_getdata(scn, NULL); - if (data == NULL) { + Elf_Data* data = elfData.ffelf_getdata(scn, nullptr); + if (data == nullptr) { continue; } @@ -131,7 +131,7 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s } elfData.ffelf_end(elf); - return NULL; + return nullptr; } #else diff --git a/src/common/impl/binary_windows.c b/src/common/impl/binary_windows.c index 918cad531..005389ff0 100644 --- a/src/common/impl/binary_windows.c +++ b/src/common/impl/binary_windows.c @@ -15,19 +15,19 @@ * Each string found is passed to the callback function for processing. */ const char* ffBinaryExtractStrings(const char* peFile, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) { - FF_AUTO_CLOSE_FD HANDLE hFile = CreateFileA(peFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + FF_AUTO_CLOSE_FD HANDLE hFile = CreateFileA(peFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { return "CreateFileA() failed"; } - FF_AUTO_CLOSE_FD HANDLE hSection = NULL; - if (!NT_SUCCESS(NtCreateSection(&hSection, SECTION_MAP_READ, NULL, NULL, PAGE_READONLY, SEC_COMMIT, hFile))) { + FF_AUTO_CLOSE_FD HANDLE hSection = nullptr; + if (!NT_SUCCESS(NtCreateSection(&hSection, SECTION_MAP_READ, nullptr, nullptr, PAGE_READONLY, SEC_COMMIT, hFile))) { return "NtCreateSection() failed"; } - PVOID base = NULL; + PVOID base = nullptr; SIZE_T viewSize = 0; - if (!NT_SUCCESS(NtMapViewOfSection(hSection, NtCurrentProcess(), &base, 0, 0, NULL, &viewSize, ViewUnmap, 0, PAGE_READONLY))) { + if (!NT_SUCCESS(NtMapViewOfSection(hSection, NtCurrentProcess(), &base, 0, 0, nullptr, &viewSize, ViewUnmap, 0, PAGE_READONLY))) { return "NtMapViewOfSection() failed"; } @@ -67,5 +67,5 @@ const char* ffBinaryExtractStrings(const char* peFile, bool (*cb)(const char* st } NtUnmapViewOfSection(NtCurrentProcess(), base); - return NULL; + return nullptr; } diff --git a/src/common/impl/commandoption.c b/src/common/impl/commandoption.c index 2f548dfad..bd80825c4 100644 --- a/src/common/impl/commandoption.c +++ b/src/common/impl/commandoption.c @@ -15,12 +15,12 @@ bool ffParseModuleOptions(const char* key, const char* value) { return false; } if (value && !*value) { - value = NULL; + value = nullptr; } for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(key[2]) - 'A']; *modules; ++modules) { FFModuleBaseInfo* baseInfo = *modules; const char* subKey = ffOptionTestPrefix(key, baseInfo->name); - if (subKey != NULL) { + if (subKey != nullptr) { if (subKey[0] == '\0' || subKey[0] == '-') // Key is exactly the module name or has a leading '-' { fprintf(stderr, "Error: unknown module key %s\n", key); @@ -64,7 +64,7 @@ bool ffParseModuleOptions(const char* key, const char* value) { } void ffPrepareCommandOption(FFdata* data) { - char* moduleType = NULL; + char* moduleType = nullptr; size_t moduleLen = 0; while (ffStrbufGetdelim(&moduleType, &moduleLen, ':', &data->structure)) { #define FF_IF_MODULE_MATCH(moduleNameConstant) if (moduleLen == strlen(moduleNameConstant) && ffStrEqualsIgnCase(moduleType, moduleNameConstant) && !ffStrbufSeparatedContainIgnCaseS(&data->structureDisabled, moduleNameConstant, ':')) @@ -177,7 +177,7 @@ static bool parseStructureCommand( if (ffStrEqualsIgnCase(line, baseInfo->name)) { uint8_t optionBuf[FF_OPTION_MAX_SIZE]; baseInfo->initOptions(optionBuf); - if (data->resultDoc != NULL) { + if (data->resultDoc != nullptr) { fn(data, baseInfo, optionBuf); } else { baseInfo->printModule(optionBuf); @@ -194,7 +194,7 @@ static bool parseStructureCommand( yyjson_mut_obj_add_str(doc, module, "type", line); yyjson_mut_obj_add_str(doc, module, "error", "Unknown module type"); } else { - ffPrintError(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, ""); + ffPrintError(line, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, ""); } return false; } @@ -203,7 +203,7 @@ void ffPrintCommandOption(FFdata* data) { // Parse the structure and call the modules int32_t thres = instance.config.display.stat; - char* moduleType = NULL; + char* moduleType = nullptr; size_t moduleLen = 0; while (ffStrbufGetdelim(&moduleType, &moduleLen, ':', &data->structure)) { if (ffStrbufSeparatedContainIgnCaseS(&data->structureDisabled, moduleType, ':')) { @@ -249,7 +249,7 @@ void ffMigrateCommandOptionToJsonc(FFdata* data) { ffStrbufAppendS(&data->structure, FASTFETCH_DATATEXT_STRUCTURE); // Cannot use `ffStrbufSetStatic` here because we will modify the string } - char* moduleType = NULL; + char* moduleType = nullptr; size_t moduleLen = 0; while (ffStrbufGetdelim(&moduleType, &moduleLen, ':', &data->structure)) { if (ffStrbufSeparatedContainIgnCaseS(&data->structureDisabled, moduleType, ':')) { diff --git a/src/common/impl/dbus.c b/src/common/impl/dbus.c index 473af2d20..ca20efb18 100644 --- a/src/common/impl/dbus.c +++ b/src/common/impl/dbus.c @@ -19,7 +19,7 @@ static bool loadLibSymbols(FFDBusLibrary* lib) { FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_unref, false) FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_connection_send_with_reply_and_block, false) FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_connection_unref, false) - dbus = NULL; // don't auto dlclose + dbus = nullptr; // don't auto dlclose return true; } @@ -33,27 +33,27 @@ static const FFDBusLibrary* loadLib(void) { loadSuccess = loadLibSymbols(&lib); } - return loadSuccess ? &lib : NULL; + return loadSuccess ? &lib : nullptr; } const char* ffDBusLoadData(DBusBusType busType, FFDBusData* data) { data->lib = loadLib(); - if (data->lib == NULL) { + if (data->lib == nullptr) { return "Failed to load DBus library"; } - data->connection = data->lib->ffdbus_bus_get(busType, NULL); - if (data->connection == NULL) { + data->connection = data->lib->ffdbus_bus_get(busType, nullptr); + if (data->connection == nullptr) { return "Failed to connect to DBus"; } - return NULL; + return nullptr; } void ffDBusDestroyData(FFDBusData* data) { - if (data->connection != NULL) { + if (data->connection != nullptr) { data->lib->ffdbus_connection_unref(data->connection); - data->connection = NULL; + data->connection = nullptr; } } @@ -61,7 +61,7 @@ bool ffDBusGetString(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result) int argType = dbus->lib->ffdbus_message_iter_get_arg_type(iter); if (argType == DBUS_TYPE_STRING || argType == DBUS_TYPE_OBJECT_PATH) { - const char* value = NULL; + const char* value = nullptr; dbus->lib->ffdbus_message_iter_get_basic(iter, &value); if (!ffStrSet(value)) { @@ -254,8 +254,8 @@ bool ffDBusGetInt(FFDBusData* dbus, DBusMessageIter* iter, int64_t* result) { DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* method, const char* arg1, const char* arg2) { DBusMessage* message = dbus->lib->ffdbus_message_new_method_call(busName, objectPath, interface, method); - if (message == NULL) { - return NULL; + if (message == nullptr) { + return nullptr; } if (arg1) { @@ -266,7 +266,7 @@ DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const c } } - DBusMessage* reply = dbus->lib->ffdbus_connection_send_with_reply_and_block(dbus->connection, message, instance.config.general.processingTimeout, NULL); + DBusMessage* reply = dbus->lib->ffdbus_connection_send_with_reply_and_block(dbus->connection, message, instance.config.general.processingTimeout, nullptr); dbus->lib->ffdbus_message_unref(message); @@ -275,8 +275,8 @@ DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const c DBusMessage* ffDBusGetProperty(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property) { DBusMessage* message = dbus->lib->ffdbus_message_new_method_call(busName, objectPath, "org.freedesktop.DBus.Properties", "Get"); - if (message == NULL) { - return NULL; + if (message == nullptr) { + return nullptr; } dbus->lib->ffdbus_message_append_args(message, @@ -286,7 +286,7 @@ DBusMessage* ffDBusGetProperty(FFDBusData* dbus, const char* busName, const char &property, DBUS_TYPE_INVALID); - DBusMessage* reply = dbus->lib->ffdbus_connection_send_with_reply_and_block(dbus->connection, message, instance.config.general.processingTimeout, NULL); + DBusMessage* reply = dbus->lib->ffdbus_connection_send_with_reply_and_block(dbus->connection, message, instance.config.general.processingTimeout, nullptr); dbus->lib->ffdbus_message_unref(message); @@ -295,7 +295,7 @@ DBusMessage* ffDBusGetProperty(FFDBusData* dbus, const char* busName, const char bool ffDBusGetPropertyString(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property, FFstrbuf* result) { DBusMessage* reply = ffDBusGetProperty(dbus, busName, objectPath, interface, property); - if (reply == NULL) { + if (reply == nullptr) { return false; } @@ -314,7 +314,7 @@ bool ffDBusGetPropertyString(FFDBusData* dbus, const char* busName, const char* bool ffDBusGetPropertyUint(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property, uint64_t* result) { DBusMessage* reply = ffDBusGetProperty(dbus, busName, objectPath, interface, property); - if (reply == NULL) { + if (reply == nullptr) { return false; } diff --git a/src/common/impl/debug_windows.c b/src/common/impl/debug_windows.c index a3fb7f3dc..6247ec437 100644 --- a/src/common/impl/debug_windows.c +++ b/src/common/impl/debug_windows.c @@ -10,12 +10,12 @@ const char* ffDebugWin32Error(DWORD errorCode) { wchar_t bufferW[256]; ULONG len = FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, (DWORD) errorCode, 0, bufferW, ARRAY_SIZE(bufferW), - NULL); + nullptr); if (len == 0) { snprintf(buffer, sizeof(buffer), "Unknown error code (%lu)", errorCode); diff --git a/src/common/impl/font.c b/src/common/impl/font.c index 93feff15c..681c24906 100644 --- a/src/common/impl/font.c +++ b/src/common/impl/font.c @@ -16,7 +16,7 @@ void ffFontInit(FFfont* font) { } static void strbufAppendNSExcludingC(FFstrbuf* strbuf, uint32_t length, const char* value, char exclude) { - if (value == NULL || length == 0) { + if (value == nullptr || length == 0) { return; } @@ -151,7 +151,7 @@ static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* altern ffStrStartsWithIgnCase(wordStart, "Black") || ffStrStartsWithIgnCase(wordStart, "Condensed") || ffStrStartsWithIgnCase(wordStart, "Expanded")) { - if (alternativeBuffer == NULL) { + if (alternativeBuffer == nullptr) { alternativeBuffer = FF_LIST_ADD(FFstrbuf, font->styles); ffStrbufInit(alternativeBuffer); } @@ -169,7 +169,7 @@ static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* altern return; } - if (alternativeBuffer != NULL) { + if (alternativeBuffer != nullptr) { strbufAppendNSExcludingC(alternativeBuffer, wordLength, wordStart, '-'); return; } @@ -184,7 +184,7 @@ void ffFontInitPango(FFfont* font, const char* data) { ffFontInit(font); while (*data != '\0' && *data != '`' && *data != '\\') { - fontPangoParseWord(&data, font, NULL); + fontPangoParseWord(&data, font, nullptr); } fontInitPretty(font); @@ -329,8 +329,8 @@ void ffFontInitXft(FFfont* font, const char* xft) { } // Try parse trailing "-" as size, otherwise entire head is name - const char* dashPos = NULL; - const char* sizeStart = NULL; + const char* dashPos = nullptr; + const char* sizeStart = nullptr; for (const char* q = headEnd; q > headStart;) { --q; @@ -488,7 +488,7 @@ void ffFontInitMoveValues(FFfont* font, FFstrbuf* name, FFstrbuf* size, FFstrbuf void ffFontInitWithSpace(FFfont* font, const char* rawName) { const char* pspace = strrchr(rawName, ' '); - if (pspace == NULL) { + if (pspace == nullptr) { ffFontInitCopy(font, rawName); return; } diff --git a/src/common/impl/format.c b/src/common/impl/format.c index db414bc5a..eb2ae57e5 100644 --- a/src/common/impl/format.c +++ b/src/common/impl/format.c @@ -78,7 +78,7 @@ static uint32_t getArgumentIndex(const char* placeholderValue, uint32_t numArgs, } if (firstChar >= '0' && firstChar <= '9') { - char* pEnd = NULL; + char* pEnd = nullptr; uint32_t result = (uint32_t) strtoul(placeholderValue, &pEnd, 10); if (result > numArgs) { return UINT32_MAX; @@ -109,7 +109,7 @@ static inline void appendInvalidPlaceholder(FFstrbuf* buffer, const char* start, } static inline bool formatArgSet(const FFformatarg* arg) { - return arg->value != NULL && ((arg->type == FF_ARG_TYPE_DOUBLE && *(double*) arg->value > 0.0) || (arg->type == FF_ARG_TYPE_FLOAT && *(float*) arg->value > 0.0) || (arg->type == FF_ARG_TYPE_INT && *(int32_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_STRBUF && ((FFstrbuf*) arg->value)->length > 0) || (arg->type == FF_ARG_TYPE_STRING && ffStrSet((char*) arg->value)) || (arg->type == FF_ARG_TYPE_UINT8 && *(uint8_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT16 && *(uint16_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT && *(uint32_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT64 && *(uint64_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_BOOL && *(bool*) arg->value) || (arg->type == FF_ARG_TYPE_LIST && ((FFlist*) arg->value)->length > 0)); + return arg->value != nullptr && ((arg->type == FF_ARG_TYPE_DOUBLE && *(double*) arg->value > 0.0) || (arg->type == FF_ARG_TYPE_FLOAT && *(float*) arg->value > 0.0) || (arg->type == FF_ARG_TYPE_INT && *(int32_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_STRBUF && ((FFstrbuf*) arg->value)->length > 0) || (arg->type == FF_ARG_TYPE_STRING && ffStrSet((char*) arg->value)) || (arg->type == FF_ARG_TYPE_UINT8 && *(uint8_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT16 && *(uint16_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT && *(uint32_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT64 && *(uint64_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_BOOL && *(bool*) arg->value) || (arg->type == FF_ARG_TYPE_LIST && ((FFlist*) arg->value)->length > 0)); } FF_A_UNUSED static inline void normalizeArgName(FFstrbuf* dst, const char* src) { @@ -131,7 +131,7 @@ FF_A_UNUSED static inline void normalizeArgName(FFstrbuf* dst, const char* src) #include "common/lua.h" static void appendLuaError(FFstrbuf* buffer, const char* prefix, lua_State* L) { - const char* err = lua_tolstring(L, -1, NULL); + const char* err = lua_tolstring(L, -1, nullptr); if (err) { const char* tmp = strchr(err, ':'); if (tmp) { @@ -228,12 +228,12 @@ static bool parseLuaString(FFstrbuf* buffer, const char* script, uint32_t script ffStrbufAppendS(buffer, "Lua result error: no result"); } else { // Convert first result to string - const char* res = lua_tolstring(L, 1, NULL); + const char* res = lua_tolstring(L, 1, nullptr); if (res) { ffStrbufAppendS(buffer, res); } else { - luaL_tolstring(L, 1, NULL); - const char* sval = lua_tolstring(L, -1, NULL); + luaL_tolstring(L, 1, nullptr); + const char* sval = lua_tolstring(L, -1, nullptr); if (sval) { ffStrbufAppendS(buffer, sval); } @@ -273,10 +273,10 @@ struct FFQuickJSData { static const char* loadQuickJSState(void) { if (qjsData.inited) { - if (qjsData.ctx == NULL) { + if (qjsData.ctx == nullptr) { return "QuickJS is not available"; } - return NULL; + return nullptr; } qjsData.inited = true; @@ -301,20 +301,20 @@ static const char* loadQuickJSState(void) { FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libqjs, qjsData, JS_FreeValue) qjsData.rt = qjsData.ffJS_NewRuntime(); - if (qjsData.rt == NULL) { + if (qjsData.rt == nullptr) { return "JS_NewRuntime() failed"; } qjsData.ctx = qjsData.ffJS_NewContext(qjsData.rt); - if (qjsData.ctx == NULL) { + if (qjsData.ctx == nullptr) { qjsData.ffJS_FreeRuntime(qjsData.rt); - qjsData.rt = NULL; + qjsData.rt = nullptr; return "JS_NewContext() failed"; } - libqjs = NULL; // don't close quickjs + libqjs = nullptr; // don't close quickjs - return NULL; + return nullptr; } static bool parseQuickJSString(FFstrbuf* buffer, const char* script, uint32_t scriptLen, uint32_t numArgs, const FFformatarg* arguments) { @@ -401,7 +401,7 @@ static bool parseQuickJSString(FFstrbuf* buffer, const char* script, uint32_t sc bool ret = false; if (JS_IsException(result)) { JSValue exc = qjsData.ffJS_GetException(ctx); - const char* message = qjsData.ffJS_ToCStringLen2(ctx, NULL, exc, false); + const char* message = qjsData.ffJS_ToCStringLen2(ctx, nullptr, exc, false); qjsData.ffJS_FreeValue(ctx, exc); ffStrbufAppendF(buffer, "Qjs runtime error: %s", message ?: "unknown"); if (message) { @@ -587,7 +587,7 @@ static bool parseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint3 // test for constant or env var, if so evaluate it if (firstChar == '$') { - char* pend = NULL; + char* pend = nullptr; int32_t indexSigned = (int32_t) strtol(placeholderValue.chars + 1, &pend, 10); if (pend == placeholderValue.chars + 1) { // treat placeholder as an environment variable @@ -620,7 +620,7 @@ static bool parseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint3 cSep = *pSep; *pSep = '\0'; } else { - pSep = NULL; + pSep = nullptr; } uint32_t index = getArgumentIndex(placeholderValue.chars, numArgs, arguments); @@ -646,7 +646,7 @@ static bool parseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint3 FF_STRBUF_AUTO_DESTROY trailingEscape = ffStrbufCreate(); skipAnsiEscape(&tempString, buffer, &trailingEscape); - char* pEnd = NULL; + char* pEnd = nullptr; int32_t start = (int32_t) strtol(pSep + 1, &pEnd, 10); if (start < 0) { start = (int32_t) tempString.length + start; @@ -680,7 +680,7 @@ static bool parseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint3 continue; } } else { - char* pEnd = NULL; + char* pEnd = nullptr; int32_t truncLength = (int32_t) strtol(pSep + 1, &pEnd, 10); if (*pEnd != '\0') { *pSep = cSep; diff --git a/src/common/impl/init.c b/src/common/impl/init.c index 95e6cfd76..3b167745c 100644 --- a/src/common/impl/init.c +++ b/src/common/impl/init.c @@ -123,26 +123,26 @@ void ffStart(void) { #ifdef _WIN32 SetErrorMode(SEM_FAILCRITICALERRORS); if (instance.config.display.noBuffer) { - setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stdout, nullptr, _IONBF, 0); } else { - setvbuf(stdout, NULL, _IOFBF, 4096); + setvbuf(stdout, nullptr, _IOFBF, 4096); } SetConsoleCtrlHandler(consoleHandler, TRUE); #else if (instance.config.display.noBuffer) { - setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stdout, nullptr, _IONBF, 0); } struct sigaction action; sigemptyset(&action.sa_mask); action.sa_flags = 0; action.sa_handler = exitSignalHandler; - sigaction(SIGINT, &action, NULL); - sigaction(SIGTERM, &action, NULL); - sigaction(SIGQUIT, &action, NULL); + sigaction(SIGINT, &action, nullptr); + sigaction(SIGTERM, &action, nullptr); + sigaction(SIGQUIT, &action, nullptr); sigset_t newmask; sigemptyset(&newmask); sigaddset(&newmask, SIGCHLD); - sigprocmask(SIG_BLOCK, &newmask, NULL); + sigprocmask(SIG_BLOCK, &newmask, nullptr); #endif // reset everything to default before we start printing diff --git a/src/common/impl/io_unix.c b/src/common/impl/io_unix.c index e60318611..a4d8273d3 100644 --- a/src/common/impl/io_unix.c +++ b/src/common/impl/io_unix.c @@ -22,8 +22,8 @@ static void createSubfolders(const char* fileName) { FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); - const char* token = NULL; - while ((token = strchr(fileName, '/')) != NULL) { + const char* token = nullptr; + while ((token = strchr(fileName, '/')) != nullptr) { ffStrbufAppendNS(&path, (uint32_t) (token - fileName + 1), fileName); mkdir(path.chars, S_IRWXU | S_IRGRP | S_IROTH); fileName = token + 1; @@ -119,7 +119,7 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out) { | GLOB_BRACE #endif , - NULL, + nullptr, &gb) != 0) return false; @@ -174,7 +174,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char* fd_set rd; FD_ZERO(&rd); FD_SET(ftty, &rd); - if (select(ftty + 1, &rd, NULL, NULL, &(struct timeval) { .tv_sec = FF_IO_TERM_RESP_WAIT_MS / 1000, .tv_usec = (FF_IO_TERM_RESP_WAIT_MS % 1000) * 1000 }) <= 0) { + if (select(ftty + 1, &rd, nullptr, nullptr, &(struct timeval) { .tv_sec = FF_IO_TERM_RESP_WAIT_MS / 1000, .tv_usec = (FF_IO_TERM_RESP_WAIT_MS % 1000) * 1000 }) <= 0) { return "select(/dev/tty) timeout or failed"; } } @@ -213,7 +213,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char* va_end(args); - return NULL; + return nullptr; } bool ffSuppressIO(bool suppress) { @@ -258,14 +258,14 @@ void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indenta } FF_AUTO_CLOSE_DIR DIR* dir = fdopendir(dfd); - if (dir == NULL) { + if (dir == nullptr) { close(dfd); return; // Should not happen } uint32_t folderLength = folder->length; - if (pretty && folderName != NULL) { + if (pretty && folderName != nullptr) { for (uint8_t i = 0; i < indentation - 1; i++) { fputs(" | ", stdout); } @@ -274,7 +274,7 @@ void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indenta struct dirent* entry; - while ((entry = readdir(dir)) != NULL) { + while ((entry = readdir(dir)) != nullptr) { if (entry->d_name[0] == '.') { // skip hidden files continue; } @@ -316,7 +316,7 @@ void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indenta void ffListFilesRecursively(const char* path, bool pretty) { FF_STRBUF_AUTO_DESTROY folder = ffStrbufCreateS(path); ffStrbufEnsureEndsWithC(&folder, '/'); - listFilesRecursively(folder.length, &folder, 0, NULL, pretty); + listFilesRecursively(folder.length, &folder, 0, nullptr, pretty); } FFNativeFD ffGetNullFD(void) { diff --git a/src/common/impl/io_windows.c b/src/common/impl/io_windows.c index e085bf2ca..ff78a14f1 100644 --- a/src/common/impl/io_windows.c +++ b/src/common/impl/io_windows.c @@ -20,10 +20,10 @@ static bool createSubfolders(wchar_t* fileName) { fileName, FILE_LIST_DIRECTORY | FILE_TRAVERSE | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + nullptr, OPEN_EXISTING, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_FLAG_BACKUP_SEMANTICS, - NULL); + nullptr); ptr[3] = saved; if (hRoot == INVALID_HANDLE_VALUE) { @@ -36,12 +36,12 @@ static bool createSubfolders(wchar_t* fileName) { // UNC path: \\server\share\... else if (ptr[0] == L'\\' && ptr[1] == L'\\') { wchar_t* serverEnd = wcschr(ptr + 2, L'\\'); - if (serverEnd == NULL) { + if (serverEnd == nullptr) { return false; } wchar_t* shareEnd = wcschr(serverEnd + 1, L'\\'); - if (shareEnd == NULL) { + if (shareEnd == nullptr) { return true; // no parent subfolder exists before file name } @@ -52,10 +52,10 @@ static bool createSubfolders(wchar_t* fileName) { fileName, FILE_LIST_DIRECTORY | FILE_TRAVERSE | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + nullptr, OPEN_EXISTING, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_FLAG_BACKUP_SEMANTICS, - NULL); + nullptr); *shareEnd = saved; if (hRoot == INVALID_HANDLE_VALUE) { @@ -73,10 +73,10 @@ static bool createSubfolders(wchar_t* fileName) { driveRoot, FILE_LIST_DIRECTORY | FILE_TRAVERSE | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + nullptr, OPEN_EXISTING, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_FLAG_BACKUP_SEMANTICS, - NULL); + nullptr); if (hRoot == INVALID_HANDLE_VALUE) { return false; } @@ -86,7 +86,7 @@ static bool createSubfolders(wchar_t* fileName) { while (true) { wchar_t* token = wcschr(ptr, L'\\'); - if (token == NULL) { + if (token == nullptr) { break; } @@ -113,12 +113,12 @@ static bool createSubfolders(wchar_t* fileName) { .Attributes = OBJ_CASE_INSENSITIVE, }, &iosb, - NULL, + nullptr, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN_IF, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, - NULL, + nullptr, 0); if (!NT_SUCCESS(status)) { @@ -157,13 +157,13 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data) { } } - HANDLE FF_AUTO_CLOSE_FD handle = CreateFileW(fileNameW, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE FF_AUTO_CLOSE_FD handle = CreateFileW(fileNameW, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle == INVALID_HANDLE_VALUE) { if (GetLastError() == ERROR_PATH_NOT_FOUND) { if (!createSubfolders(fileNameW)) { return false; } - handle = CreateFileW(fileNameW, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + handle = CreateFileW(fileNameW, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle == INVALID_HANDLE_VALUE) { return false; } @@ -173,7 +173,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data) { } DWORD written; - return !!WriteFile(handle, data, (DWORD) dataSize, &written, NULL); + return !!WriteFile(handle, data, (DWORD) dataSize, &written, nullptr); } static inline void readWithLength(HANDLE handle, FFstrbuf* buffer, uint32_t length) { @@ -181,7 +181,7 @@ static inline void readWithLength(HANDLE handle, FFstrbuf* buffer, uint32_t leng DWORD bytesRead = 0; while ( length > 0 && - ReadFile(handle, buffer->chars + buffer->length, length, &bytesRead, NULL) != FALSE && + ReadFile(handle, buffer->chars + buffer->length, length, &bytesRead, nullptr) != FALSE && bytesRead > 0) { buffer->length += (uint32_t) bytesRead; length -= (uint32_t) bytesRead; @@ -193,7 +193,7 @@ static inline void readUntilEOF(HANDLE handle, FFstrbuf* buffer) { uint32_t available = ffStrbufGetFree(buffer); DWORD bytesRead = 0; while ( - ReadFile(handle, buffer->chars + buffer->length, available, &bytesRead, NULL) != FALSE && + ReadFile(handle, buffer->chars + buffer->length, available, &bytesRead, nullptr) != FALSE && bytesRead > 0) { buffer->length += (uint32_t) bytesRead; if ((uint32_t) bytesRead == available) { @@ -282,7 +282,7 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out) { len /= sizeof(wchar_t); // convert from bytes to characters SIZE_T outLen; // in characters, including null terminator - if (!NT_SUCCESS(RtlExpandEnvironmentStrings(NULL, pathInW, len, pathOutW, ARRAY_SIZE(pathOutW), &outLen))) { + if (!NT_SUCCESS(RtlExpandEnvironmentStrings(nullptr, pathInW, len, pathOutW, ARRAY_SIZE(pathOutW), &outLen))) { return false; } @@ -336,7 +336,7 @@ bool ffSuppressIO(bool suppress) { void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indentation, const char* folderName, bool pretty) { uint32_t folderLength = folder->length; - if (pretty && folderName != NULL) { + if (pretty && folderName != nullptr) { for (uint8_t i = 0; i < indentation - 1; i++) { fputs(" | ", stdout); } @@ -381,7 +381,7 @@ void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indenta void ffListFilesRecursively(const char* path, bool pretty) { FF_STRBUF_AUTO_DESTROY folder = ffStrbufCreateS(path); ffStrbufEnsureEndsWithC(&folder, '/'); - listFilesRecursively(folder.length, &folder, 0, NULL, pretty); + listFilesRecursively(folder.length, &folder, 0, nullptr, pretty); } const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...) { @@ -390,7 +390,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char* DWORD inputMode = 0; bool hasInputMode = !!GetConsoleMode(hInput, &inputMode); if (!hasInputMode) { - hConin = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, NULL); + hConin = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, nullptr); hInput = hConin; hasInputMode = !!GetConsoleMode(hInput, &inputMode); } @@ -404,10 +404,10 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char* FF_AUTO_CLOSE_FD HANDLE hConout = INVALID_HANDLE_VALUE; DWORD outputMode; if (!GetConsoleMode(hOutput, &outputMode)) { - hConout = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, NULL); + hConout = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, nullptr); hOutput = hConout; } - WriteFile(hOutput, request, (DWORD) strlen(request), &bytes, NULL); + WriteFile(hOutput, request, (DWORD) strlen(request), &bytes, nullptr); } while (true) { @@ -441,7 +441,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char* while (true) { DWORD bytes = 0; - if (!ReadFile(hInput, buffer + bytesRead, (DWORD) (sizeof(buffer) - 1 - bytesRead), &bytes, NULL) || bytes == 0) { + if (!ReadFile(hInput, buffer + bytesRead, (DWORD) (sizeof(buffer) - 1 - bytesRead), &bytes, nullptr) || bytes == 0) { va_end(args); return "ReadFile() failed"; } @@ -473,7 +473,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char* va_end(args); - return NULL; + return nullptr; } FFNativeFD ffGetNullFD(void) { @@ -490,7 +490,7 @@ FFNativeFD ffGetNullFD(void) { 0, &(SECURITY_ATTRIBUTES) { .nLength = sizeof(SECURITY_ATTRIBUTES), - .lpSecurityDescriptor = NULL, + .lpSecurityDescriptor = nullptr, .bInheritHandle = TRUE, }); return hNullFile; diff --git a/src/common/impl/jsonconfig.c b/src/common/impl/jsonconfig.c index fccc56cc0..fc093313a 100644 --- a/src/common/impl/jsonconfig.c +++ b/src/common/impl/jsonconfig.c @@ -67,7 +67,7 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { if (intVal == pPair->value) { *result = pPair->value; - return NULL; + return nullptr; } } @@ -77,7 +77,7 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { if (ffStrEqualsIgnCase(strVal, pPair->key)) { *result = pPair->value; - return NULL; + return nullptr; } } @@ -244,7 +244,7 @@ static const char* printJsonConfig(FFdata* data, bool prepare) { yyjson_val* modules = yyjson_obj_get(root, "modules"); if (!modules) { - return NULL; + return nullptr; } if (!yyjson_is_arr(modules)) { return "Property 'modules' must be an array of strings or objects"; @@ -263,7 +263,7 @@ static const char* printJsonConfig(FFdata* data, bool prepare) { yyjson_val* module = item; const char* type = yyjson_get_str(module); if (type) { - module = NULL; + module = nullptr; } else if (yyjson_is_obj(module)) { yyjson_val* conditions = yyjson_obj_get(module, "condition"); if (conditions) { @@ -307,7 +307,7 @@ static const char* printJsonConfig(FFdata* data, bool prepare) { return "module object must contain a \"type\" key ( case sensitive )"; } if (yyjson_obj_size(module) == 1) { // contains only Property type - module = NULL; + module = nullptr; } } else { return "modules must be an array of strings or objects"; @@ -347,7 +347,7 @@ static const char* printJsonConfig(FFdata* data, bool prepare) { #endif } - return NULL; + return nullptr; } void ffPrintJsonConfig(FFdata* data, bool prepare) { @@ -359,7 +359,7 @@ void ffPrintJsonConfig(FFdata* data, bool prepare) { yyjson_mut_obj_add_str(jsonDoc, obj, "error", error); yyjson_mut_doc_set_root(jsonDoc, obj); } else { - ffPrintError("JsonConfig", 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "%s", error); + ffPrintError("JsonConfig", 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "%s", error); } } } diff --git a/src/common/impl/kmod_apple.c b/src/common/impl/kmod_apple.c index 82edc4946..3f1395f5c 100644 --- a/src/common/impl/kmod_apple.c +++ b/src/common/impl/kmod_apple.c @@ -6,7 +6,7 @@ bool ffKmodLoaded(const char* modName) { FF_CFTYPE_AUTO_RELEASE CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, modName, kCFStringEncodingUTF8); FF_CFTYPE_AUTO_RELEASE CFArrayRef identifiers = CFArrayCreate(kCFAllocatorDefault, (const void**) &name, 1, &kCFTypeArrayCallBacks); - FF_CFTYPE_AUTO_RELEASE CFArrayRef keys = CFArrayCreate(kCFAllocatorDefault, NULL, 0, NULL); + FF_CFTYPE_AUTO_RELEASE CFArrayRef keys = CFArrayCreate(kCFAllocatorDefault, nullptr, 0, nullptr); FF_CFTYPE_AUTO_RELEASE CFDictionaryRef kextInfo = KextManagerCopyLoadedKextInfo(identifiers, keys); return CFDictionaryContainsKey(kextInfo, name); } diff --git a/src/common/impl/kmod_linux.c b/src/common/impl/kmod_linux.c index 204ab3585..e5f9d1029 100644 --- a/src/common/impl/kmod_linux.c +++ b/src/common/impl/kmod_linux.c @@ -3,7 +3,7 @@ bool ffKmodLoaded(const char* modName) { static FFstrbuf modules; - if (modules.chars == NULL) { + if (modules.chars == nullptr) { ffStrbufInitS(&modules, "\n"); ffAppendFileBuffer("/proc/modules", &modules); } @@ -21,5 +21,5 @@ bool ffKmodLoaded(const char* modName) { temp[0] = '\n'; memcpy(temp + 1, modName, len); temp[1 + len] = ' '; - return memmem(modules.chars, modules.length, temp, len + 2) != NULL; + return memmem(modules.chars, modules.length, temp, len + 2) != nullptr; } diff --git a/src/common/impl/kmod_nbsd.c b/src/common/impl/kmod_nbsd.c index f1b450a9b..19f18a05d 100644 --- a/src/common/impl/kmod_nbsd.c +++ b/src/common/impl/kmod_nbsd.c @@ -10,9 +10,9 @@ typedef struct FF_A_PACKED FFNbsdModList { } FFNbsdModList; bool ffKmodLoaded(const char* modName) { - static FFNbsdModList* list = NULL; + static FFNbsdModList* list = nullptr; - if (list == NULL) { + if (list == nullptr) { struct iovec iov = {}; for (size_t len = 8192;; len = iov.iov_len) { diff --git a/src/common/impl/kmod_windows.c b/src/common/impl/kmod_windows.c index 081e5a788..be3ec1b48 100644 --- a/src/common/impl/kmod_windows.c +++ b/src/common/impl/kmod_windows.c @@ -5,7 +5,7 @@ bool ffKmodLoaded(const char* modName) { ULONG bufferSize = 0; - NtQuerySystemInformation(SystemModuleInformation, NULL, 0, &bufferSize); + NtQuerySystemInformation(SystemModuleInformation, nullptr, 0, &bufferSize); if (bufferSize == 0) { return true; // ignore errors } diff --git a/src/common/impl/library.c b/src/common/impl/library.c index c16e0b11d..08ba5055b 100644 --- a/src/common/impl/library.c +++ b/src/common/impl/library.c @@ -35,7 +35,7 @@ void* ffLibraryLoadSingle(const char* path, int maxVersion) { // libX.dll.1 never exists on Windows, while libX-1.dll may exist FF_UNUSED(maxVersion) - if (result != NULL) { + if (result != nullptr) { return result; } @@ -50,11 +50,11 @@ void* ffLibraryLoadSingle(const char* path, int maxVersion) { #else - if (result == NULL) { + if (result == nullptr) { FF_DEBUG("dlopen(\"%s\"): %s", path, dlerror()); } - if (result != NULL || maxVersion < 0) { + if (result != nullptr || maxVersion < 0) { return result; } @@ -67,7 +67,7 @@ void* ffLibraryLoadSingle(const char* path, int maxVersion) { ffStrbufAppendSInt(&pathbuf, i); result = dlopen(pathbuf.chars, FF_DLOPEN_FLAGS); - if (result != NULL) { + if (result != nullptr) { break; } else { FF_DEBUG("dlopen(\"%s\"): %s", pathbuf.chars, dlerror()); @@ -90,7 +90,7 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...) { do { const char* pathRest = va_arg(defaultNames, const char*); - if (pathRest == NULL) { + if (pathRest == nullptr) { break; } @@ -115,11 +115,11 @@ void* dlopen(const char* path, FF_A_UNUSED int mode) { NTSTATUS status = RtlUTF8ToUnicodeN(pathW, sizeof(pathW), &pathWBytes, path, (uint32_t) strlen(path) + 1); if (!NT_SUCCESS(status)) { FF_DEBUG("RtlUTF8ToUnicodeN failed for path %s with status 0x%08lX: %s", path, status, ffDebugNtStatus(status)); - return NULL; + return nullptr; } - PVOID module = NULL; - status = LdrLoadDll(NULL, NULL, &(UNICODE_STRING) { + PVOID module = nullptr; + status = LdrLoadDll(nullptr, nullptr, &(UNICODE_STRING) { .Length = (USHORT) (pathWBytes - sizeof(wchar_t)), // Exclude null terminator .MaximumLength = (USHORT) pathWBytes, .Buffer = pathW, @@ -128,7 +128,7 @@ void* dlopen(const char* path, FF_A_UNUSED int mode) { if (!NT_SUCCESS(status)) { FF_DEBUG("LdrLoadDll failed for path %s with status 0x%08lX: %s", path, status, ffDebugNtStatus(status)); - return NULL; + return nullptr; } return module; @@ -155,17 +155,17 @@ void* dlsym(void* handle, const char* symbol) { &address); if (!NT_SUCCESS(status)) { FF_DEBUG("LdrGetProcedureAddress failed for symbol %s with status 0x%08lX: %s", symbol, status, ffDebugNtStatus(status)); - return NULL; + return nullptr; } return address; } void* ffLibraryGetModule(const wchar_t* libraryFileName) { - assert(libraryFileName != NULL && "Use \"ffGetPeb()->ImageBaseAddress\" instead"); + assert(libraryFileName != nullptr && "Use \"ffGetPeb()->ImageBaseAddress\" instead"); - void* module = NULL; + void* module = nullptr; USHORT libraryFileNameBytes = (USHORT) (wcslen(libraryFileName) * sizeof(wchar_t) + sizeof(wchar_t)); - NTSTATUS status = LdrGetDllHandle(NULL, NULL, &(UNICODE_STRING) { + NTSTATUS status = LdrGetDllHandle(nullptr, nullptr, &(UNICODE_STRING) { .Length = libraryFileNameBytes - sizeof(wchar_t), .MaximumLength = libraryFileNameBytes, .Buffer = (wchar_t*) libraryFileName, @@ -173,7 +173,7 @@ void* ffLibraryGetModule(const wchar_t* libraryFileName) { &module); if (!NT_SUCCESS(status)) { FF_DEBUG("LdrGetDllHandle failed for library %ls with status 0x%08lX: %s", libraryFileName, status, ffDebugNtStatus(status)); - return NULL; + return nullptr; } return module; } diff --git a/src/common/impl/lua.c b/src/common/impl/lua.c index ffc1d83c9..871bf43b0 100644 --- a/src/common/impl/lua.c +++ b/src/common/impl/lua.c @@ -109,7 +109,7 @@ static int yyjsonEncode(lua_State* L) { pretty = (int) lua_toboolean(L, 2); } - yyjson_mut_doc* doc = yyjson_mut_doc_new(NULL); + yyjson_mut_doc* doc = yyjson_mut_doc_new(nullptr); if (__builtin_expect(!doc, false)) { lua_pushlstring(L, "yyjson: yyjson_mut_doc_new() failed", strlen("yyjson: yyjson_mut_doc_new() failed")); return lua_error(L); @@ -120,9 +120,9 @@ static int yyjsonEncode(lua_State* L) { size_t jsonLen; yyjson_write_err err = {}; - FF_AUTO_FREE const char* jsonStr = yyjson_mut_write_opts(doc, YYJSON_WRITE_ALLOW_INF_AND_NAN | (pretty ? YYJSON_WRITE_PRETTY_TWO_SPACES : 0), NULL, &jsonLen, &err); + FF_AUTO_FREE const char* jsonStr = yyjson_mut_write_opts(doc, YYJSON_WRITE_ALLOW_INF_AND_NAN | (pretty ? YYJSON_WRITE_PRETTY_TWO_SPACES : 0), nullptr, &jsonLen, &err); - if (__builtin_expect(jsonStr != NULL, true)) { + if (__builtin_expect(jsonStr != nullptr, true)) { lua_pushlstring(L, jsonStr, jsonLen); yyjson_mut_doc_free(doc); return 1; @@ -140,10 +140,10 @@ static int yyjsonEncode(lua_State* L) { const char* ffLuaLoadState(void) { if (luaData.inited) { - if (luaData.L == NULL) { + if (luaData.L == nullptr) { return "Lua library is not available"; } - return NULL; + return nullptr; } luaData.inited = true; @@ -211,7 +211,7 @@ const char* ffLuaLoadState(void) { #endif lua_State* L = ffluaL_newstate(); - if (L == NULL) { + if (L == nullptr) { return "luaL_newstate() failed"; } #if LUA_VERSION_NUM >= 505 @@ -226,8 +226,8 @@ const char* ffLuaLoadState(void) { lua_pushcfunction(L, yyjsonEncode); lua_setglobal(L, "json_encode"); luaData.L = L; - liblua = NULL; // don't close lua - return NULL; + liblua = nullptr; // don't close lua + return nullptr; } #endif diff --git a/src/common/impl/memrchr.c b/src/common/impl/memrchr.c index aaf97e604..4acca548d 100644 --- a/src/common/impl/memrchr.c +++ b/src/common/impl/memrchr.c @@ -4,7 +4,7 @@ void* memrchr(const void* s, int c, size_t n) { if (n == 0) { - return NULL; + return nullptr; } const uint8_t uc = (uint8_t) c; @@ -17,5 +17,5 @@ void* memrchr(const void* s, int c, size_t n) { } } - return NULL; + return nullptr; } diff --git a/src/common/impl/netif_apple.c b/src/common/impl/netif_apple.c index 2d42735ff..ed2fb5615 100644 --- a/src/common/impl/netif_apple.c +++ b/src/common/impl/netif_apple.c @@ -52,7 +52,7 @@ get_rt_address(struct rt_msghdr* rtm, int desired) { sa = (struct sockaddr*) (ROUNDUP(salen) + (char*) sa); } } - return NULL; + return nullptr; } bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { diff --git a/src/common/impl/netif_bsd.c b/src/common/impl/netif_bsd.c index 2b59c6d53..b81bbfe78 100644 --- a/src/common/impl/netif_bsd.c +++ b/src/common/impl/netif_bsd.c @@ -39,20 +39,20 @@ get_rt_address(struct rt_msghdr* rtm, int desired) { sa = (struct sockaddr*) (ROUNDUP(sa->sa_len) + (char*) sa); } } - return NULL; + return nullptr; } bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { int mib[6] = { CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, RTF_GATEWAY }; size_t needed; - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0 || needed == 0) { + if (sysctl(mib, 6, nullptr, &needed, nullptr, 0) < 0 || needed == 0) { return false; } FF_AUTO_FREE char* buf = malloc(needed); - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { + if (sysctl(mib, 6, buf, &needed, nullptr, 0) < 0) { return false; } @@ -89,13 +89,13 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { int mib[6] = { CTL_NET, PF_ROUTE, 0, AF_INET6, NET_RT_FLAGS, RTF_GATEWAY }; size_t needed; - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0 || needed == 0) { + if (sysctl(mib, 6, nullptr, &needed, nullptr, 0) < 0 || needed == 0) { return false; } FF_AUTO_FREE char* buf = malloc(needed); - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { + if (sysctl(mib, 6, buf, &needed, nullptr, 0) < 0) { return false; } diff --git a/src/common/impl/netif_haiku.c b/src/common/impl/netif_haiku.c index a32138c68..73782d919 100644 --- a/src/common/impl/netif_haiku.c +++ b/src/common/impl/netif_haiku.c @@ -29,7 +29,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { } FF_AUTO_FREE void* buffer = malloc((size_t) size); - if (buffer == NULL) { + if (buffer == nullptr) { return false; } @@ -54,13 +54,13 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { } size_t addressSize = 0; - if (interface->ifr_route.destination != NULL) { + if (interface->ifr_route.destination != nullptr) { addressSize += interface->ifr_route.destination->sa_len; } - if (interface->ifr_route.mask != NULL) { + if (interface->ifr_route.mask != nullptr) { addressSize += interface->ifr_route.mask->sa_len; } - if (interface->ifr_route.gateway != NULL) { + if (interface->ifr_route.gateway != nullptr) { addressSize += interface->ifr_route.gateway->sa_len; } @@ -88,7 +88,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { } FF_AUTO_FREE void* buffer = malloc((size_t) size); - if (buffer == NULL) { + if (buffer == nullptr) { return false; } @@ -109,13 +109,13 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { } size_t addressSize = 0; - if (interface->ifr_route.destination != NULL) { + if (interface->ifr_route.destination != nullptr) { addressSize += interface->ifr_route.destination->sa_len; } - if (interface->ifr_route.mask != NULL) { + if (interface->ifr_route.mask != nullptr) { addressSize += interface->ifr_route.mask->sa_len; } - if (interface->ifr_route.gateway != NULL) { + if (interface->ifr_route.gateway != nullptr) { addressSize += interface->ifr_route.gateway->sa_len; } diff --git a/src/common/impl/netif_windows.c b/src/common/impl/netif_windows.c index 7531ae064..9a21678e0 100644 --- a/src/common/impl/netif_windows.c +++ b/src/common/impl/netif_windows.c @@ -4,7 +4,7 @@ #include bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { - PMIB_IPFORWARD_TABLE2 pIpForwardTable = NULL; + PMIB_IPFORWARD_TABLE2 pIpForwardTable = nullptr; if (!NETIO_SUCCESS(GetIpForwardTable2(AF_INET, &pIpForwardTable))) { return false; @@ -48,7 +48,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { } bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { - PMIB_IPFORWARD_TABLE2 pIpForwardTable = NULL; + PMIB_IPFORWARD_TABLE2 pIpForwardTable = nullptr; if (!NETIO_SUCCESS(GetIpForwardTable2(AF_INET6, &pIpForwardTable))) { return false; diff --git a/src/common/impl/networking_common.c b/src/common/impl/networking_common.c index e63979bf2..2c436590e 100644 --- a/src/common/impl/networking_common.c +++ b/src/common/impl/networking_common.c @@ -29,9 +29,9 @@ const char* ffNetworkingLoadZlibLibrary(void) { FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflateInit2_) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflate) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflateEnd) - zlib = NULL; // don't auto dlclose + zlib = nullptr; // don't auto dlclose } - return zlibData.ffinflateEnd == NULL ? "Failed to load libz" : NULL; + return zlibData.ffinflateEnd == nullptr ? "Failed to load libz" : nullptr; } // Try to pre-read gzip header to determine uncompressed size @@ -64,14 +64,14 @@ static uint32_t guessGzipOutputSize(const void* data, uint32_t dataSize) { // Decompress gzip content bool ffNetworkingDecompressGzip(FFstrbuf* buffer, char* headerEnd) { - assert(headerEnd != NULL && *headerEnd == '\r'); + assert(headerEnd != nullptr && *headerEnd == '\r'); // Calculate header size uint32_t headerSize = (uint32_t) (headerEnd - buffer->chars); *headerEnd = '\0'; // Replace delimiter with null character for easier processing // Ensure Content-Encoding is in response headers, not in response body - bool hasGzip = strcasestr(buffer->chars, "\nContent-Encoding: gzip") != NULL; + bool hasGzip = strcasestr(buffer->chars, "\nContent-Encoding: gzip") != nullptr; *headerEnd = '\r'; // Restore delimiter if (!hasGzip) { @@ -165,7 +165,7 @@ bool ffNetworkingDecompressGzip(FFstrbuf* buffer, char* headerEnd) { // Use decompressedBuffer.length (total) not decompressedSize (last chunk only) FF_STRBUF_AUTO_DESTROY newBuffer = ffStrbufCreateA(headerSize + decompressedBuffer.length + 64); - char* line = NULL; + char* line = nullptr; size_t len = 0; while (ffStrbufGetline(&line, &len, buffer)) { if (ffStrStartsWithIgnCase(line, "Content-Encoding:")) { diff --git a/src/common/impl/networking_linux.c b/src/common/impl/networking_linux.c index 7e4056792..9dcdd72cd 100644 --- a/src/common/impl/networking_linux.c +++ b/src/common/impl/networking_linux.c @@ -97,7 +97,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { }, 1, &sent, - NULL) != 0) { + nullptr) != 0) { sent = 0; } if (fcntl(state->sockfd, F_SETFL, 0) == -1) { @@ -123,9 +123,9 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { sent, strerror(errno)); freeaddrinfo(state->addr); - state->addr = NULL; + state->addr = nullptr; ffStrbufDestroy(&state->command); - return NULL; + return nullptr; } FF_DEBUG( @@ -149,7 +149,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { // Traditional connect and send function static const char* connectAndSend(FFNetworkingState* state) { - const char* ret = NULL; + const char* ret = nullptr; FF_DEBUG("Using traditional connection method to connect"); FF_DEBUG("Attempting connect() to server..."); @@ -178,7 +178,7 @@ error: exit: FF_DEBUG("Releasing address info and other resources"); freeaddrinfo(state->addr); - state->addr = NULL; + state->addr = nullptr; ffStrbufDestroy(&state->command); return ret; @@ -212,7 +212,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos FF_DEBUG("Thread ID initialized to 0"); #endif - const char* ret = NULL; + const char* ret = nullptr; struct addrinfo hints = { .ai_family = state->ipv6 ? AF_INET6 : AF_INET, @@ -280,14 +280,14 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos #endif } - return NULL; + return nullptr; error: FF_DEBUG("Error occurred during initialization"); - if (state->addr != NULL) { + if (state->addr != nullptr) { FF_DEBUG("Releasing address information"); freeaddrinfo(state->addr); - state->addr = NULL; + state->addr = nullptr; } if (state->sockfd > 0) { @@ -307,7 +307,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho #ifdef FF_HAVE_ZLIB const char* zlibError = ffNetworkingLoadZlibLibrary(); // Only enable compression if zlib library is successfully loaded - if (zlibError == NULL) { + if (zlibError == nullptr) { FF_DEBUG("Successfully loaded zlib library, compression enabled"); } else { FF_DEBUG("Failed to load zlib library, compression disabled: %s", zlibError); @@ -322,16 +322,16 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho } const char* initResult = initNetworkingState(state, host, path, headers); - if (initResult != NULL) { + if (initResult != nullptr) { FF_DEBUG("Initialization failed: %s", initResult); return initResult; } FF_DEBUG("Network state initialization successful"); const char* tfoResult = tryNonThreadingFastPath(state); - if (tfoResult == NULL) { + if (tfoResult == nullptr) { FF_DEBUG("TryNonThreadingFastPath() succeeded or in progress"); - return NULL; + return nullptr; } FF_DEBUG("TryNonThreadingFastPath() failed: %s, trying traditional connection", tfoResult); @@ -341,7 +341,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho state->thread = ffThreadCreate(connectAndSendThreadMain, state); if (state->thread) { FF_DEBUG("Thread creation successful: thread=%p", (void*) (uintptr_t) state->thread); - return NULL; + return nullptr; } FF_DEBUG("Thread creation failed"); } else { @@ -455,7 +455,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf // Check for Content-Length header to pre-allocate enough memory const char* clHeader = strcasestr(buffer->chars, "Content-Length:"); if (clHeader) { - contentLength = (uint32_t) strtoul(clHeader + 15, NULL, 10); + contentLength = (uint32_t) strtoul(clHeader + 15, nullptr, 10); if (contentLength > 0) { FF_DEBUG("Detected Content-Length: %u, pre-allocating buffer", contentLength); // Ensure buffer is large enough, adding header size and some margin @@ -505,5 +505,5 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf } #endif - return NULL; + return nullptr; } diff --git a/src/common/impl/networking_windows.c b/src/common/impl/networking_windows.c index d3a775228..019306b6d 100644 --- a/src/common/impl/networking_windows.c +++ b/src/common/impl/networking_windows.c @@ -23,7 +23,7 @@ static const char* initWsaData(WSADATA* wsaData) { } // Dummy socket needed for WSAIoctl - SOCKET sockfd = WSASocketW(AF_INET, SOCK_STREAM, 0, NULL, 0, 0); + SOCKET sockfd = WSASocketW(AF_INET, SOCK_STREAM, 0, nullptr, 0, 0); if (sockfd == INVALID_SOCKET) { FF_DEBUG("WSASocketW(AF_INET, SOCK_STREAM) failed"); WSACleanup(); @@ -32,7 +32,7 @@ static const char* initWsaData(WSADATA* wsaData) { DWORD dwBytes; GUID guid = WSAID_CONNECTEX; - if (WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid), &ConnectEx, sizeof(ConnectEx), &dwBytes, NULL, NULL) != 0) { + if (WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid), &ConnectEx, sizeof(ConnectEx), &dwBytes, nullptr, nullptr) != 0) { FF_DEBUG("WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER) failed"); closesocket(sockfd); WSACleanup(); @@ -42,7 +42,7 @@ static const char* initWsaData(WSADATA* wsaData) { closesocket(sockfd); FF_DEBUG("WinSock initialized successfully"); - return NULL; + return nullptr; } const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers) { @@ -52,7 +52,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho #ifdef FF_HAVE_ZLIB const char* zlibError = ffNetworkingLoadZlibLibrary(); // Only enable compression if zlib library is successfully loaded - if (zlibError == NULL) { + if (zlibError == nullptr) { FF_DEBUG("Successfully loaded zlib library, compression enabled"); } else { FF_DEBUG("Failed to load zlib library, compression disabled: %s", zlibError); @@ -69,7 +69,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho static WSADATA wsaData; if (wsaData.wVersion == 0) { const char* error = initWsaData(&wsaData); - if (error != NULL) { + if (error != nullptr) { wsaData.wVersion = (WORD) -1; FF_DEBUG("WinSock initialization failed: %s", error); return error; @@ -87,7 +87,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho }; wchar_t hostW[256]; - if (!NT_SUCCESS(RtlUTF8ToUnicodeN(hostW, (ULONG) sizeof(hostW), NULL, host, (ULONG) strlen(host) + 1))) { + if (!NT_SUCCESS(RtlUTF8ToUnicodeN(hostW, (ULONG) sizeof(hostW), nullptr, host, (ULONG) strlen(host) + 1))) { FF_DEBUG("Failed to convert host to wide string: %s", host); return "Failed to convert host to wide string"; } @@ -98,7 +98,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho return "GetAddrInfoW() failed"; } - state->sockfd = WSASocketW(addr->ai_family, addr->ai_socktype, addr->ai_protocol, NULL, 0, 0); + state->sockfd = WSASocketW(addr->ai_family, addr->ai_socktype, addr->ai_protocol, nullptr, 0, 0); if (state->sockfd == INVALID_SOCKET) { FF_DEBUG("WSASocketW() failed"); FreeAddrInfoW(addr); @@ -189,7 +189,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho BOOL result = ConnectEx(state->sockfd, addr->ai_addr, (int) addr->ai_addrlen, state->command.chars, state->command.length, &sent, &state->overlapped); FreeAddrInfoW(addr); - addr = NULL; + addr = nullptr; if (!result) { if (WSAGetLastError() != WSA_IO_PENDING) { @@ -207,7 +207,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho } // No need to cleanup state fields here since we need them in the receive function - return NULL; + return nullptr; } const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer) { @@ -250,9 +250,9 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf FF_DEBUG("WSAGetOverlappedResult succeeded, %u bytes sent", (unsigned) transfer); ffStrbufDestroy(&state->command); WSACloseEvent(state->overlapped.hEvent); - state->overlapped.hEvent = NULL; + state->overlapped.hEvent = nullptr; - if (setsockopt(state->sockfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0) != 0) { + if (setsockopt(state->sockfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, nullptr, 0) != 0) { FF_DEBUG("Failed to update connect context: %s", ffDebugWin32Error((DWORD) WSAGetLastError())); // Not a critical error, continue anyway } @@ -293,8 +293,8 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf 1, &received, &recvFlags, - NULL, - NULL); + nullptr, + nullptr); if (recvResult == SOCKET_ERROR || received == 0) { if (recvResult == 0 && received == 0) { @@ -320,7 +320,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf // Check for Content-Length header to pre-allocate enough memory const char* clHeader = strcasestr(buffer->chars, "Content-Length:"); if (clHeader) { - contentLength = (uint32_t) strtoul(clHeader + 15, NULL, 10); + contentLength = (uint32_t) strtoul(clHeader + 15, nullptr, 10); if (contentLength > 0) { FF_DEBUG("Detected Content-Length: %u, pre-allocating buffer", contentLength); // Ensure buffer is large enough, adding header size and some margin @@ -372,5 +372,5 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf } #endif - return NULL; + return nullptr; } diff --git a/src/common/impl/option.c b/src/common/impl/option.c index 3d592d0ec..87b004aea 100644 --- a/src/common/impl/option.c +++ b/src/common/impl/option.c @@ -5,19 +5,19 @@ #include -// Return start position of the inner key if the argument key belongs to the module specified, NULL otherwise +// Return start position of the inner key if the argument key belongs to the module specified, nullptr otherwise const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName) { assert(argumentKey && moduleName); const char* subKey = argumentKey; if (!(subKey[0] == '-' && subKey[1] == '-')) { - return NULL; + return nullptr; } subKey += 2; uint32_t moduleNameLen = (uint32_t) strlen(moduleName); if (strncasecmp(subKey, moduleName, moduleNameLen) != 0) { - return NULL; + return nullptr; } subKey += moduleNameLen; @@ -27,7 +27,7 @@ const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName) } if (subKey[0] != '-') { - return NULL; + return nullptr; } subKey += 1; @@ -36,7 +36,7 @@ const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName) } void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer) { - if (value == NULL) { + if (value == nullptr) { fprintf(stderr, "Error: usage: %s \n", argumentKey); exit(477); } @@ -45,7 +45,7 @@ void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* b } uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value) { - if (value == NULL) { + if (value == nullptr) { fprintf(stderr, "Error: usage: %s \n", argumentKey); exit(480); } @@ -61,7 +61,7 @@ uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value) { } int32_t ffOptionParseInt32(const char* argumentKey, const char* value) { - if (value == NULL) { + if (value == nullptr) { fprintf(stderr, "Error: usage: %s \n", argumentKey); exit(480); } @@ -77,7 +77,7 @@ int32_t ffOptionParseInt32(const char* argumentKey, const char* value) { } int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]) { - if (requestedKey == NULL) { + if (requestedKey == nullptr) { fprintf(stderr, "Error: usage: %s \n", argumentKey); exit(476); } @@ -139,7 +139,7 @@ void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer) { } else if (value[0] == '@') { // Xterm 256 color ++value; - char* pend = NULL; + char* pend = nullptr; uint32_t color = (uint32_t) strtoul(value, &pend, 10); if (pend == value || color > 255) { fprintf(stderr, "Error: invalid 256 color code found: %s\n", value); @@ -153,7 +153,7 @@ void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer) { } else if (value[0] == '#') { // RGB color ++value; - char* pend = NULL; + char* pend = nullptr; uint32_t rgb = (uint32_t) strtoul(value, &pend, 16); if (pend == value) { fprintf(stderr, "Error: invalid RGB color code found: %s\n", value); diff --git a/src/common/impl/path.c b/src/common/impl/path.c index c97210e96..32e21ca8f 100644 --- a/src/common/impl/path.c +++ b/src/common/impl/path.c @@ -47,7 +47,7 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) { } #endif - return NULL; + return nullptr; } ffStrbufClear(result); return "Executable not found"; @@ -60,13 +60,13 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) { const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) { char buffer[MAX_PATH + 1]; - DWORD length = SearchPathA(NULL, name, ".exe", sizeof(buffer), buffer, NULL); + DWORD length = SearchPathA(nullptr, name, ".exe", sizeof(buffer), buffer, nullptr); if (length == 0) { ffStrbufClear(result); return "Executable not found"; } ffStrbufSetS(result, buffer); - return NULL; + return nullptr; } static inline int winerr2Errno(DWORD err) { @@ -93,7 +93,7 @@ static inline int winerr2Errno(DWORD err) { char* frealpath(HANDLE hFile, char* resolved_name) { if (__builtin_expect(hFile == INVALID_HANDLE_VALUE || !hFile, false)) { errno = EINVAL; - return NULL; + return nullptr; } wchar_t resolvedNameW[MAX_PATH + 4]; /* +4 for "\\\\?\\" prefix */ @@ -101,11 +101,11 @@ char* frealpath(HANDLE hFile, char* resolved_name) { if (lenW == 0) { errno = winerr2Errno(GetLastError()); - return NULL; + return nullptr; } if (lenW >= ARRAY_SIZE(resolvedNameW)) { errno = E2BIG; - return NULL; + return nullptr; } lenW++; // Include null terminator @@ -126,7 +126,7 @@ char* frealpath(HANDLE hFile, char* resolved_name) { ULONG outBytes = 0; if (!NT_SUCCESS(RtlUnicodeToUTF8N(resolved_name, MAX_PATH, &outBytes, srcW, (ULONG) (srcLenW * sizeof(wchar_t))))) { errno = E2BIG; - return NULL; + return nullptr; } } else { /* UTF-8 worst-case: up to 4 bytes per UTF-16 code unit */ @@ -135,13 +135,13 @@ char* frealpath(HANDLE hFile, char* resolved_name) { if (!NT_SUCCESS(RtlUnicodeToUTF8N(tmp, (ULONG) sizeof(tmp), &outBytes, srcW, (ULONG) (srcLenW * sizeof(wchar_t))))) { errno = E2BIG; - return NULL; + return nullptr; } resolved_name = (char*) malloc(outBytes); if (!resolved_name) { errno = ENOMEM; - return NULL; + return nullptr; } memcpy(resolved_name, tmp, outBytes); @@ -153,7 +153,7 @@ char* frealpath(HANDLE hFile, char* resolved_name) { char* realpath(const char* __restrict file_name, char* __restrict resolved_name) { if (!file_name) { errno = EINVAL; - return NULL; + return nullptr; } wchar_t fileNameW[MAX_PATH]; @@ -161,21 +161,21 @@ char* realpath(const char* __restrict file_name, char* __restrict resolved_name) if (!NT_SUCCESS(RtlUTF8ToUnicodeN(fileNameW, (ULONG) sizeof(fileNameW), &lenBytes, file_name, (ULONG) strlen(file_name) + 1))) { errno = EINVAL; - return NULL; + return nullptr; } FF_AUTO_CLOSE_FD HANDLE hFile = CreateFileW( fileNameW, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, - NULL); + nullptr); if (hFile == INVALID_HANDLE_VALUE) { errno = winerr2Errno(GetLastError()); - return NULL; + return nullptr; } return frealpath(hFile, resolved_name); @@ -189,13 +189,13 @@ ssize_t freadlink(HANDLE hFile, char* buf, size_t bufsiz) { alignas(REPARSE_DATA_BUFFER) BYTE reparseBuf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; DWORD bytesReturned = 0; - if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, reparseBuf, (DWORD) sizeof(reparseBuf), &bytesReturned, NULL)) { + if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, nullptr, 0, reparseBuf, (DWORD) sizeof(reparseBuf), &bytesReturned, nullptr)) { errno = winerr2Errno(GetLastError()); return -1; } REPARSE_DATA_BUFFER* rp = (REPARSE_DATA_BUFFER*) reparseBuf; - const wchar_t* targetW = NULL; + const wchar_t* targetW = nullptr; USHORT targetBytes = 0; if (rp->ReparseTag == IO_REPARSE_TAG_SYMLINK) { @@ -262,10 +262,10 @@ ssize_t readlink(const char* path, char* buf, size_t bufsiz) { pathW, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, - NULL); + nullptr); if (hFile == INVALID_HANDLE_VALUE) { errno = winerr2Errno(GetLastError()); diff --git a/src/common/impl/percent.c b/src/common/impl/percent.c index 266588cb6..ef276484f 100644 --- a/src/common/impl/percent.c +++ b/src/common/impl/percent.c @@ -17,7 +17,7 @@ static void appendOutputColor(FFstrbuf* buffer, const FFModuleArgs* module) { const char* ffPercentParseTypeJsonConfig(yyjson_val* jsonVal, FFPercentageTypeFlags* result) { if (yyjson_is_uint(jsonVal)) { *result = (FFPercentageTypeFlags) yyjson_get_uint(jsonVal); - return NULL; + return nullptr; } if (yyjson_is_arr(jsonVal)) { FFPercentageTypeFlags flags = 0; @@ -45,7 +45,7 @@ const char* ffPercentParseTypeJsonConfig(yyjson_val* jsonVal, FFPercentageTypeFl } *result = flags; - return NULL; + return nullptr; } return "Error: usage: percent.type must be a number or an array of strings"; @@ -90,7 +90,7 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentageModuleConf bool monochrome = (percentType & FF_PERCENTAGE_TYPE_BAR_MONOCHROME_BIT) || !autoColorElapsed; if (!options->pipe && options->barColorElapsed.length > 0 && monochrome) { - const char* color = NULL; + const char* color = nullptr; if (!autoColorElapsed) { color = options->barColorElapsed.chars; } else if (green <= yellow) { diff --git a/src/common/impl/printing.c b/src/common/impl/printing.c index 9f372d937..1203dfb0a 100644 --- a/src/common/impl/printing.c +++ b/src/common/impl/printing.c @@ -7,7 +7,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu ffLogoPrintLine(); // This is used by --set-keyless, in this case we want neither the module name nor the separator - if (moduleName == NULL) { + if (moduleName == nullptr) { return; } @@ -35,7 +35,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu if (instance.config.display.keyType & FF_MODULE_KEY_TYPE_STRING) { ffPrintCharTimes(' ', instance.config.display.keyType >> FF_MODULE_KEY_TYPE_SPACE_SHIFT); - // NULL check is required for modules with custom keys, e.g. disk with the folder path + // nullptr check is required for modules with custom keys, e.g. disk with the folder path if ((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0) { fputs(moduleName, stdout); @@ -84,7 +84,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu bool ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); bool success; - if (__builtin_expect(moduleArgs != NULL, 1)) { + if (__builtin_expect(moduleArgs != nullptr, 1)) { success = ffParseFormatString(&buffer, &moduleArgs->outputFormat, numArgs, arguments); } else { ffStrbufSetStatic(&buffer, "undefined format"); diff --git a/src/common/impl/processing_linux.c b/src/common/impl/processing_linux.c index 828d4846d..e43aff2b9 100644 --- a/src/common/impl/processing_linux.c +++ b/src/common/impl/processing_linux.c @@ -79,7 +79,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle* posix_spawn_file_actions_adddup2(&file_actions, pipes[1], useStdErr ? STDERR_FILENO : STDOUT_FILENO); posix_spawn_file_actions_adddup2(&file_actions, nullFile, useStdErr ? STDOUT_FILENO : STDERR_FILENO); - static char* oldLang = NULL; + static char* oldLang = nullptr; static int langIndex = -1; if (langIndex >= 0) { @@ -95,7 +95,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle* } } if (langIndex < 0) { - for (int i = 0; environ[i] != NULL; i++) { + for (int i = 0; environ[i] != nullptr; i++) { if (ffStrStartsWith(environ[i], "LANG=")) { langIndex = i; const char* langValue = environ[i] + 5; // Skip "LANG=" @@ -112,7 +112,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle* } } - int ret = posix_spawnp(&childPid, argv[0], &file_actions, NULL, argv, environ); + int ret = posix_spawnp(&childPid, argv[0], &file_actions, nullptr, argv, environ); if (oldLang) { environ[langIndex] = oldLang; @@ -153,7 +153,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle* close(pipes[1]); outHandle->pid = childPid; outHandle->pipeRead = pipes[0]; - return NULL; + return nullptr; } const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) { @@ -173,11 +173,11 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) { int pollret = poll(&pollfd, 1, timeout); if (pollret == 0) { kill(childPid, SIGTERM); - waitpid(childPid, NULL, 0); + waitpid(childPid, nullptr, 0); return "poll(&pollfd, 1, timeout) timeout (try increasing --processing-timeout)"; } else if (pollret < 0 || (pollfd.revents & POLLERR)) { kill(childPid, SIGTERM); - waitpid(childPid, NULL, 0); + waitpid(childPid, nullptr, 0); return pollret < 0 ? "poll(&pollfd, 1, timeout) error: pollret < 0" : "poll(&pollfd, 1, timeout) error: pollfd.revents & POLLERR"; @@ -197,9 +197,9 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) { return "command not found"; } // We only handle 127 as an error. See `getTerminalVersionUrxvt` in `terminalshell.c` - return NULL; + return nullptr; } - return NULL; + return nullptr; } else if (nRead < 0) { break; } @@ -278,11 +278,11 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons size_t len = 0; int mibs[] = { CTL_KERN, KERN_PROCARGS2, pid }; - if (sysctl(mibs, ARRAY_SIZE(mibs), NULL, &len, NULL, 0) == 0) { // try get arg0 + if (sysctl(mibs, ARRAY_SIZE(mibs), nullptr, &len, nullptr, 0) == 0) { // try get arg0 // don't know why if don't let len longer, proArgs2 and len will change during the following sysctl() in old MacOS version. len++; FF_AUTO_FREE char* const procArgs2 = malloc(len); - if (sysctl(mibs, ARRAY_SIZE(mibs), procArgs2, &len, NULL, 0) == 0) { + if (sysctl(mibs, ARRAY_SIZE(mibs), procArgs2, &len, nullptr, 0) == 0) { // https://gist.github.com/nonowarn/770696#file-getargv-c-L46 uint32_t argc = *(uint32_t*) procArgs2; const char* realExePath = procArgs2 + sizeof(argc); @@ -354,7 +354,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons 4, args, &size, - NULL, + nullptr, 0) == 0) ffStrbufSetNS(exePath, (uint32_t) (size - 1), args); @@ -374,7 +374,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons 4, args, &size, - NULL, + nullptr, 0) == 0) { char* arg0 = args; size_t arg0Len = strlen(args); @@ -423,7 +423,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons #elif defined(__OpenBSD__) - kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); + kvm_t* kd = kvm_open(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr); int count = 0; const struct kinfo_proc* proc = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count); if (proc) { @@ -488,7 +488,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i } buf[nRead] = '\0'; // pid (comm) state ppid pgrp session tty - const char* pState = NULL; + const char* pState = nullptr; { // comm in `/proc/pid/stat` is not encoded, and may contain ' ', ')' or even `\n` @@ -542,7 +542,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i struct kinfo_proc proc; size_t size = sizeof(proc); if (sysctl( - (int[]) { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }, 4, &proc, &size, NULL, 0)) { + (int[]) { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }, 4, &proc, &size, nullptr, 0)) { return "sysctl(KERN_PROC_PID) failed"; } @@ -568,7 +568,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i struct kinfo_proc proc; size_t size = sizeof(proc); if (sysctl( - (int[]) { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }, 4, &proc, &size, NULL, 0)) { + (int[]) { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }, 4, &proc, &size, nullptr, 0)) { return "sysctl(KERN_PROC_PID) failed"; } @@ -580,7 +580,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i if (proc.ki_tdev != NODEV && proc.ki_flag & P_CONTROLT) { const char* ttyName = devname(proc.ki_tdev, S_IFCHR); if (ffStrStartsWith(ttyName, "pts/")) { - *tty = (int32_t) strtol(ttyName + strlen("pts/"), NULL, 10); + *tty = (int32_t) strtol(ttyName + strlen("pts/"), nullptr, 10); } else { *tty = -1; } @@ -594,7 +594,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i struct kinfo_proc2 proc; size_t size = sizeof(proc); if (sysctl( - (int[]) { CTL_KERN, KERN_PROC2, KERN_PROC_PID, pid, sizeof(proc), 1 }, 6, &proc, &size, NULL, 0) != 0) { + (int[]) { CTL_KERN, KERN_PROC2, KERN_PROC_PID, pid, sizeof(proc), 1 }, 6, &proc, &size, nullptr, 0) != 0) { return "sysctl(KERN_PROC_PID) failed"; } @@ -606,7 +606,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i if (proc.p_flag & P_CONTROLT) { const char* ttyName = devname(proc.p_tdev, S_IFCHR); if (ffStrStartsWith(ttyName, "pts/")) { - *tty = (int32_t) strtol(ttyName + strlen("pts/"), NULL, 10); + *tty = (int32_t) strtol(ttyName + strlen("pts/"), nullptr, 10); } else { *tty = -1; } @@ -633,7 +633,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i #elif defined(__OpenBSD__) - kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); + kvm_t* kd = kvm_open(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr); int count = 0; const struct kinfo_proc* proc = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count); if (proc) { @@ -668,5 +668,5 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i #endif - return NULL; + return nullptr; } diff --git a/src/common/impl/processing_windows.c b/src/common/impl/processing_windows.c index 846276b59..5df9f9057 100644 --- a/src/common/impl/processing_windows.c +++ b/src/common/impl/processing_windows.c @@ -15,7 +15,7 @@ static void argvToCmdline(char* const argv[], FFstrbuf* result) { // From https://gist.github.com/jin-x/cdd641d98887524b091fb1f82a68717d FF_STRBUF_AUTO_DESTROY temp = ffStrbufCreate(); - for (int i = 0; argv[i] != NULL; i++) { + for (int i = 0; argv[i] != nullptr; i++) { ffStrbufSetS(&temp, argv[i]); // Add slash (\) before double quotes (") and duplicate slashes before it for ( @@ -63,7 +63,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle* FF_PIPE_BUFSIZ, FF_PIPE_BUFSIZ, 0, - NULL); + nullptr); if (hChildPipeRead == INVALID_HANDLE_VALUE) { return "CreateNamedPipeW(L\"\\\\.\\pipe\\FASTFETCH-$(PID)\") failed"; } @@ -74,12 +74,12 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle* 0, &(SECURITY_ATTRIBUTES) { .nLength = sizeof(SECURITY_ATTRIBUTES), - .lpSecurityDescriptor = NULL, + .lpSecurityDescriptor = nullptr, .bInheritHandle = TRUE, }, OPEN_EXISTING, 0, - NULL); + nullptr); if (hChildPipeWrite == INVALID_HANDLE_VALUE) { return "CreateFileW(L\"\\\\.\\pipe\\FASTFETCH-$(PID)\") failed"; } @@ -97,26 +97,26 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle* siStartInfo.hStdError = ffGetNullFD(); } - FF_AUTO_FREE wchar_t* cmdline = NULL; + FF_AUTO_FREE wchar_t* cmdline = nullptr; { FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); argvToCmdline(argv, &buf); uint32_t cmdlineBytes = (buf.length + 1) * sizeof(wchar_t); cmdline = malloc(cmdlineBytes); - if (!NT_SUCCESS(RtlUTF8ToUnicodeN(cmdline, cmdlineBytes, NULL, buf.chars, buf.length + 1))) { + if (!NT_SUCCESS(RtlUTF8ToUnicodeN(cmdline, cmdlineBytes, nullptr, buf.chars, buf.length + 1))) { return "RtlUTF8ToUnicodeN() failed"; } } BOOL success = CreateProcessW( - NULL, // application name + nullptr, // application name cmdline, // command line - NULL, // process security attributes - NULL, // primary thread security attributes + nullptr, // process security attributes + nullptr, // primary thread security attributes TRUE, // handles are inherited 0, // creation flags - NULL, // use parent's environment - NULL, // use parent's current directory + nullptr, // use parent's environment + nullptr, // use parent's current directory &siStartInfo, // STARTUPINFO pointer &piProcInfo // receives PROCESS_INFORMATION ); @@ -134,7 +134,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle* outHandle->pipeRead = hChildPipeRead; hChildPipeRead = INVALID_HANDLE_VALUE; // ownership transferred, don't close it - return NULL; + return nullptr; } static void terminateChildProcess(HANDLE hProcess, HANDLE hChildPipeRead, HANDLE hReadEvent, IO_STATUS_BLOCK* piosb) { @@ -154,11 +154,11 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) { int32_t timeout = instance.config.general.processingTimeout; FF_AUTO_CLOSE_FD HANDLE hProcess = handle->pid; FF_AUTO_CLOSE_FD HANDLE hChildPipeRead = handle->pipeRead; - FF_AUTO_CLOSE_FD HANDLE hReadEvent = NULL; + FF_AUTO_CLOSE_FD HANDLE hReadEvent = nullptr; handle->pid = INVALID_HANDLE_VALUE; handle->pipeRead = INVALID_HANDLE_VALUE; - if (timeout >= 0 && !NT_SUCCESS(NtCreateEvent(&hReadEvent, EVENT_ALL_ACCESS, NULL, SynchronizationEvent, FALSE))) { + if (timeout >= 0 && !NT_SUCCESS(NtCreateEvent(&hReadEvent, EVENT_ALL_ACCESS, nullptr, SynchronizationEvent, FALSE))) { return "NtCreateEvent() failed"; } @@ -169,13 +169,13 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) { NTSTATUS status = NtReadFile( hChildPipeRead, hReadEvent, - NULL, - NULL, + nullptr, + nullptr, &iosb, str, (ULONG) sizeof(str), - NULL, - NULL); + nullptr, + nullptr); if (status == STATUS_PENDING) { switch (NtWaitForSingleObject(hReadEvent, FALSE, &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 })) { case STATUS_WAIT_0: @@ -198,7 +198,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) { } if (!NT_SUCCESS(status)) { - terminateChildProcess(hProcess, hChildPipeRead, NULL, &iosb); + terminateChildProcess(hProcess, hChildPipeRead, nullptr, &iosb); return "NtReadFile(hChildPipeRead) failed"; } @@ -219,7 +219,7 @@ exit: { } } - return NULL; + return nullptr; } bool ffProcessGetInfoWindows(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrbuf* exe, const char** exeName, FFstrbuf* exePath, bool* gui) { diff --git a/src/common/impl/properties.c b/src/common/impl/properties.c index c13ed1cd6..9a4fe290e 100644 --- a/src/common/impl/properties.c +++ b/src/common/impl/properties.c @@ -95,7 +95,7 @@ bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer) { bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries) { FF_AUTO_CLOSE_FILE FILE* file = fopen(filename, "r"); - if (file == NULL) { + if (file == nullptr) { return false; } @@ -115,7 +115,7 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer } if (!allSet) { - FF_AUTO_FREE char* line = NULL; + FF_AUTO_FREE char* line = nullptr; size_t len = 0; while (getline(&line, &len, file) != -1) { diff --git a/src/common/impl/settings.c b/src/common/impl/settings.c index 1e1d05f35..28a91b186 100644 --- a/src/common/impl/settings.c +++ b/src/common/impl/settings.c @@ -19,10 +19,10 @@ typedef struct GVariantGetters { static FFvariant getGVariantValue(GVariant* variant, FFvarianttype type, const GVariantGetters* variantGetters) { FFvariant result; - if (variant == NULL) { + if (variant == nullptr) { result = FF_VARIANT_NULL; } else if (type == FF_VARIANT_TYPE_STRING) { - result = (FFvariant) { .strValue = variantGetters->ffg_variant_dup_string(variant, NULL) }; // Dup string, so that variant itself can be freed + result = (FFvariant) { .strValue = variantGetters->ffg_variant_dup_string(variant, nullptr) }; // Dup string, so that variant itself can be freed } else if (type == FF_VARIANT_TYPE_BOOL) { result = (FFvariant) { .boolValue = (bool) variantGetters->ffg_variant_get_boolean(variant), .boolValueSet = true }; } else if (type == FF_VARIANT_TYPE_INT) { @@ -57,27 +57,27 @@ static const GSettingsData* getGSettingsData(void) { if (!data.inited) { data.inited = true; - FF_LIBRARY_LOAD(libgsettings, NULL, "libgio-2.0" FF_LIBRARY_EXTENSION, 1); - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_source_lookup, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_has_key, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_new_full, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_value, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_user_value, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_default_value, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_source_get_default, NULL) + FF_LIBRARY_LOAD(libgsettings, nullptr, "libgio-2.0" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_source_lookup, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_has_key, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_new_full, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_value, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_user_value, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_default_value, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_source_get_default, nullptr) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_dup_string, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_get_boolean, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_get_int32, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_unref, NULL); + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_dup_string, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_get_boolean, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_get_int32, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_unref, nullptr); data.schemaSource = data.ffg_settings_schema_source_get_default(); if (data.schemaSource) { - libgsettings = NULL; + libgsettings = nullptr; } } if (!data.schemaSource) { - return NULL; + return nullptr; } return &data; @@ -85,12 +85,12 @@ static const GSettingsData* getGSettingsData(void) { FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const char* key, FFvarianttype type) { const GSettingsData* data = getGSettingsData(); - if (data == NULL) { + if (data == nullptr) { return FF_VARIANT_NULL; } GSettingsSchema* schema = data->ffg_settings_schema_source_lookup(data->schemaSource, schemaName, true); - if (schema == NULL) { + if (schema == nullptr) { return FF_VARIANT_NULL; } @@ -98,18 +98,18 @@ FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const return FF_VARIANT_NULL; } - GSettings* settings = data->ffg_settings_new_full(schema, NULL, path); - if (settings == NULL) { + GSettings* settings = data->ffg_settings_new_full(schema, nullptr, path); + if (settings == nullptr) { return FF_VARIANT_NULL; } GVariant* variant = data->ffg_settings_get_value(settings, key); - if (variant != NULL) { + if (variant != nullptr) { return getGVariantValue(variant, type, &data->variantGetters); } variant = data->ffg_settings_get_user_value(settings, key); - if (variant != NULL) { + if (variant != nullptr) { return getGVariantValue(variant, type, &data->variantGetters); } @@ -141,21 +141,21 @@ static const DConfData* getDConfData(void) { if (!data.inited) { data.inited = true; - FF_LIBRARY_LOAD(libdconf, NULL, "libdconf" FF_LIBRARY_EXTENSION, 2); - FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_read_full, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_new, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_dup_string, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_get_boolean, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_get_int32, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_unref, NULL) + FF_LIBRARY_LOAD(libdconf, nullptr, "libdconf" FF_LIBRARY_EXTENSION, 2); + FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_read_full, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_new, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_dup_string, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_get_boolean, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_get_int32, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_unref, nullptr) data.client = data.ffdconf_client_new(); if (data.client) { - libdconf = NULL; + libdconf = nullptr; } } if (!data.client) { - return NULL; + return nullptr; } return &data; @@ -163,21 +163,21 @@ static const DConfData* getDConfData(void) { FFvariant ffSettingsGetDConf(const char* key, FFvarianttype type) { const DConfData* data = getDConfData(); - if (data == NULL) { + if (data == nullptr) { return FF_VARIANT_NULL; } - GVariant* variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_FLAGS_NONE, NULL); - if (variant != NULL) { + GVariant* variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_FLAGS_NONE, nullptr); + if (variant != nullptr) { return getGVariantValue(variant, type, &data->variantGetters); } - variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_USER_VALUE, NULL); - if (variant != NULL) { + variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_USER_VALUE, nullptr); + if (variant != nullptr) { return getGVariantValue(variant, type, &data->variantGetters); } - variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_DEFAULT_VALUE, NULL); + variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_DEFAULT_VALUE, nullptr); return getGVariantValue(variant, type, &data->variantGetters); } #else // FF_HAVE_DCONF @@ -192,7 +192,7 @@ FFvariant ffSettingsGetGnome(const char* dconfKey, const char* gsettingsSchemaNa if ( (type == FF_VARIANT_TYPE_BOOL && gsettings.boolValueSet) || - (type != FF_VARIANT_TYPE_BOOL && gsettings.strValue != NULL)) { + (type != FF_VARIANT_TYPE_BOOL && gsettings.strValue != nullptr)) { return gsettings; } @@ -204,7 +204,7 @@ FFvariant ffSettingsGetGnome(const char* dconfKey, const char* gsettingsSchemaNa FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvarianttype type) { FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; - if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != NULL) { + if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) { return FF_VARIANT_NULL; } @@ -260,7 +260,7 @@ FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvariant ffSettingsGetXFConfFirstMatch(const char* channelName, const char* propertyPrefix, FFvarianttype type, void* data, FFTestXfconfPropCallback* cb) { FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; - if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != NULL) { + if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) { return FF_VARIANT_NULL; } @@ -361,20 +361,20 @@ static const SQLiteData* getSQLiteData(void) { if (!data.inited) { data.inited = true; - FF_LIBRARY_LOAD(libsqlite, NULL, "libsqlite3" FF_LIBRARY_EXTENSION, 1); - FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_open_v2, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_prepare_v2, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_step, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_data_count, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_column_int, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_column_text, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_finalize, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_close, NULL) - libsqlite = NULL; + FF_LIBRARY_LOAD(libsqlite, nullptr, "libsqlite3" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_open_v2, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_prepare_v2, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_step, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_data_count, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_column_int, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_column_text, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_finalize, nullptr) + FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_close, nullptr) + libsqlite = nullptr; } if (!data.ffsqlite3_close) { - return NULL; + return nullptr; } return &data; @@ -386,17 +386,17 @@ int ffSettingsGetSQLite3Int(const char* dbPath, const char* query) { } const SQLiteData* data = getSQLiteData(); - if (data == NULL) { + if (data == nullptr) { return 0; } sqlite3* db; - if (data->ffsqlite3_open_v2(dbPath, &db, SQLITE_OPEN_READONLY | SQLITE_OPEN_NOMUTEX, NULL) != SQLITE_OK) { + if (data->ffsqlite3_open_v2(dbPath, &db, SQLITE_OPEN_READONLY | SQLITE_OPEN_NOMUTEX, nullptr) != SQLITE_OK) { return 0; } sqlite3_stmt* stmt; - if (data->ffsqlite3_prepare_v2(db, query, (int) strlen(query), &stmt, NULL) != SQLITE_OK) { + if (data->ffsqlite3_prepare_v2(db, query, (int) strlen(query), &stmt, nullptr) != SQLITE_OK) { data->ffsqlite3_close(db); return 0; } @@ -421,17 +421,17 @@ bool ffSettingsGetSQLite3String(const char* dbPath, const char* query, FFstrbuf* } const SQLiteData* data = getSQLiteData(); - if (data == NULL) { + if (data == nullptr) { return false; } sqlite3* db; - if (data->ffsqlite3_open_v2(dbPath, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) { + if (data->ffsqlite3_open_v2(dbPath, &db, SQLITE_OPEN_READONLY, nullptr) != SQLITE_OK) { return false; } sqlite3_stmt* stmt; - if (data->ffsqlite3_prepare_v2(db, query, (int) strlen(query), &stmt, NULL) != SQLITE_OK) { + if (data->ffsqlite3_prepare_v2(db, query, (int) strlen(query), &stmt, nullptr) != SQLITE_OK) { data->ffsqlite3_close(db); return false; } @@ -514,12 +514,12 @@ typedef struct E_Config { #define FF_EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, member, type) \ do { \ struct_type ___ett; \ - ffeet_data_descriptor_element_add(edd, #member, type, EET_G_UNKNOWN, (char*) (&(___ett.member)) - (char*) (&(___ett)), 0, /* 0, */ NULL, NULL); \ + ffeet_data_descriptor_element_add(edd, #member, type, EET_G_UNKNOWN, (char*) (&(___ett.member)) - (char*) (&(___ett)), 0, /* 0, */ nullptr, nullptr); \ } while (0) #define FF_EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, member, subtype) \ do { \ struct_type ___ett; \ - ffeet_data_descriptor_element_add(edd, #member, EET_T_UNKNOW, EET_G_LIST, (char*) (&(___ett.member)) - (char*) (&(___ett)), 0, /* 0, */ NULL, subtype); \ + ffeet_data_descriptor_element_add(edd, #member, EET_T_UNKNOW, EET_G_LIST, (char*) (&(___ett.member)) - (char*) (&(___ett)), 0, /* 0, */ nullptr, subtype); \ } while (0) bool ffSettingsGetEnlightenmentProperty(ffEnlightenmentSettings* result) { diff --git a/src/common/impl/size.c b/src/common/impl/size.c index 4e8d1e371..9019ac574 100644 --- a/src/common/impl/size.c +++ b/src/common/impl/size.c @@ -27,16 +27,16 @@ void ffSizeAppendNum(uint64_t bytes, FFstrbuf* result) { const FFOptionsDisplay* options = &instance.config.display; switch (options->sizeBinaryPrefix) { case FF_SIZE_BINARY_PREFIX_TYPE_IEC: - appendNum(result, bytes, 1024, (const char*[]) { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", NULL }); + appendNum(result, bytes, 1024, (const char*[]) { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", nullptr }); break; case FF_SIZE_BINARY_PREFIX_TYPE_SI: - appendNum(result, bytes, 1000, (const char*[]) { "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL }); + appendNum(result, bytes, 1000, (const char*[]) { "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", nullptr }); break; case FF_SIZE_BINARY_PREFIX_TYPE_JEDEC: - appendNum(result, bytes, 1024, (const char*[]) { "B", "KB", "MB", "GB", "TB", NULL }); + appendNum(result, bytes, 1024, (const char*[]) { "B", "KB", "MB", "GB", "TB", nullptr }); break; default: - appendNum(result, bytes, 1024, (const char*[]) { "B", NULL }); + appendNum(result, bytes, 1024, (const char*[]) { "B", nullptr }); break; } } diff --git a/src/common/impl/smbios.c b/src/common/impl/smbios.c index 028bcd9c1..88d898344 100644 --- a/src/common/impl/smbios.c +++ b/src/common/impl/smbios.c @@ -63,7 +63,7 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header) { } static bool parseSmbiosTable(const uint8_t* data, uint32_t length) { - const FFSmbiosHeader* endOfTable = NULL; + const FFSmbiosHeader* endOfTable = nullptr; FF_DEBUG("Parsing SMBIOS table structures with length %u bytes", length); FF_A_UNUSED int structureCount = 0, totalCount = 0; @@ -214,7 +214,7 @@ static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffe size_t pageOffset = (size_t) (address - alignedAddress); size_t mapLength = pageOffset + length; - void* p = mmap(NULL, mapLength, PROT_READ, MAP_SHARED, fd, alignedAddress); + void* p = mmap(nullptr, mapLength, PROT_READ, MAP_SHARED, fd, alignedAddress); if (p == MAP_FAILED) { FF_DEBUG("mmap failed at aligned address 0x%lx for %zu bytes: %s", (unsigned long) alignedAddress, @@ -457,7 +457,7 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { } while (address < lineEnd && (*address == ' ' || *address == '\t')); errno = 0; - char* addressEnd = NULL; + char* addressEnd = nullptr; unsigned long long parsedAddress = strtoull(address, &addressEnd, 16); if (errno != 0 || addressEnd == address || parsedAddress == 0) { FF_DEBUG("Failed to parse OpenBSD SMBIOS table address from line: %.*s", @@ -541,7 +541,7 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { } #endif - off_t entryAddress = (off_t) strtol(strEntryAddress.chars, NULL, 16); + off_t entryAddress = (off_t) strtol(strEntryAddress.chars, nullptr, 16); if (entryAddress == 0) { FF_DEBUG("Invalid SMBIOS entry address: 0"); return false; @@ -671,7 +671,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { if (!fillTableBufferFallback(&buffer)) { FF_DEBUG("Fallback SMBIOS retrieval also failed"); ffStrbufDestroy(&buffer); - return NULL; + return nullptr; } } @@ -682,7 +682,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { if (buffer.length == 0) { FF_DEBUG("No valid SMBIOS data available"); - return NULL; + return nullptr; } return &smbiosTable; @@ -717,13 +717,13 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { NtQuerySystemInformation(SystemFirmwareTableInformation, &sfti, sizeof(sfti), &bufSize); if (bufSize <= sizeof(FFRawSmbiosData) + sizeof(sfti)) { FF_DEBUG("Invalid firmware table size: %lu (must be > %zu)", bufSize, sizeof(FFRawSmbiosData) + sizeof(sfti)); - return NULL; + return nullptr; } if (bufSize != sfti.TableBufferLength + (ULONG) sizeof(sfti)) { FF_DEBUG("Firmware table size mismatch: NtQuerySystemInformation returned %lu but expected %lu", bufSize, sfti.TableBufferLength + (ULONG) sizeof(sfti)); - return NULL; + return nullptr; } FF_DEBUG("Firmware table size: %lu bytes", bufSize); @@ -734,8 +734,8 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { if (!NT_SUCCESS(NtQuerySystemInformation(SystemFirmwareTableInformation, buffer, bufSize, &bufSize))) { FF_DEBUG("NtQuerySystemInformation(SystemFirmwareTableInformation) failed"); free(buffer); - buffer = NULL; - return NULL; + buffer = nullptr; + return nullptr; } FFRawSmbiosData* rawData = (FFRawSmbiosData*) buffer->TableBuffer; @@ -746,14 +746,14 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { if (!parseSmbiosTable(rawData->SMBIOSTableData, rawData->Length)) { free(buffer); - buffer = NULL; - return NULL; + buffer = nullptr; + return nullptr; } } if (!buffer) { FF_DEBUG("No valid SMBIOS data available"); - return NULL; + return nullptr; } return &smbiosTable; } @@ -771,33 +771,33 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { if (!registryEntry) { FF_DEBUG("IOServiceGetMatchingService() failed to find AppleSMBIOS"); - return NULL; + return nullptr; } FF_DEBUG("AppleSMBIOS service found, retrieving SMBIOS data"); smbiosDataBuffer = IORegistryEntryCreateCFProperty(registryEntry, CFSTR("SMBIOS"), kCFAllocatorDefault, kNilOptions); if (!smbiosDataBuffer) { FF_DEBUG("IORegistryEntryCreateCFProperty() failed to get SMBIOS data"); - return NULL; + return nullptr; } if (CFGetTypeID(smbiosDataBuffer) != CFDataGetTypeID()) { FF_DEBUG("Unexpected SMBIOS data type: expected CFData"); CFRelease(smbiosDataBuffer); - smbiosDataBuffer = NULL; - return NULL; + smbiosDataBuffer = nullptr; + return nullptr; } FF_DEBUG("Successfully retrieved SMBIOS data: %lu bytes", CFDataGetLength(smbiosDataBuffer)); if (!parseSmbiosTable((const uint8_t*) CFDataGetBytePtr(smbiosDataBuffer), (uint32_t) CFDataGetLength(smbiosDataBuffer))) { CFRelease(smbiosDataBuffer); - smbiosDataBuffer = NULL; - return NULL; + smbiosDataBuffer = nullptr; + return nullptr; } } if (!smbiosDataBuffer) { FF_DEBUG("No valid SMBIOS data available"); - return NULL; + return nullptr; } return &smbiosTable; diff --git a/src/common/impl/sysctl.c b/src/common/impl/sysctl.c index 597469814..e17b5c348 100644 --- a/src/common/impl/sysctl.c +++ b/src/common/impl/sysctl.c @@ -5,26 +5,26 @@ #ifdef __OpenBSD__ const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result) { size_t neededLength; - if (sysctl((int[]) { mib1, mib2 }, 2, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) { // neededLength is 1 for empty strings, because of the null terminator + if (sysctl((int[]) { mib1, mib2 }, 2, nullptr, &neededLength, nullptr, 0) != 0 || neededLength == 1) { // neededLength is 1 for empty strings, because of the null terminator return "sysctl() length query failed"; } ffStrbufEnsureFree(result, (uint32_t) neededLength - 1); - if (sysctl((int[]) { mib1, mib2 }, 2, result->chars + result->length, &neededLength, NULL, 0) != 0) { + if (sysctl((int[]) { mib1, mib2 }, 2, result->chars + result->length, &neededLength, nullptr, 0) != 0) { return "sysctl() failed to retrieve string data"; } result->length += (uint32_t) neededLength - 1; result->chars[result->length] = '\0'; - return NULL; + return nullptr; } int ffSysctlGetInt(int mib1, int mib2, int defaultValue) { int result; size_t neededLength = sizeof(result); - if (sysctl((int[]) { mib1, mib2 }, 2, &result, &neededLength, NULL, 0) != 0) { + if (sysctl((int[]) { mib1, mib2 }, 2, &result, &neededLength, nullptr, 0) != 0) { return defaultValue; } return result; @@ -33,7 +33,7 @@ int ffSysctlGetInt(int mib1, int mib2, int defaultValue) { int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue) { int64_t result; size_t neededLength = sizeof(result); - if (sysctl((int[]) { mib1, mib2 }, 2, &result, &neededLength, NULL, 0) != 0) { + if (sysctl((int[]) { mib1, mib2 }, 2, &result, &neededLength, nullptr, 0) != 0) { return defaultValue; } return result; @@ -41,13 +41,13 @@ int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue) { #else const char* ffSysctlGetString(const char* propName, FFstrbuf* result) { size_t neededLength; - if (sysctlbyname(propName, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) { // neededLength is 1 for empty strings, because of the null terminator + if (sysctlbyname(propName, nullptr, &neededLength, nullptr, 0) != 0 || neededLength == 1) { // neededLength is 1 for empty strings, because of the null terminator return "sysctlbyname() failed"; } ffStrbufEnsureFree(result, (uint32_t) neededLength - 1); - if (sysctlbyname(propName, result->chars + result->length, &neededLength, NULL, 0) != 0) { + if (sysctlbyname(propName, result->chars + result->length, &neededLength, nullptr, 0) != 0) { return "sysctlbyname() failed to retrieve string data"; } @@ -55,13 +55,13 @@ const char* ffSysctlGetString(const char* propName, FFstrbuf* result) { result->chars[result->length] = '\0'; - return NULL; + return nullptr; } int ffSysctlGetInt(const char* propName, int defaultValue) { int result; size_t neededLength = sizeof(result); - if (sysctlbyname(propName, &result, &neededLength, NULL, 0) != 0) { + if (sysctlbyname(propName, &result, &neededLength, nullptr, 0) != 0) { return defaultValue; } return result; @@ -70,7 +70,7 @@ int ffSysctlGetInt(const char* propName, int defaultValue) { int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue) { int64_t result; size_t neededLength = sizeof(result); - if (sysctlbyname(propName, &result, &neededLength, NULL, 0) != 0) { + if (sysctlbyname(propName, &result, &neededLength, nullptr, 0) != 0) { return defaultValue; } return result; @@ -78,15 +78,15 @@ int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue) { #endif // OpenBSD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength) { - if (sysctl(request, requestLength, NULL, resultLength, NULL, 0) != 0) { - return NULL; + if (sysctl(request, requestLength, nullptr, resultLength, nullptr, 0) != 0) { + return nullptr; } void* data = malloc(*resultLength); - if (sysctl(request, requestLength, data, resultLength, NULL, 0) != 0) { + if (sysctl(request, requestLength, data, resultLength, nullptr, 0) != 0) { free(data); - return NULL; + return nullptr; } return data; diff --git a/src/common/impl/tracer.c b/src/common/impl/tracer.c index e031cad0d..b54f88467 100644 --- a/src/common/impl/tracer.c +++ b/src/common/impl/tracer.c @@ -67,10 +67,10 @@ __attribute__((destructor, no_instrument_function)) void trace_fini() { #if _WIN32 SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME); - SymInitialize(NtCurrentProcess(), NULL, TRUE); + SymInitialize(NtCurrentProcess(), nullptr, TRUE); #endif - const char* fnName = NULL; + const char* fnName = nullptr; uint32_t count = atomic_load_explicit(&event_count, memory_order_acquire); for (uint32_t i = 0; i < count; ++i) { diff --git a/src/common/io.h b/src/common/io.h index df69feb8c..2012d0db0 100644 --- a/src/common/io.h +++ b/src/common/io.h @@ -46,7 +46,7 @@ static inline bool ffIsValidNativeFD(FFNativeFD fd) { return fd >= 0; #else // https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443 - return fd != INVALID_HANDLE_VALUE && fd != NULL; + return fd != INVALID_HANDLE_VALUE && fd != nullptr; #endif } @@ -77,7 +77,7 @@ FF_A_NONNULL(3) static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, return write(fd, data, dataSize) != -1; #else DWORD written; - return WriteFile(fd, data, (DWORD) dataSize, &written, NULL) && written == dataSize; + return WriteFile(fd, data, (DWORD) dataSize, &written, nullptr) && written == dataSize; #endif } @@ -96,7 +96,7 @@ FF_A_NONNULL(3) static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSiz return read(fd, data, dataSize); #else DWORD bytesRead; - if (!ReadFile(fd, data, (DWORD) dataSize, &bytesRead, NULL)) { + if (!ReadFile(fd, data, (DWORD) dataSize, &bytesRead, nullptr)) { return -1; } @@ -111,7 +111,7 @@ FF_A_NONNULL(1, 3) static inline ssize_t ffReadFileData(const char* fileName, si #ifndef _WIN32 open(fileName, O_RDONLY | O_CLOEXEC); #else - CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if (!ffIsValidNativeFD(fd)) { @@ -135,7 +135,7 @@ FF_A_NONNULL(1, 2) static inline bool ffAppendFileBuffer(const char* fileName, F #ifndef _WIN32 open(fileName, O_RDONLY | O_CLOEXEC); #else - CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if (!ffIsValidNativeFD(fd)) { @@ -179,7 +179,7 @@ FF_A_NONNULL(1) static inline bool ffPathExists(const char* path, FFPathType pat #ifdef _WIN32 wchar_t wPath[MAX_PATH]; - if (!NT_SUCCESS(RtlUTF8ToUnicodeN(wPath, (ULONG) sizeof(wPath), NULL, path, (ULONG) strlen(path) + 1))) { + if (!NT_SUCCESS(RtlUTF8ToUnicodeN(wPath, (ULONG) sizeof(wPath), nullptr, path, (ULONG) strlen(path) + 1))) { return false; } diff --git a/src/common/library.h b/src/common/library.h index a584fbfc8..4d6cf2df1 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -37,8 +37,8 @@ static inline void ffLibraryUnload(void** handle) { #define FF_LIBRARY_LOAD(libraryObjectName, returnValue, libraryFileName, maxVersion, ...) \ void* FF_A_CLEANUP(ffLibraryUnload) libraryObjectName = ffLibraryLoadSingle(libraryFileName, maxVersion); \ - __VA_OPT__(if (__builtin_expect(libraryObjectName == NULL, false)) libraryObjectName = ffLibraryLoadMulti(__VA_ARGS__, NULL);) \ - if (__builtin_expect(libraryObjectName == NULL, false)) \ + __VA_OPT__(if (__builtin_expect(libraryObjectName == nullptr, false)) libraryObjectName = ffLibraryLoadMulti(__VA_ARGS__, nullptr);) \ + if (__builtin_expect(libraryObjectName == nullptr, false)) \ return returnValue; #define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \ @@ -46,7 +46,7 @@ static inline void ffLibraryUnload(void** handle) { #define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \ symbolMapping = (__typeof__(&symbolName)) dlsym(library, #symbolName); \ - if (__builtin_expect(symbolMapping == NULL, false)) \ + if (__builtin_expect(symbolMapping == nullptr, false)) \ return returnValue; #define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ @@ -78,7 +78,7 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...); __typeof__(&symbolName) ff##symbolName; #define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ - FF_A_UNUSED void* libraryObjectName = NULL; // Placeholder + FF_A_UNUSED void* libraryObjectName = nullptr; // Placeholder #define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \ FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__) diff --git a/src/common/settings.h b/src/common/settings.h index 5161ff1f2..bd96634f9 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -18,7 +18,7 @@ typedef union FFvariant { }; } FFvariant; -#define FF_VARIANT_NULL ((FFvariant) { .strValue = NULL }) +#define FF_VARIANT_NULL ((FFvariant) { .strValue = nullptr }) FFvariant ffSettingsGetDConf(const char* key, FFvarianttype type); FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const char* key, FFvarianttype type); diff --git a/src/common/smbios.h b/src/common/smbios.h index 532dbb028..744717cc6 100644 --- a/src/common/smbios.h +++ b/src/common/smbios.h @@ -84,7 +84,7 @@ static_assert(sizeof(FFSmbiosHeader) == 4, "FFSmbiosHeader should be 4 bytes"); static inline const char* ffSmbiosLocateString(const char* start, uint8_t index /* start from 1 */) { if (index == 0 || *start == '\0') { - return NULL; + return nullptr; } while (--index) { start += strlen(start) + 1; diff --git a/src/common/strutil.h b/src/common/strutil.h index 6d8b639b1..b6c36afae 100644 --- a/src/common/strutil.h +++ b/src/common/strutil.h @@ -18,7 +18,7 @@ __stdcall char* StrStrIA(const char* lpFirst, const char* lpSrch); #define FF_STR(x) FF_STR_INDIR(x) static inline bool ffStrSet(const char* str) { - if (str == NULL) { + if (str == nullptr) { return false; } @@ -69,17 +69,17 @@ static inline bool ffStrEquals(const char* str, const char* compareTo) { FF_A_ALWAYS_INLINE static inline bool ffStrContains(const char* str, const char* compareTo) { - return strstr(str, compareTo) != NULL; + return strstr(str, compareTo) != nullptr; } FF_A_ALWAYS_INLINE static inline bool ffStrContainsIgnCase(const char* str, const char* compareTo) { - return strcasestr(str, compareTo) != NULL; + return strcasestr(str, compareTo) != nullptr; } FF_A_ALWAYS_INLINE static inline bool ffStrContainsC(const char* str, char compareTo) { - return strchr(str, compareTo) != NULL; + return strchr(str, compareTo) != nullptr; } FF_A_ALWAYS_INLINE @@ -118,7 +118,7 @@ static inline int8_t ffHexCharToInt(char c) { // Copies at most (dstBufSiz - 1) bytes from src to dst; dst is always null-terminated static inline char* ffStrCopy(char* __restrict__ dst, const char* __restrict__ src, size_t dstBufSiz) { - if (__builtin_expect(dst == NULL, false) || dstBufSiz == 0) { + if (__builtin_expect(dst == nullptr, false) || dstBufSiz == 0) { return dst; } diff --git a/src/common/thread.h b/src/common/thread.h index 84c247cae..be82def60 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -18,7 +18,7 @@ static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { ReleaseSRWLockExclusive(mutex); } static inline FFThreadType ffThreadCreate(unsigned(__stdcall* func)(void*), void* data) { - return (FFThreadType) _beginthreadex(NULL, 0, func, data, 0, NULL); + return (FFThreadType) _beginthreadex(nullptr, 0, func, data, 0, nullptr); } #define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \ static __stdcall unsigned fn##ThreadMain(void* data) { \ @@ -34,7 +34,7 @@ static inline void ffThreadDetach(FFThreadType thread) { NtClose(thread); } static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout) { - if (NtWaitForSingleObject(thread, FALSE, timeout == 0 ? NULL : &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 }) != STATUS_WAIT_0) { + if (NtWaitForSingleObject(thread, FALSE, timeout == 0 ? nullptr : &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 }) != STATUS_WAIT_0) { TerminateThread(thread, (DWORD) -1); NtClose(thread); return false; @@ -74,18 +74,18 @@ static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { #endif static inline FFThreadType ffThreadCreate(void* (*func)(void*), void* data) { FFThreadType newThread = 0; - pthread_create(&newThread, NULL, func, data); + pthread_create(&newThread, nullptr, func, data); return newThread; } #define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \ static void* fn##ThreadMain(void* data) { \ fn((paramType) data); \ - return NULL; \ + return nullptr; \ } #define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \ static void* fn##ThreadMain() { \ fn(); \ - return NULL; \ + return nullptr; \ } static inline void ffThreadDetach(FFThreadType thread) { pthread_detach(thread); @@ -97,7 +97,7 @@ static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeou if (clock_gettime(CLOCK_REALTIME, &ts) == 0) { ts.tv_sec += timeout / 1000; ts.tv_nsec += (timeout % 1000) * 1000000; - if (pthread_timedjoin_np(thread, NULL, &ts) != 0) { + if (pthread_timedjoin_np(thread, nullptr, &ts) != 0) { pthread_kill(thread, SIGTERM); return false; } @@ -105,7 +105,7 @@ static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeou } } #endif - pthread_join(thread, NULL); + pthread_join(thread, nullptr); return true; } static inline uintptr_t ffThreadGetCurrentId() { diff --git a/src/common/time.h b/src/common/time.h index e2d86ab1d..a4d25341b 100644 --- a/src/common/time.h +++ b/src/common/time.h @@ -58,7 +58,7 @@ static inline bool ffTimeSleep(uint32_t msec) { interval.QuadPart = -(int64_t) msec * 10000; // Relative time in 100-nanosecond intervals return NT_SUCCESS(NtDelayExecution(TRUE, &interval)); #else - return nanosleep(&(struct timespec) { msec / 1000, (long) (msec % 1000) * 1000000 }, NULL) == 0; + return nanosleep(&(struct timespec) { msec / 1000, (long) (msec % 1000) * 1000000 }, nullptr) == 0; #endif } diff --git a/src/common/windows/com.c b/src/common/windows/com.c index a400ca9c6..1dab646cd 100644 --- a/src/common/windows/com.c +++ b/src/common/windows/com.c @@ -21,14 +21,14 @@ static const char* doInitCom() { return "RoInitialize() failed: unexpected error"; case RPC_E_CHANGED_MODE: // COM was already initialized with a different concurrency model - return NULL; + return nullptr; default: return "RoInitialize() failed: unknown error"; } } atexit(RoUninitializeWrap); - return NULL; + return nullptr; } #else #include @@ -38,7 +38,7 @@ static void CoUninitializeWrap(void) { } static const char* doInitCom() { - HRESULT res = CoInitializeEx(NULL, COINIT_MULTITHREADED); + HRESULT res = CoInitializeEx(nullptr, COINIT_MULTITHREADED); if (FAILED(res)) { switch (res) { case E_INVALIDARG: @@ -47,14 +47,14 @@ static const char* doInitCom() { return "CoInitializeEx() failed: out of memory"; case RPC_E_CHANGED_MODE: // COM was already initialized with a different concurrency model - return NULL; + return nullptr; default: return "CoInitializeEx() failed: unknown error"; } } atexit(CoUninitializeWrap); - return NULL; + return nullptr; } #endif diff --git a/src/common/windows/com.h b/src/common/windows/com.h index 57b8c6d81..d7a7dc090 100644 --- a/src/common/windows/com.h +++ b/src/common/windows/com.h @@ -16,7 +16,7 @@ static inline void ffReleaseComObject(void* ppUnknown) { #else pUnknown->lpVtbl->Release(pUnknown); #endif - *(IUnknown**) ppUnknown = NULL; + *(IUnknown**) ppUnknown = nullptr; } } diff --git a/src/common/windows/getline.c b/src/common/windows/getline.c index 3d43d55f3..fda41b0a4 100644 --- a/src/common/windows/getline.c +++ b/src/common/windows/getline.c @@ -7,7 +7,7 @@ ssize_t getline(char** lineptr, size_t* n, FILE* stream) { ssize_t pos = -1; int c; - if (lineptr == NULL || stream == NULL || n == NULL) { + if (lineptr == nullptr || stream == nullptr || n == nullptr) { errno = EINVAL; return -1; } @@ -19,9 +19,9 @@ ssize_t getline(char** lineptr, size_t* n, FILE* stream) { goto exit; } - if (*lineptr == NULL) { + if (*lineptr == nullptr) { *lineptr = malloc(128); - if (*lineptr == NULL) { + if (*lineptr == nullptr) { goto exit; } *n = 128; @@ -35,7 +35,7 @@ ssize_t getline(char** lineptr, size_t* n, FILE* stream) { new_size = 128; } char* new_ptr = realloc(*lineptr, new_size); - if (new_ptr == NULL) { + if (new_ptr == nullptr) { pos = -1; goto exit; } diff --git a/src/common/windows/registry.c b/src/common/windows/registry.c index 3618760c2..8bd2e09fd 100644 --- a/src/common/windows/registry.c +++ b/src/common/windows/registry.c @@ -42,7 +42,7 @@ HANDLE ffRegGetRootKeyHandle(HKEY hKey) { NTSTATUS status = RtlOpenCurrentUser(KEY_READ, &result); if (!NT_SUCCESS(status)) { FF_DEBUG("RtlOpenCurrentUser() failed: %s", ffDebugNtStatus(status)); - return NULL; + return nullptr; } break; } @@ -51,13 +51,13 @@ HANDLE ffRegGetRootKeyHandle(HKEY hKey) { UNICODE_STRING path = RTL_CONSTANT_STRING(L"\\Registry\\Machine"); NTSTATUS status = NtOpenKey(&result, KEY_READ, &(OBJECT_ATTRIBUTES) { .Length = sizeof(OBJECT_ATTRIBUTES), - .RootDirectory = NULL, + .RootDirectory = nullptr, .ObjectName = &path, .Attributes = OBJ_CASE_INSENSITIVE, }); if (!NT_SUCCESS(status)) { FF_DEBUG("NtOpenKey(%ls) failed: %s (0x%08lx)", path.Buffer, ffDebugNtStatus(status), status); - return NULL; + return nullptr; } break; } @@ -65,7 +65,7 @@ HANDLE ffRegGetRootKeyHandle(HKEY hKey) { // Unsupported FF_DEBUG("Unsupported root key: %p", hKey); assert(false); - return NULL; + return nullptr; } hRootKeys[(uintptr_t) hKey - (uintptr_t) HKEY_CLASSES_ROOT] = result; FF_DEBUG("Opened root key %s -> %p", hKey2Str(result), result); @@ -241,7 +241,7 @@ bool ffRegReadValue(HANDLE hKey, const FFRegValueArg* arg, FFstrbuf* error) { }; alignas(KEY_VALUE_PARTIAL_INFORMATION) uint8_t staticBuffer[128 + sizeof(KEY_VALUE_PARTIAL_INFORMATION)]; - FF_AUTO_FREE uint8_t* dynamicBuffer = NULL; + FF_AUTO_FREE uint8_t* dynamicBuffer = nullptr; KEY_VALUE_PARTIAL_INFORMATION* buffer = (KEY_VALUE_PARTIAL_INFORMATION*) &staticBuffer; DWORD bufSize = sizeof(staticBuffer); @@ -287,9 +287,9 @@ bool ffRegReadValues(HANDLE hKey, uint32_t argc, const FFRegValueArg argv[], FFs for (uint32_t i = 0; i < argc; ++i) { if (__builtin_expect(!argv[i].value, false)) { - FF_DEBUG("ffRegReadValues(argv[%u].value) is NULL", (unsigned) i); + FF_DEBUG("ffRegReadValues(argv[%u].value) is nullptr", (unsigned) i); if (error) { - ffStrbufAppendF(error, "ffRegReadValues(argv[%u].pVar) is NULL", (unsigned) i); + ffStrbufAppendF(error, "ffRegReadValues(argv[%u].pVar) is nullptr", (unsigned) i); } return false; } @@ -307,7 +307,7 @@ bool ffRegReadValues(HANDLE hKey, uint32_t argc, const FFRegValueArg argv[], FFs bufferSize = 512; } - FF_AUTO_FREE uint8_t* buffer = NULL; + FF_AUTO_FREE uint8_t* buffer = nullptr; while (true) { buffer = (uint8_t*) realloc(buffer, bufferSize); diff --git a/src/common/windows/unicode.c b/src/common/windows/unicode.c index 06008ba42..534c399f2 100644 --- a/src/common/windows/unicode.c +++ b/src/common/windows/unicode.c @@ -9,7 +9,7 @@ void ffStrbufSetNWS(FFstrbuf* result, uint32_t length, const wchar_t* source) { } ULONG size_needed = 0; - NTSTATUS status = RtlUnicodeToUTF8N(NULL, 0, &size_needed, source, length * sizeof(wchar_t)); + NTSTATUS status = RtlUnicodeToUTF8N(nullptr, 0, &size_needed, source, length * sizeof(wchar_t)); if (size_needed == 0) { ffStrbufSetF(result, "RtlUnicodeToUTF8N failed: %X", (unsigned) status); @@ -29,7 +29,7 @@ void ffStrbufAppendNWS(FFstrbuf* result, uint32_t length, const wchar_t* source) } ULONG size_needed = 0; - NTSTATUS status = RtlUnicodeToUTF8N(NULL, 0, &size_needed, source, length * sizeof(wchar_t)); + NTSTATUS status = RtlUnicodeToUTF8N(nullptr, 0, &size_needed, source, length * sizeof(wchar_t)); if (size_needed == 0) { ffStrbufAppendF(result, "RtlUnicodeToUTF8N failed: %X", (unsigned) status); diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index d76c4adaa..5b8176069 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_android.c @@ -17,11 +17,11 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) { static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); - if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL })) { + if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, nullptr })) { return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; } - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); if (!doc) { return "Failed to parse battery info"; } @@ -66,7 +66,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results) { battery->temperature = yyjson_get_num(yyjson_obj_get(root, "temperature")); } - return NULL; + return nullptr; } static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results) { @@ -74,8 +74,8 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results) { if (ffProcessAppendStdOut(&buf, (char*[]) { "/system/bin/dumpsys", "battery", - NULL, - }) != NULL || + nullptr, + }) != nullptr || buf.length == 0) { return "Executing `/system/bin/dumpsys battery` failed"; // Only works in `adb shell`, or when rooted } @@ -88,7 +88,7 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY temp = ffStrbufCreate(); if (!ffParsePropLines(start, "present: ", &temp) || !ffStrbufEqualS(&temp, "true")) { - return NULL; + return nullptr; } ffStrbufClear(&temp); @@ -148,13 +148,13 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results) { ffParsePropLines(start, "technology: ", &battery->technology); - return NULL; + return nullptr; } const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { const char* error = parseTermuxApi(options, results); - if (error && parseDumpsys(options, results) == NULL) { - return NULL; + if (error && parseDumpsys(options, results) == nullptr) { + return nullptr; } return error; } diff --git a/src/detection/battery/battery_apple.c b/src/detection/battery/battery_apple.c index c22aa6d43..fb6030391 100644 --- a/src/detection/battery/battery_apple.c +++ b/src/detection/battery/battery_apple.c @@ -15,18 +15,18 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { io_registry_entry_t registryEntry; while ((registryEntry = IOIteratorNext(iterator)) != IO_OBJECT_NULL) { FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryBattery = registryEntry; - FF_CFTYPE_AUTO_RELEASE CFMutableDictionaryRef properties = NULL; + FF_CFTYPE_AUTO_RELEASE CFMutableDictionaryRef properties = nullptr; if (IORegistryEntryCreateCFProperties(entryBattery, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { continue; } int currentCapacity, maxCapacity; - if (ffCfDictGetInt(properties, CFSTR(kIOPMPSMaxCapacityKey), &maxCapacity) != NULL || maxCapacity <= 0) { + if (ffCfDictGetInt(properties, CFSTR(kIOPMPSMaxCapacityKey), &maxCapacity) != nullptr || maxCapacity <= 0) { continue; } - if (ffCfDictGetInt(properties, CFSTR(kIOPMPSCurrentCapacityKey), ¤tCapacity) != NULL || currentCapacity <= 0) { + if (ffCfDictGetInt(properties, CFSTR(kIOPMPSCurrentCapacityKey), ¤tCapacity) != nullptr || currentCapacity <= 0) { continue; } @@ -63,7 +63,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { battery->cycleCount = cycleCount < 0 ? 0 : (uint32_t) cycleCount; battery->timeRemaining = -1; - if (ffCfDictGetBool(properties, CFSTR(kIOPMPSExternalConnectedKey), &boolValue) == NULL) { + if (ffCfDictGetBool(properties, CFSTR(kIOPMPSExternalConnectedKey), &boolValue) == nullptr) { if (boolValue) { battery->status |= FF_BATTERY_STATUS_AC_CONNECTED; } else { @@ -76,24 +76,24 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { } } } - if (ffCfDictGetBool(properties, CFSTR(kIOPMPSIsChargingKey), &boolValue) == NULL && boolValue) { + if (ffCfDictGetBool(properties, CFSTR(kIOPMPSIsChargingKey), &boolValue) == nullptr && boolValue) { battery->status |= FF_BATTERY_STATUS_CHARGING; } - if (ffCfDictGetBool(properties, CFSTR(kIOPMPSAtCriticalLevelKey), &boolValue) == NULL && boolValue) { + if (ffCfDictGetBool(properties, CFSTR(kIOPMPSAtCriticalLevelKey), &boolValue) == nullptr && boolValue) { battery->status |= FF_BATTERY_STATUS_CRITICAL; } int sbdsManufactureDate = 0; - if (ffCfDictGetInt(properties, CFSTR(kIOPMPSManufactureDateKey), &sbdsManufactureDate) == NULL) { + if (ffCfDictGetInt(properties, CFSTR(kIOPMPSManufactureDateKey), &sbdsManufactureDate) == nullptr) { int day = sbdsManufactureDate & 0b11111; int month = (sbdsManufactureDate >> 5) & 0b1111; int year = (sbdsManufactureDate >> 9) + 1800; ffStrbufSetF(&battery->manufactureDate, "%.4d-%.2d-%.2d", year, month, day); } else { CFDictionaryRef batteryData; - if (ffCfDictGetDict(properties, CFSTR("BatteryData"), &batteryData) == NULL) { + if (ffCfDictGetDict(properties, CFSTR("BatteryData"), &batteryData) == nullptr) { char manufactureDate[sizeof(uint64_t)]; - if (ffCfDictGetInt64(batteryData, CFSTR(kIOPMPSManufactureDateKey), (int64_t*) manufactureDate) == NULL) { + if (ffCfDictGetInt64(batteryData, CFSTR(kIOPMPSManufactureDateKey), (int64_t*) manufactureDate) == nullptr) { // https://github.com/AsahiLinux/linux/blob/b5c05cbffb0488c7618106926d522cc3b43d93d5/drivers/power/supply/macsmc_power.c#L410-L419 int year = (manufactureDate[0] - '0') * 10 + (manufactureDate[1] - '0') + 2000 - 8; int month = (manufactureDate[2] - '0') * 10 + (manufactureDate[3] - '0'); @@ -113,5 +113,5 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { } } - return NULL; + return nullptr; } diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 336a17e06..a51f72708 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -18,7 +18,7 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul } if (units == 0) { - return NULL; + return nullptr; } FF_AUTO_CLOSE_FD int acpifd = open("/dev/acpi", O_RDONLY | O_CLOEXEC); @@ -86,5 +86,5 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul } #endif } - return NULL; + return nullptr; } diff --git a/src/detection/battery/battery_haiku.c b/src/detection/battery/battery_haiku.c index aa620e6e5..22726bf32 100644 --- a/src/detection/battery/battery_haiku.c +++ b/src/detection/battery/battery_haiku.c @@ -50,7 +50,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) { battery->status |= FF_BATTERY_STATUS_AC_CONNECTED; } - return NULL; + return nullptr; } const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) { @@ -67,5 +67,5 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul parseBattery(dirfd(dir), entry->d_name, results); } - return NULL; + return nullptr; } diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index 6c1f71125..0362cbcd1 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -175,14 +175,14 @@ static bool parseBattery(int dfd, const char* id, FFBatteryOptions* options, FFl const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/power_supply/"); - if (dirp == NULL) { - return "opendir(\"/sys/class/power_supply/\") == NULL"; + if (dirp == nullptr) { + return "opendir(\"/sys/class/power_supply/\") == nullptr"; } bool acConnected = false; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -199,5 +199,5 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { } } - return NULL; + return nullptr; } diff --git a/src/detection/battery/battery_nbsd.c b/src/detection/battery/battery_nbsd.c index 2e8b42680..fda4ef0db 100644 --- a/src/detection/battery/battery_nbsd.c +++ b/src/detection/battery/battery_nbsd.c @@ -20,7 +20,7 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed"; } - prop_dictionary_t root = NULL; + prop_dictionary_t root = nullptr; if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &root) < 0) { return "prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed"; } @@ -35,7 +35,7 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul } prop_object_iterator_t itKey = prop_dictionary_iterator(root); - for (prop_dictionary_keysym_t key; (key = prop_object_iterator_next(itKey)) != NULL;) { + for (prop_dictionary_keysym_t key; (key = prop_object_iterator_next(itKey)) != nullptr;) { if (!ffStrStartsWith(prop_dictionary_keysym_value(key), "acpibat")) { continue; } @@ -44,12 +44,12 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul uint32_t max = 0, curr = 0, dischargeRate = 0; bool charging = false, critical = false; prop_object_iterator_t iter = prop_array_iterator(bat); - for (prop_dictionary_t dict; (dict = prop_object_iterator_next(iter)) != NULL;) { + for (prop_dictionary_t dict; (dict = prop_object_iterator_next(iter)) != nullptr;) { if (prop_object_type(dict) != PROP_TYPE_DICTIONARY) { continue; } - const char* desc = NULL; + const char* desc = nullptr; if (!prop_dictionary_get_string(dict, "description", &desc)) { continue; } @@ -64,7 +64,7 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul } else if (ffStrEquals(desc, "charge")) { prop_dictionary_get_uint32(dict, "max-value", &max); prop_dictionary_get_uint32(dict, "cur-value", &curr); - const char* state = NULL; + const char* state = nullptr; if (prop_dictionary_get_string(dict, "state", &state) && ffStrEquals(state, "critical")) { critical = true; } @@ -105,5 +105,5 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul prop_object_iterator_release(itKey); prop_object_release(root); - return NULL; + return nullptr; } diff --git a/src/detection/battery/battery_obsd.c b/src/detection/battery/battery_obsd.c index ee664ce69..8de17bcd9 100644 --- a/src/detection/battery/battery_obsd.c +++ b/src/detection/battery/battery_obsd.c @@ -20,7 +20,7 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul } if (info.battery_state == APM_BATTERY_ABSENT) { - return NULL; + return nullptr; } FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *result); @@ -56,5 +56,5 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul } } - return NULL; + return nullptr; } diff --git a/src/detection/battery/battery_windows.c b/src/detection/battery/battery_windows.c index 84f2a907c..7a57c191b 100644 --- a/src/detection/battery/battery_windows.c +++ b/src/detection/battery/battery_windows.c @@ -51,21 +51,21 @@ static FFBatteryWmiEntry* getBatteryEntry(FFlist* entries, FFlist* results, ULON } static const char* queryWmiAllData(const GUID* guid, const char* guidStr, PWNODE_ALL_DATA* pAllData, ULONG* pBufferSize) { - FF_AUTO_CLOSE_WMI_BLOCK HANDLE hBlock = NULL; + FF_AUTO_CLOSE_WMI_BLOCK HANDLE hBlock = nullptr; ULONG status = WmiOpenBlock(guid, WMIGUID_QUERY, &hBlock); if (status != ERROR_SUCCESS) { FF_DEBUG("WMI: WmiOpenBlock() failed for %s: %s", guidStr, ffDebugWin32Error(status)); return "WmiOpenBlock() failed"; } - status = WmiQueryAllDataW(hBlock, pBufferSize, NULL); + status = WmiQueryAllDataW(hBlock, pBufferSize, nullptr); if (status != ERROR_SUCCESS && status != ERROR_INSUFFICIENT_BUFFER) { FF_DEBUG("WMI: first WmiQueryAllDataW() failed: %s", ffDebugWin32Error(status)); - return "WmiQueryAllDataW(NULL) failed"; + return "WmiQueryAllDataW(nullptr) failed"; } if (*pBufferSize == 0) { - return "WmiQueryAllDataW(NULL) returned no data"; + return "WmiQueryAllDataW(nullptr) returned no data"; } if (*pBufferSize < sizeof(WNODE_ALL_DATA)) { @@ -79,11 +79,11 @@ static const char* queryWmiAllData(const GUID* guid, const char* guidStr, PWNODE if (status != ERROR_SUCCESS) { FF_DEBUG("WMI: second WmiQueryAllDataW failed: %s", ffDebugWin32Error(status)); free(*pAllData); - *pAllData = NULL; + *pAllData = nullptr; return "WmiQueryAllDataW(*pAllData) failed"; } - return NULL; + return nullptr; } static bool getInstanceData(const PWNODE_ALL_DATA allData, ULONG bufferSize, ULONG index, const uint8_t** instanceData, ULONG* instanceLength) { @@ -109,7 +109,7 @@ static bool getInstanceData(const PWNODE_ALL_DATA allData, ULONG bufferSize, ULO static void detectStaticData(FFlist* entries, FFlist* results) { FF_DEBUG("detectStaticData"); - FF_AUTO_FREE PWNODE_ALL_DATA allData = NULL; + FF_AUTO_FREE PWNODE_ALL_DATA allData = nullptr; ULONG bufferSize = 0; const char* error = queryWmiAllData(&BATTERY_STATIC_DATA_WMI_GUID, "BATTERY_STATIC_DATA_WMI_GUID", &allData, &bufferSize); if (error) { @@ -117,7 +117,7 @@ static void detectStaticData(FFlist* entries, FFlist* results) { } for (ULONG i = 0; i < allData->InstanceCount; ++i) { - const uint8_t* instanceData = NULL; + const uint8_t* instanceData = nullptr; ULONG instanceLength = 0; if (!getInstanceData(allData, bufferSize, i, &instanceData, &instanceLength) || instanceLength < offsetof(BATTERY_WMI_STATIC_DATA, Strings)) { continue; @@ -187,7 +187,7 @@ static void detectStaticData(FFlist* entries, FFlist* results) { static void detectStatus(FFlist* entries, FFlist* results) { FF_DEBUG("detectStatus"); - FF_AUTO_FREE PWNODE_ALL_DATA allData = NULL; + FF_AUTO_FREE PWNODE_ALL_DATA allData = nullptr; ULONG bufferSize = 0; const char* error = queryWmiAllData(&BATTERY_STATUS_WMI_GUID, "BATTERY_STATUS_WMI_GUID", &allData, &bufferSize); if (error) { @@ -195,7 +195,7 @@ static void detectStatus(FFlist* entries, FFlist* results) { } for (ULONG i = 0; i < allData->InstanceCount; ++i) { - const uint8_t* instanceData = NULL; + const uint8_t* instanceData = nullptr; ULONG instanceLength = 0; if (!getInstanceData(allData, bufferSize, i, &instanceData, &instanceLength) || instanceLength < sizeof(BATTERY_WMI_STATUS)) { continue; @@ -225,7 +225,7 @@ static void detectStatus(FFlist* entries, FFlist* results) { static void detectRuntime(FFlist* entries, FFlist* results) { FF_DEBUG("detectRuntime"); - FF_AUTO_FREE PWNODE_ALL_DATA allData = NULL; + FF_AUTO_FREE PWNODE_ALL_DATA allData = nullptr; ULONG bufferSize = 0; const char* error = queryWmiAllData(&BATTERY_RUNTIME_WMI_GUID, "BATTERY_RUNTIME_WMI_GUID", &allData, &bufferSize); if (error) { @@ -233,7 +233,7 @@ static void detectRuntime(FFlist* entries, FFlist* results) { } for (ULONG i = 0; i < allData->InstanceCount; ++i) { - const uint8_t* instanceData = NULL; + const uint8_t* instanceData = nullptr; ULONG instanceLength = 0; if (!getInstanceData(allData, bufferSize, i, &instanceData, &instanceLength) || instanceLength < sizeof(BATTERY_WMI_RUNTIME)) { continue; @@ -249,7 +249,7 @@ static void detectRuntime(FFlist* entries, FFlist* results) { static void detectFullChargedCapacity(FFlist* entries, FFlist* results) { FF_DEBUG("detectFullChargedCapacity"); - FF_AUTO_FREE PWNODE_ALL_DATA allData = NULL; + FF_AUTO_FREE PWNODE_ALL_DATA allData = nullptr; ULONG bufferSize = 0; const char* error = queryWmiAllData(&BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID, "BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID", &allData, &bufferSize); if (error) { @@ -257,7 +257,7 @@ static void detectFullChargedCapacity(FFlist* entries, FFlist* results) { } for (ULONG i = 0; i < allData->InstanceCount; ++i) { - const uint8_t* instanceData = NULL; + const uint8_t* instanceData = nullptr; ULONG instanceLength = 0; if (!getInstanceData(allData, bufferSize, i, &instanceData, &instanceLength) || instanceLength < sizeof(BATTERY_WMI_FULL_CHARGED_CAPACITY)) { continue; @@ -275,7 +275,7 @@ static void detectFullChargedCapacity(FFlist* entries, FFlist* results) { static void detectCycleCount(FFlist* entries, FFlist* results) { FF_DEBUG("detectCycleCount"); - FF_AUTO_FREE PWNODE_ALL_DATA allData = NULL; + FF_AUTO_FREE PWNODE_ALL_DATA allData = nullptr; ULONG bufferSize = 0; const char* error = queryWmiAllData(&BATTERY_CYCLE_COUNT_WMI_GUID, "BATTERY_CYCLE_COUNT_WMI_GUID", &allData, &bufferSize); if (error) { @@ -283,7 +283,7 @@ static void detectCycleCount(FFlist* entries, FFlist* results) { } for (ULONG i = 0; i < allData->InstanceCount; ++i) { - const uint8_t* instanceData = NULL; + const uint8_t* instanceData = nullptr; ULONG instanceLength = 0; if (!getInstanceData(allData, bufferSize, i, &instanceData, &instanceLength) || instanceLength < sizeof(BATTERY_WMI_CYCLE_COUNT)) { continue; @@ -296,7 +296,7 @@ static void detectCycleCount(FFlist* entries, FFlist* results) { static void detectTemperature(FFlist* entries, FFlist* results) { FF_DEBUG("detectTemperature"); - FF_AUTO_FREE PWNODE_ALL_DATA allData = NULL; + FF_AUTO_FREE PWNODE_ALL_DATA allData = nullptr; ULONG bufferSize = 0; const char* error = queryWmiAllData(&BATTERY_TEMPERATURE_WMI_GUID, "BATTERY_TEMPERATURE_WMI_GUID", &allData, &bufferSize); if (error) { @@ -304,7 +304,7 @@ static void detectTemperature(FFlist* entries, FFlist* results) { } for (ULONG i = 0; i < allData->InstanceCount; ++i) { - const uint8_t* instanceData = NULL; + const uint8_t* instanceData = nullptr; ULONG instanceLength = 0; if (!getInstanceData(allData, bufferSize, i, &instanceData, &instanceLength) || instanceLength < sizeof(BATTERY_WMI_TEMPERATURE)) { continue; @@ -319,7 +319,7 @@ static const char* detectWithNtApi(FFBatteryResult* battery) { // Reports summary battery information, not per battery FF_DEBUG("NtApi: start detection"); SYSTEM_BATTERY_STATE info; - NTSTATUS status = NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info)); + NTSTATUS status = NtPowerInformation(SystemBatteryState, nullptr, 0, &info, sizeof(info)); if (!NT_SUCCESS(status)) { FF_DEBUG("NtApi: NtPowerInformation(SystemBatteryState) failed: %s", ffDebugNtStatus(status)); return "NtPowerInformation(SystemBatteryState) failed"; @@ -346,7 +346,7 @@ static const char* detectWithNtApi(FFBatteryResult* battery) { battery->status |= FF_BATTERY_STATUS_CRITICAL; } battery->timeRemaining = info.EstimatedTime == BATTERY_UNKNOWN_TIME ? -1 : (int32_t) info.EstimatedTime; - return NULL; + return nullptr; } const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { @@ -355,7 +355,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { FF_LIST_AUTO_DESTROY entries = ffListCreate(); detectStaticData(&entries, results); if (results->length == 0) { - return NULL; + return nullptr; } else if (results->length == 1) { // Fast path for single battery detectWithNtApi(FF_LIST_FIRST(FFBatteryWmiEntry, entries)->result); @@ -380,5 +380,5 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { } FF_DEBUG("WMI: finished detection, total results=%u", results->length); - return NULL; + return nullptr; } diff --git a/src/detection/bios/bios_android.c b/src/detection/bios/bios_android.c index a53db0db5..7d3409a28 100644 --- a/src/detection/bios/bios_android.c +++ b/src/detection/bios/bios_android.c @@ -12,5 +12,5 @@ const char* ffDetectBios(FFBiosResult* bios) { ffStrbufSetStatic(&bios->type, "Bootloader"); - return NULL; + return nullptr; } diff --git a/src/detection/bios/bios_apple.c b/src/detection/bios/bios_apple.c index 6b046d2ea..c9a6759b6 100644 --- a/src/detection/bios/bios_apple.c +++ b/src/detection/bios/bios_apple.c @@ -13,7 +13,7 @@ const char* ffDetectBios(FFBiosResult* bios) { return "IODeviceTree:/rom not found"; } - FF_CFTYPE_AUTO_RELEASE CFMutableDictionaryRef deviceRomProps = NULL; + FF_CFTYPE_AUTO_RELEASE CFMutableDictionaryRef deviceRomProps = nullptr; if (IORegistryEntryCreateCFProperties(deviceRom, &deviceRomProps, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { return "IORegistryEntryCreateCFProperties(deviceRom) failed"; } @@ -54,5 +54,5 @@ const char* ffDetectBios(FFBiosResult* bios) { } #endif - return NULL; + return nullptr; } diff --git a/src/detection/bios/bios_bsd.c b/src/detection/bios/bios_bsd.c index 66e50ea51..93f21eaac 100644 --- a/src/detection/bios/bios_bsd.c +++ b/src/detection/bios/bios_bsd.c @@ -27,5 +27,5 @@ const char* ffDetectBios(FFBiosResult* result) { : "BIOS"); } } - return NULL; + return nullptr; } diff --git a/src/detection/bios/bios_linux.c b/src/detection/bios/bios_linux.c index 8776631e2..9db76a54b 100644 --- a/src/detection/bios/bios_linux.c +++ b/src/detection/bios/bios_linux.c @@ -17,5 +17,5 @@ const char* ffDetectBios(FFBiosResult* bios) { } else { ffStrbufSetStatic(&bios->type, "BIOS"); } - return NULL; + return nullptr; } diff --git a/src/detection/bios/bios_nbsd.c b/src/detection/bios/bios_nbsd.c index 3ab43ed0b..836f836b2 100644 --- a/src/detection/bios/bios_nbsd.c +++ b/src/detection/bios/bios_nbsd.c @@ -4,17 +4,17 @@ #include "common/io.h" const char* ffDetectBios(FFBiosResult* bios) { - if (ffSysctlGetString("machdep.dmi.bios-date", &bios->date) == NULL) { + if (ffSysctlGetString("machdep.dmi.bios-date", &bios->date) == nullptr) { ffCleanUpSmbiosValue(&bios->date); } - if (ffSysctlGetString("machdep.dmi.bios-version", &bios->version) == NULL) { + if (ffSysctlGetString("machdep.dmi.bios-version", &bios->version) == nullptr) { ffCleanUpSmbiosValue(&bios->version); } - if (ffSysctlGetString("machdep.dmi.bios-vendor", &bios->vendor) == NULL) { + if (ffSysctlGetString("machdep.dmi.bios-vendor", &bios->vendor) == nullptr) { ffCleanUpSmbiosValue(&bios->vendor); } - if (ffSysctlGetString("machdep.bootmethod", &bios->type) != NULL) { + if (ffSysctlGetString("machdep.bootmethod", &bios->type) != nullptr) { ffStrbufSetStatic(&bios->type, ffPathExists("/dev/efi", FF_PATHTYPE_FILE) ? "UEFI" : "BIOS"); } - return NULL; + return nullptr; } diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index 42b7674a4..211d6a9b0 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -71,7 +71,7 @@ const char* ffDetectBios(FFBiosResult* bios) { // Same as GetFirmwareType, but support (?) Windows 7 // https://ntdoc.m417z.com/system_information_class SYSTEM_BOOT_ENVIRONMENT_INFORMATION sbei; - if (NT_SUCCESS(NtQuerySystemInformation(SystemBootEnvironmentInformation, &sbei, sizeof(sbei), NULL))) { + if (NT_SUCCESS(NtQuerySystemInformation(SystemBootEnvironmentInformation, &sbei, sizeof(sbei), nullptr))) { switch (sbei.FirmwareType) { case FirmwareTypeBios: ffStrbufSetStatic(&bios->type, "BIOS"); @@ -86,7 +86,7 @@ const char* ffDetectBios(FFBiosResult* bios) { #elif __sun di_node_t rootNode = di_init("/", DINFOPROP); if (rootNode != DI_NODE_NIL) { - char* efiVersion = NULL; + char* efiVersion = nullptr; if (di_prop_lookup_strings(DDI_DEV_T_ANY, rootNode, "efi-version", &efiVersion) > 0) { ffStrbufSetStatic(&bios->type, "UEFI"); } else { @@ -103,5 +103,5 @@ const char* ffDetectBios(FFBiosResult* bios) { ffStrbufSetStatic(&bios->type, deviceEfi ? "UEFI" : "BIOS"); #endif - return NULL; + return nullptr; } diff --git a/src/detection/bluetooth/bluetooth_apple.m b/src/detection/bluetooth/bluetooth_apple.m index 9cbf732a5..22ae236b5 100644 --- a/src/detection/bluetooth/bluetooth_apple.m +++ b/src/detection/bluetooth/bluetooth_apple.m @@ -108,5 +108,5 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF } } - return NULL; + return nullptr; } diff --git a/src/detection/bluetooth/bluetooth_bsd.c b/src/detection/bluetooth/bluetooth_bsd.c index db9f23cf7..b70157753 100644 --- a/src/detection/bluetooth/bluetooth_bsd.c +++ b/src/detection/bluetooth/bluetooth_bsd.c @@ -12,7 +12,7 @@ static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* dev->devname #endif ); - ffStrbufInitS(&device->address, bt_ntoa(&dev->bdaddr, NULL)); + ffStrbufInitS(&device->address, bt_ntoa(&dev->bdaddr, nullptr)); ffStrbufUpperCase(&device->address); ffStrbufInit(&device->type); device->battery = 0; @@ -26,5 +26,5 @@ const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUS return "bt_devenum() failed"; } - return NULL; + return nullptr; } diff --git a/src/detection/bluetooth/bluetooth_haiku.cpp b/src/detection/bluetooth/bluetooth_haiku.cpp index 8ed52c5ac..7efb69722 100644 --- a/src/detection/bluetooth/bluetooth_haiku.cpp +++ b/src/detection/bluetooth/bluetooth_haiku.cpp @@ -11,7 +11,7 @@ const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* d LocalDevice* dev = LocalDevice::GetLocalDevice(); if (!dev) { - return NULL; + return nullptr; } BString devClass; @@ -26,5 +26,5 @@ const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* d // TODO: more devices? - return NULL; + return nullptr; } diff --git a/src/detection/bluetooth/bluetooth_linux.c b/src/detection/bluetooth/bluetooth_linux.c index fb4e42242..f99d8289e 100644 --- a/src/detection/bluetooth/bluetooth_linux.c +++ b/src/detection/bluetooth/bluetooth_linux.c @@ -124,14 +124,14 @@ static void detectBluetoothProperty(FFDBusData* dbus, DBusMessageIter* iter, FFB static FFBluetoothResult* detectBluetoothObject(FFlist* devices, FFDBusData* dbus, DBusMessageIter* iter) { if (dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY) { - return NULL; + return nullptr; } DBusMessageIter dictIter; dbus->lib->ffdbus_message_iter_recurse(iter, &dictIter); if (dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_OBJECT_PATH) { - return NULL; + return nullptr; } const char* objectPath; @@ -139,13 +139,13 @@ static FFBluetoothResult* detectBluetoothObject(FFlist* devices, FFDBusData* dbu // We don't want adapter objects if (!ffStrContains(objectPath, "/dev_")) { - return NULL; + return nullptr; } dbus->lib->ffdbus_message_iter_next(&dictIter); if (dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_ARRAY) { - return NULL; + return nullptr; } DBusMessageIter arrayIter; @@ -202,7 +202,7 @@ static const char* detectBluetooth(FFBluetoothOptions* options, FFlist* devices, return error; } - DBusMessage* managedObjects = ffDBusGetMethodReply(&dbus, "org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", NULL, NULL); + DBusMessage* managedObjects = ffDBusGetMethodReply(&dbus, "org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", nullptr, nullptr); if (!managedObjects) { return "Failed to call GetManagedObjects"; } @@ -216,19 +216,19 @@ static const char* detectBluetooth(FFBluetoothOptions* options, FFlist* devices, detectBluetoothRoot(options, devices, &dbus, &rootIter, connectedCount); dbus.lib->ffdbus_message_unref(managedObjects); - return NULL; + return nullptr; } static uint32_t connectedDevices(void) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/bluetooth"); - if (dirp == NULL) { + if (dirp == nullptr) { return 0; } uint32_t result = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { - if (strchr(entry->d_name, ':') != NULL) { + while ((entry = readdir(dirp)) != nullptr) { + if (strchr(entry->d_name, ':') != nullptr) { ++result; } } @@ -244,7 +244,7 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF if (!options->showDisconnected) { connectedCount = (int32_t) connectedDevices(); if (connectedCount == 0) { - return NULL; + return nullptr; } } diff --git a/src/detection/bluetooth/bluetooth_windows.c b/src/detection/bluetooth/bluetooth_windows.c index 8932aef50..ac0d2f49f 100644 --- a/src/detection/bluetooth/bluetooth_windows.c +++ b/src/detection/bluetooth/bluetooth_windows.c @@ -35,7 +35,7 @@ static const char* ffBluetoothDetectBattery(FFlist* devices) { } if (idListLength == 0) { - return NULL; + return nullptr; } wchar_t* FF_AUTO_FREE idList = (wchar_t*) malloc((size_t) idListLength * sizeof(wchar_t)); @@ -94,7 +94,7 @@ static const char* ffBluetoothDetectBattery(FFlist* devices) { } } - return NULL; + return nullptr; } const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) { @@ -114,7 +114,7 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF &btdi); if (!hFind) { if (GetLastError() == ERROR_NO_MORE_ITEMS) { - return NULL; + return nullptr; } return "BluetoothFindFirstDevice() failed"; } @@ -219,5 +219,5 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF ffBluetoothDetectBattery(devices); } - return NULL; + return nullptr; } diff --git a/src/detection/bluetoothradio/bluetoothradio_apple.m b/src/detection/bluetoothradio/bluetoothradio_apple.m index c5154abf1..be662f9f9 100644 --- a/src/detection/bluetoothradio/bluetoothradio_apple.m +++ b/src/detection/bluetoothradio/bluetoothradio_apple.m @@ -21,8 +21,8 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) "-xml", "-detailLevel", "basic", - NULL - }) != NULL) + nullptr + }) != nullptr) return "Starting `system_profiler SPBluetoothDataType -xml -detailLevel basic` failed"; NSArray* arr = [NSPropertyListSerialization propertyListWithData:[NSData dataWithBytes:buffer.chars length:buffer.length] @@ -65,5 +65,5 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) } } - return NULL; + return nullptr; } diff --git a/src/detection/bluetoothradio/bluetoothradio_linux.c b/src/detection/bluetoothradio/bluetoothradio_linux.c index a7d92a483..c3a33a9cc 100644 --- a/src/detection/bluetoothradio/bluetoothradio_linux.c +++ b/src/detection/bluetoothradio/bluetoothradio_linux.c @@ -73,14 +73,14 @@ static const char* detectBluetoothProperty(FFBluetoothRadioResult* device, FFDBu ffDBusGetBool(dbus, &dictIter, &device->connectable); } - return NULL; + return nullptr; } static const char* detectBluetoothRoot(FFBluetoothRadioResult* device, const char* hciName, FFDBusData* dbus) { char objPath[300]; snprintf(objPath, sizeof(objPath), "/org/bluez/%s", hciName); - DBusMessage* properties = ffDBusGetMethodReply(dbus, "org.bluez", objPath, "org.freedesktop.DBus.Properties", "GetAll", "org.bluez.Adapter1", NULL); + DBusMessage* properties = ffDBusGetMethodReply(dbus, "org.bluez", objPath, "org.freedesktop.DBus.Properties", "GetAll", "org.bluez.Adapter1", nullptr); if (!properties) { return "Failed to call org.freedesktop.DBus.Properties.GetAll"; } @@ -104,12 +104,12 @@ static const char* detectBluetoothRoot(FFBluetoothRadioResult* device, const cha } while (dbus->lib->ffdbus_message_iter_next(&arrayIter)); dbus->lib->ffdbus_message_unref(properties); - return NULL; + return nullptr; } static const char* detectBluetooth(FFlist* devices) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/bluetooth"); - if (dirp == NULL) { + if (dirp == nullptr) { return "Failed to open /sys/class/bluetooth"; } @@ -120,12 +120,12 @@ static const char* detectBluetooth(FFlist* devices) { } struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } - if (strchr(entry->d_name, ':') != NULL) { // ignore connected devices + if (strchr(entry->d_name, ':') != nullptr) { // ignore connected devices continue; } @@ -138,7 +138,7 @@ static const char* detectBluetooth(FFlist* devices) { device->enabled = false; detectBluetoothRoot(device, entry->d_name, &dbus); } - return NULL; + return nullptr; } #endif diff --git a/src/detection/bluetoothradio/bluetoothradio_windows.c b/src/detection/bluetoothradio/bluetoothradio_windows.c index f0b55d455..8bb672b21 100644 --- a/src/detection/bluetoothradio/bluetoothradio_windows.c +++ b/src/detection/bluetoothradio/bluetoothradio_windows.c @@ -58,7 +58,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothIsConnectable) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothIsDiscoverable) - HANDLE hRadio = NULL; + HANDLE hRadio = nullptr; HBLUETOOTH_DEVICE_FIND hFind = ffBluetoothFindFirstRadio(&(BLUETOOTH_FIND_RADIO_PARAMS) { .dwSize = sizeof(BLUETOOTH_FIND_RADIO_PARAMS) }, &hRadio); @@ -73,7 +73,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) do { BTH_LOCAL_RADIO_INFO blri; DWORD returned; - if (!DeviceIoControl(hRadio, IOCTL_BTH_GET_LOCAL_INFO, NULL, 0, &blri, sizeof(blri), &returned, NULL)) { + if (!DeviceIoControl(hRadio, IOCTL_BTH_GET_LOCAL_INFO, nullptr, 0, &blri, sizeof(blri), &returned, nullptr)) { continue; } @@ -95,5 +95,5 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) ffBluetoothFindRadioClose(hFind); - return NULL; + return nullptr; } diff --git a/src/detection/board/board_android.c b/src/detection/board/board_android.c index b5978d1f2..f70c1abb3 100644 --- a/src/detection/board/board_android.c +++ b/src/detection/board/board_android.c @@ -5,5 +5,5 @@ const char* ffDetectBoard(FFBoardResult* board) { if (!ffSettingsGetAndroidProperty("ro.product.board", &board->name)) { ffSettingsGetAndroidProperty("ro.board.platform", &board->name); } - return NULL; + return nullptr; } diff --git a/src/detection/board/board_apple.c b/src/detection/board/board_apple.c index e7c4d381d..f3b39538d 100644 --- a/src/detection/board/board_apple.c +++ b/src/detection/board/board_apple.c @@ -28,5 +28,5 @@ const char* ffDetectBoard(FFBoardResult* result) { ffCfStrGetString(manufacturer, &result->vendor); } - return NULL; + return nullptr; } diff --git a/src/detection/board/board_bsd.c b/src/detection/board/board_bsd.c index 2e0e41720..62a8ab1ff 100644 --- a/src/detection/board/board_bsd.c +++ b/src/detection/board/board_bsd.c @@ -11,5 +11,5 @@ const char* ffDetectBoard(FFBoardResult* result) { ffCleanUpSmbiosValue(&result->vendor); ffSettingsGetFreeBSDKenv("smbios.planar.version", &result->version); ffCleanUpSmbiosValue(&result->version); - return NULL; + return nullptr; } diff --git a/src/detection/board/board_linux.c b/src/detection/board/board_linux.c index 52b3df2cd..c2315b47f 100644 --- a/src/detection/board/board_linux.c +++ b/src/detection/board/board_linux.c @@ -22,5 +22,5 @@ const char* ffDetectBoard(FFBoardResult* board) { ffStrbufSubstrBefore(&board->vendor, comma); } } - return NULL; + return nullptr; } diff --git a/src/detection/board/board_nbsd.c b/src/detection/board/board_nbsd.c index cc3ff938d..09bcab71f 100644 --- a/src/detection/board/board_nbsd.c +++ b/src/detection/board/board_nbsd.c @@ -3,18 +3,18 @@ #include "common/smbios.h" const char* ffDetectBoard(FFBoardResult* board) { - if (ffSysctlGetString("machdep.dmi.board-product", &board->name) == NULL) { + if (ffSysctlGetString("machdep.dmi.board-product", &board->name) == nullptr) { ffCleanUpSmbiosValue(&board->name); } - if (ffSysctlGetString("machdep.dmi.board-version", &board->version) == NULL) { + if (ffSysctlGetString("machdep.dmi.board-version", &board->version) == nullptr) { ffCleanUpSmbiosValue(&board->version); } - if (ffSysctlGetString("machdep.dmi.board-vendor", &board->vendor) == NULL) { + if (ffSysctlGetString("machdep.dmi.board-vendor", &board->vendor) == nullptr) { ffCleanUpSmbiosValue(&board->vendor); } - if (ffSysctlGetString("machdep.dmi.board-serial", &board->serial) == NULL) { + if (ffSysctlGetString("machdep.dmi.board-serial", &board->serial) == nullptr) { ffCleanUpSmbiosValue(&board->serial); } - return NULL; + return nullptr; } diff --git a/src/detection/board/board_windows.c b/src/detection/board/board_windows.c index 079e64d51..599dad034 100644 --- a/src/detection/board/board_windows.c +++ b/src/detection/board/board_windows.c @@ -42,5 +42,5 @@ const char* ffDetectBoard(FFBoardResult* board) { ffStrbufSetStatic(&board->version, ffSmbiosLocateString(strings, data->Version)); ffCleanUpSmbiosValue(&board->version); - return NULL; + return nullptr; } diff --git a/src/detection/bootmgr/bootmgr_apple.c b/src/detection/bootmgr/bootmgr_apple.c index d2b24e00e..59aaa7831 100644 --- a/src/detection/bootmgr/bootmgr_apple.c +++ b/src/detection/bootmgr/bootmgr_apple.c @@ -39,7 +39,7 @@ static const char* detectSecureBoot(bool* result) { *result = *CFDataGetBytePtr((CFDataRef) prop) != 0x02 /* Permissive Security */; #endif - return NULL; + return nullptr; } const char* ffDetectBootmgr(FFBootmgrResult* result) { @@ -65,5 +65,5 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) { detectSecureBoot(&result->secureBoot); - return NULL; + return nullptr; } diff --git a/src/detection/bootmgr/bootmgr_bsd.c b/src/detection/bootmgr/bootmgr_bsd.c index cfaa41d26..93983ab37 100644 --- a/src/detection/bootmgr/bootmgr_bsd.c +++ b/src/detection/bootmgr/bootmgr_bsd.c @@ -58,5 +58,5 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) { result->secureBoot = !!buffer[0]; } - return NULL; + return nullptr; } diff --git a/src/detection/bootmgr/bootmgr_haiku.cpp b/src/detection/bootmgr/bootmgr_haiku.cpp index 72358fca0..78060b296 100644 --- a/src/detection/bootmgr/bootmgr_haiku.cpp +++ b/src/detection/bootmgr/bootmgr_haiku.cpp @@ -13,5 +13,5 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) { // TODO: detectSecureBoot(&result->secureBoot); - return NULL; + return nullptr; } diff --git a/src/detection/bootmgr/bootmgr_linux.c b/src/detection/bootmgr/bootmgr_linux.c index 0fd019a2f..daae9e79e 100644 --- a/src/detection/bootmgr/bootmgr_linux.c +++ b/src/detection/bootmgr/bootmgr_linux.c @@ -28,5 +28,5 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) { result->secureBoot = buffer[4] == 1; } - return NULL; + return nullptr; } diff --git a/src/detection/bootmgr/bootmgr_windows.c b/src/detection/bootmgr/bootmgr_windows.c index e83e1e2a1..0a1a55994 100644 --- a/src/detection/bootmgr/bootmgr_windows.c +++ b/src/detection/bootmgr/bootmgr_windows.c @@ -7,7 +7,7 @@ #include const char* enablePrivilege(const wchar_t* privilege) { - FF_AUTO_CLOSE_FD HANDLE token = NULL; + FF_AUTO_CLOSE_FD HANDLE token = nullptr; if (!NT_SUCCESS(NtOpenProcessToken(NtCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))) { return "NtOpenProcessToken() failed"; } @@ -17,11 +17,11 @@ const char* enablePrivilege(const wchar_t* privilege) { .Privileges = { (LUID_AND_ATTRIBUTES) { .Attributes = SE_PRIVILEGE_ENABLED } }, }; - if (!LookupPrivilegeValueW(NULL, privilege, &tp.Privileges[0].Luid)) { + if (!LookupPrivilegeValueW(nullptr, privilege, &tp.Privileges[0].Luid)) { return "LookupPrivilegeValue() failed"; } - NTSTATUS status = NtAdjustPrivilegesToken(token, false, &tp, sizeof(tp), NULL, NULL); + NTSTATUS status = NtAdjustPrivilegesToken(token, false, &tp, sizeof(tp), nullptr, nullptr); if (!NT_SUCCESS(status)) { return "NtAdjustPrivilegesToken() failed"; } @@ -30,12 +30,12 @@ const char* enablePrivilege(const wchar_t* privilege) { return "The token does not have the specified privilege; try sudo please"; } - return NULL; + return nullptr; } const char* ffDetectBootmgr(FFBootmgrResult* result) { const char* err = enablePrivilege(L"SeSystemEnvironmentPrivilege"); - if (err != NULL) { + if (err != nullptr) { return err; } @@ -45,7 +45,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) { } ULONG size = sizeof(result->order); - if (!NT_SUCCESS(NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(L"BootCurrent"), &efiGlobalGuid, &result->order, &size, NULL))) { + if (!NT_SUCCESS(NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(L"BootCurrent"), &efiGlobalGuid, &result->order, &size, nullptr))) { return "NtQuerySystemEnvironmentValueEx(BootCurrent) failed"; } if (size != sizeof(result->order)) { @@ -56,7 +56,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) { wchar_t key[9]; swprintf(key, ARRAY_SIZE(key), L"Boot%04X", result->order); size = sizeof(buffer); - if (!NT_SUCCESS(NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(key), &efiGlobalGuid, buffer, &size, NULL))) { + if (!NT_SUCCESS(NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(key), &efiGlobalGuid, buffer, &size, nullptr))) { return "NtQuerySystemEnvironmentValueEx(Boot####) failed"; } if (size < sizeof(FFEfiLoadOption) || size == ARRAY_SIZE(buffer)) { @@ -66,9 +66,9 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) { ffEfiFillLoadOption((FFEfiLoadOption*) buffer, result); SYSTEM_SECUREBOOT_INFORMATION ssi; - if (NT_SUCCESS(NtQuerySystemInformation(SystemSecureBootInformation, &ssi, sizeof(ssi), NULL))) { + if (NT_SUCCESS(NtQuerySystemInformation(SystemSecureBootInformation, &ssi, sizeof(ssi), nullptr))) { result->secureBoot = ssi.SecureBootEnabled; } - return NULL; + return nullptr; } diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index 5dd12b2a4..013e3e84e 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -27,7 +27,7 @@ extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* bright // Works for internal display static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* result) { - if (DisplayServicesGetBrightness == NULL) { + if (DisplayServicesGetBrightness == nullptr) { return "DisplayServices function DisplayServicesGetBrightness is not available"; } @@ -45,7 +45,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa } } - return NULL; + return nullptr; } #ifdef __aarch64__ @@ -63,7 +63,7 @@ static const char* detectWithDdcci(FF_A_UNUSED const FFDisplayServerResult* disp io_registry_entry_t registryEntry; while ((registryEntry = IOIteratorNext(iterator)) != IO_OBJECT_NULL) { - FF_CFTYPE_AUTO_RELEASE IOAVServiceRef service = NULL; + FF_CFTYPE_AUTO_RELEASE IOAVServiceRef service = nullptr; { FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryAv = registryEntry; @@ -118,7 +118,7 @@ static const char* detectWithDdcci(FF_A_UNUSED const FFDisplayServerResult* disp } } - return NULL; + return nullptr; } #else static IOOptionBits getSupportedTransactionType(void) { @@ -181,7 +181,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F } uint8_t i2cOut[12] = {}; - IOI2CConnectRef connect = NULL; + IOI2CConnectRef connect = nullptr; if (IOI2CInterfaceOpen(interface, kNilOptions, &connect) != KERN_SUCCESS) { continue; } @@ -227,7 +227,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F } } - return NULL; + return nullptr; } #endif @@ -240,5 +240,5 @@ const char* ffDetectBrightness(FFBrightnessOptions* options, FFlist* result) { detectWithDdcci(displayServer, options, result); } - return NULL; + return nullptr; } diff --git a/src/detection/brightness/brightness_bsd.c b/src/detection/brightness/brightness_bsd.c index 5ff411c61..93c48aad3 100644 --- a/src/detection/brightness/brightness_bsd.c +++ b/src/detection/brightness/brightness_bsd.c @@ -69,7 +69,7 @@ const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* re brightness->builtin = false; } - return NULL; + return nullptr; } #else @@ -125,7 +125,7 @@ const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FFlist ffStrbufAppendS(&brightness->name, path + strlen("/dev/backlight/")); } } - return NULL; + return nullptr; } #else @@ -143,5 +143,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && result->length == 0) { detectWithDdcci(options, result); } - return NULL; + return nullptr; } diff --git a/src/detection/brightness/brightness_haiku.cpp b/src/detection/brightness/brightness_haiku.cpp index 86fbe6d82..aadf9c9ca 100644 --- a/src/detection/brightness/brightness_haiku.cpp +++ b/src/detection/brightness/brightness_haiku.cpp @@ -42,5 +42,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* } while (screen.SetToNext() == B_OK); - return NULL; + return nullptr; } diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index c0012c434..afac0fa7d 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -11,7 +11,7 @@ static const char* detectWithBacklight(FFlist* result) { const char* backlightDirPath = "/sys/class/backlight/"; FF_AUTO_CLOSE_DIR DIR* dirp = opendir(backlightDirPath); - if (dirp == NULL) { + if (dirp == nullptr) { return "Failed to open `/sys/class/backlight/`"; } @@ -23,7 +23,7 @@ static const char* detectWithBacklight(FFlist* result) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -72,7 +72,7 @@ static const char* detectWithBacklight(FFlist* result) { ffStrbufSubstrBefore(&backlightDir, backlightDirLength); } - return NULL; + return nullptr; } #ifdef FF_HAVE_DDCUTIL @@ -103,7 +103,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl if (ffddca_init) { FF_SUPPRESS_IO(); // Ref: https://github.com/rockowitz/ddcutil/issues/344 - if (ffddca_init(NULL, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0) { + if (ffddca_init(nullptr, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0) { return "ddca_init() failed"; } } else { @@ -112,11 +112,11 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl ffddca_set_default_sleep_multiplier(options->ddcciSleep / 40.0); } - libddcutil = NULL; // Don't dlclose libddcutil. See https://github.com/rockowitz/ddcutil/issues/330 + libddcutil = nullptr; // Don't dlclose libddcutil. See https://github.com/rockowitz/ddcutil/issues/330 } #else #if DDCUTIL_VMAJOR >= 2 - if (ddca_init(NULL, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0) { + if (ddca_init(nullptr, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0) { return "ddca_init() failed"; } #else @@ -124,7 +124,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl #endif #endif - FF_AUTO_FREE DDCA_Display_Info_List* infoList = NULL; + FF_AUTO_FREE DDCA_Display_Info_List* infoList = nullptr; if (ffddca_get_display_info_list2(false, &infoList) < 0) { return "ddca_get_display_info_list2(false, &infoList) failed"; } @@ -138,7 +138,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl DDCA_Display_Handle handle; if (ffddca_open_display2(display->dref, false, &handle) >= 0) { - DDCA_Any_Vcp_Value* vcpValue = NULL; + DDCA_Any_Vcp_Value* vcpValue = nullptr; if (ffddca_get_any_vcp_value_using_explicit_type(handle, 0x10 /*brightness*/, DDCA_NON_TABLE_VCP_VALUE, &vcpValue) >= 0) { assert(vcpValue->value_type == DDCA_NON_TABLE_VCP_VALUE); int current = VALREC_CUR_VAL(vcpValue), max = VALREC_MAX_VAL(vcpValue); @@ -154,7 +154,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl } } - return NULL; + return nullptr; } #endif @@ -170,5 +170,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* } #endif - return NULL; + return nullptr; } diff --git a/src/detection/brightness/brightness_nbsd.c b/src/detection/brightness/brightness_nbsd.c index afd665604..9b556bbe1 100644 --- a/src/detection/brightness/brightness_nbsd.c +++ b/src/detection/brightness/brightness_nbsd.c @@ -22,5 +22,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* brightness->current = value; brightness->builtin = true; } - return NULL; + return nullptr; } diff --git a/src/detection/brightness/brightness_obsd.c b/src/detection/brightness/brightness_obsd.c index 102a8c256..c93cc6f68 100644 --- a/src/detection/brightness/brightness_obsd.c +++ b/src/detection/brightness/brightness_obsd.c @@ -40,5 +40,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* brightness->builtin = true; } - return NULL; + return nullptr; } diff --git a/src/detection/brightness/brightness_windows.c b/src/detection/brightness/brightness_windows.c index 70b7f0197..7f26adabc 100644 --- a/src/detection/brightness/brightness_windows.c +++ b/src/detection/brightness/brightness_windows.c @@ -45,7 +45,7 @@ static const char* detectWithWmi(FFlist* result) { 0xd43412ac, 0x67f9, 0x4fbb, { 0xa0, 0x81, 0x17, 0x52, 0xa2, 0xc3, 0x3e, 0x84 } }; - FF_AUTO_CLOSE_WMI_BLOCK HANDLE hBlock = NULL; + FF_AUTO_CLOSE_WMI_BLOCK HANDLE hBlock = nullptr; ULONG status = WmiOpenBlock(&WmiMonitorBrightnessGuid, WMIGUID_QUERY, &hBlock); if (status != 0) { @@ -54,7 +54,7 @@ static const char* detectWithWmi(FFlist* result) { } ULONG bufferSize = 0; - status = WmiQueryAllDataW(hBlock, &bufferSize, NULL); + status = WmiQueryAllDataW(hBlock, &bufferSize, nullptr); if (status != ERROR_SUCCESS && status != ERROR_INSUFFICIENT_BUFFER) { FF_DEBUG("WMI: first WmiQueryAllDataW failed, bufferSize=%lu: %s", bufferSize, ffDebugWin32Error(status)); return "WmiQueryAllDataW() failed"; @@ -121,7 +121,7 @@ static const char* detectWithWmi(FFlist* result) { FF_DEBUG("WMI: finished detection, total results=%u", result->length); - return NULL; + return nullptr; } static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFlist* result) { @@ -159,7 +159,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F NTSTATUS monitorStatus = ffGetPhysicalMonitors(&deviceName, 1, &monitorCount, &physicalMonitor); if (NT_SUCCESS(monitorStatus) && monitorCount >= 1) { DWORD curr = 0, max = 0; - if (NT_SUCCESS(ffDDCCIGetVCPFeature(physicalMonitor, FF_DDC_CI_LUMINANCE_OPCODE, NULL, &curr, &max))) { + if (NT_SUCCESS(ffDDCCIGetVCPFeature(physicalMonitor, FF_DDC_CI_LUMINANCE_OPCODE, nullptr, &curr, &max))) { FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result); if (display->name.length > 0) { ffStrbufInitCopy(&brightness->name, &display->name); @@ -192,7 +192,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F } FF_DEBUG("DDC/CI: finished detection, total results=%u", result->length); - return NULL; + return nullptr; } static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer) { @@ -219,5 +219,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* } FF_DEBUG("finished, resultCount=%u", result->length); - return NULL; + return nullptr; } diff --git a/src/detection/btrfs/btrfs_linux.c b/src/detection/btrfs/btrfs_linux.c index 41914d709..120b3f6c2 100644 --- a/src/detection/btrfs/btrfs_linux.c +++ b/src/detection/btrfs/btrfs_linux.c @@ -12,13 +12,13 @@ static const char* enumerateDevices(FFBtrfsResult* item, int dfd, FFstrbuf* buff } FF_AUTO_CLOSE_DIR DIR* dirp = fdopendir(subfd); - if (dirp == NULL) { + if (dirp == nullptr) { close(subfd); - return "fdopendir(\"/sys/fs/btrfs/UUID/devices\") == NULL"; + return "fdopendir(\"/sys/fs/btrfs/UUID/devices\") == nullptr"; } struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -36,7 +36,7 @@ static const char* enumerateDevices(FFBtrfsResult* item, int dfd, FFstrbuf* buff } } - return NULL; + return nullptr; } static const char* enumerateFeatures(FFBtrfsResult* item, int dfd) { @@ -46,12 +46,12 @@ static const char* enumerateFeatures(FFBtrfsResult* item, int dfd) { } FF_AUTO_CLOSE_DIR DIR* dirp = fdopendir(subfd); - if (dirp == NULL) { - return "fdopendir(\"/sys/fs/btrfs/UUID/features\") == NULL"; + if (dirp == nullptr) { + return "fdopendir(\"/sys/fs/btrfs/UUID/features\") == nullptr"; } struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -61,7 +61,7 @@ static const char* enumerateFeatures(FFBtrfsResult* item, int dfd) { ffStrbufAppendS(&item->features, entry->d_name); } - return NULL; + return nullptr; } static const char* detectAllocation(FFBtrfsResult* item, int dfd, FFstrbuf* buffer) { @@ -73,7 +73,7 @@ static const char* detectAllocation(FFBtrfsResult* item, int dfd, FFstrbuf* buff if (ffReadFileBufferRelative(subfd, "global_rsv_size", buffer)) { item->globalReservationTotal = ffStrbufToUInt(buffer, 0); } else { - return "ffReadFileBuffer(\"/sys/fs/btrfs/UUID/allocation/global_rsv_size\") == NULL"; + return "ffReadFileBuffer(\"/sys/fs/btrfs/UUID/allocation/global_rsv_size\") == nullptr"; } if (ffReadFileBufferRelative(subfd, "global_rsv_reserved", buffer)) { @@ -118,19 +118,19 @@ static const char* detectAllocation(FFBtrfsResult* item, int dfd, FFstrbuf* buff #undef FF_BTRFS_DETECT_TYPE - return NULL; + return nullptr; } const char* ffDetectBtrfs(FFlist* result) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/fs/btrfs/"); - if (dirp == NULL) { - return "opendir(\"/sys/fs/btrfs\") == NULL"; + if (dirp == nullptr) { + return "opendir(\"/sys/fs/btrfs\") == nullptr"; } FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -174,5 +174,5 @@ const char* ffDetectBtrfs(FFlist* result) { detectAllocation(item, dfd, &buffer); } - return NULL; + return nullptr; } diff --git a/src/detection/camera/camera_android.c b/src/detection/camera/camera_android.c index b09314d39..9b6c99890 100644 --- a/src/detection/camera/camera_android.c +++ b/src/detection/camera/camera_android.c @@ -16,11 +16,11 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) { const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); - if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL })) { + if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, nullptr })) { return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; } - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); if (!doc) { return "Failed to parse camera info"; } @@ -54,5 +54,5 @@ const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { ffStrbufInit(&camera->colorspace); } - return NULL; + return nullptr; } diff --git a/src/detection/camera/camera_apple.m b/src/detection/camera/camera_apple.m index aa5c1cf91..603bcd598 100644 --- a/src/detection/camera/camera_apple.m +++ b/src/detection/camera/camera_apple.m @@ -16,7 +16,7 @@ const char* ffDetectCamera(FFlist* result) #ifdef MAC_OS_X_VERSION_10_15 FF_SUPPRESS_IO(); // #822 - AVCaptureDeviceType deviceType = NULL; + AVCaptureDeviceType deviceType = nullptr; #ifdef MAC_OS_VERSION_14_0 // Strangely `@available(macOS 14.0, *)` doesn't work here (#1594) @@ -26,7 +26,7 @@ const char* ffDetectCamera(FFlist* result) deviceType = AVCaptureDeviceTypeExternal; } #endif - if (deviceType == NULL) + if (deviceType == nullptr) deviceType = AVCaptureDeviceTypeExternalUnknown; AVCaptureDeviceDiscoverySession* session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera, deviceType] @@ -54,7 +54,7 @@ const char* ffDetectCamera(FFlist* result) camera->width = size.width < 0 ? 0 : (uint32_t) size.width; camera->height = size.height < 0 ? 0 : (uint32_t) size.height; } - return NULL; + return nullptr; #else return "No support for old MacOS version"; #endif diff --git a/src/detection/camera/camera_linux.c b/src/detection/camera/camera_linux.c index 2fea2b4b2..2fc8b129c 100644 --- a/src/detection/camera/camera_linux.c +++ b/src/detection/camera/camera_linux.c @@ -86,7 +86,7 @@ const char* ffDetectCamera(FFlist* result) { camera->height = fmt.fmt.pix.height; } - return NULL; + return nullptr; #else FF_UNUSED(result); return "Fastfetch was compiled without "; diff --git a/src/detection/camera/camera_windows.cpp b/src/detection/camera/camera_windows.cpp index 1f4230696..0d24a9eb3 100644 --- a/src/detection/camera/camera_windows.cpp +++ b/src/detection/camera/camera_windows.cpp @@ -32,7 +32,7 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { return "SetGUID(MF_*) failed"; } - IMFActivate** devices = NULL; + IMFActivate** devices = nullptr; uint32_t count; if (FAILED(ffMFEnumDeviceSources(attrs, &devices, &count))) { @@ -89,7 +89,7 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { } // Assume first type is the maximum resolution - IMFMediaType* type = NULL; + IMFMediaType* type = nullptr; for (DWORD idx = 0; SUCCEEDED(handler->GetMediaTypeByIndex(idx, &type)); ++idx) { on_scope_exit destroyType([=] { type->Release(); }); diff --git a/src/detection/chassis/chassis.c b/src/detection/chassis/chassis.c index d4d1fd378..d87e3a71f 100644 --- a/src/detection/chassis/chassis.c +++ b/src/detection/chassis/chassis.c @@ -76,6 +76,6 @@ const char* ffChassisTypeToString(uint32_t type) { case 0x24: return "Stick PC"; default: - return NULL; + return nullptr; } } diff --git a/src/detection/chassis/chassis_apple.c b/src/detection/chassis/chassis_apple.c index 1ff4fee52..b5a041dcf 100644 --- a/src/detection/chassis/chassis_apple.c +++ b/src/detection/chassis/chassis_apple.c @@ -11,7 +11,7 @@ const char* ffDetectChassis(FFChassisResult* result) { .uuid = ffStrbufCreate(), .vendor = ffStrbufCreate(), }; - if (ffDetectHost(&host) != NULL) { + if (ffDetectHost(&host) != nullptr) { return "Failed to detect host"; } @@ -36,5 +36,5 @@ const char* ffDetectChassis(FFChassisResult* result) { ffStrbufDestroy(&host.uuid); ffStrbufDestroy(&host.vendor); - return NULL; + return nullptr; } diff --git a/src/detection/chassis/chassis_bsd.c b/src/detection/chassis/chassis_bsd.c index fa1371890..dc839bcd2 100644 --- a/src/detection/chassis/chassis_bsd.c +++ b/src/detection/chassis/chassis_bsd.c @@ -12,5 +12,5 @@ const char* ffDetectChassis(FFChassisResult* result) { ffCleanUpSmbiosValue(&result->serial); ffSettingsGetFreeBSDKenv("smbios.chassis.version", &result->version); ffCleanUpSmbiosValue(&result->version); - return NULL; + return nullptr; } diff --git a/src/detection/chassis/chassis_linux.c b/src/detection/chassis/chassis_linux.c index af7ed0a1e..686fc67be 100644 --- a/src/detection/chassis/chassis_linux.c +++ b/src/detection/chassis/chassis_linux.c @@ -35,5 +35,5 @@ const char* ffDetectChassis(FFChassisResult* result) { result->type.chars[0] = (char) toupper(result->type.chars[0]); } } - return NULL; + return nullptr; } diff --git a/src/detection/chassis/chassis_nbsd.c b/src/detection/chassis/chassis_nbsd.c index 56447982d..386da9212 100644 --- a/src/detection/chassis/chassis_nbsd.c +++ b/src/detection/chassis/chassis_nbsd.c @@ -3,18 +3,18 @@ #include "common/smbios.h" const char* ffDetectChassis(FFChassisResult* chassis) { - if (ffSysctlGetString("machdep.dmi.chassis-type", &chassis->type) == NULL) { + if (ffSysctlGetString("machdep.dmi.chassis-type", &chassis->type) == nullptr) { ffCleanUpSmbiosValue(&chassis->type); } - if (ffSysctlGetString("machdep.dmi.chassis-version", &chassis->version) == NULL) { + if (ffSysctlGetString("machdep.dmi.chassis-version", &chassis->version) == nullptr) { ffCleanUpSmbiosValue(&chassis->version); } - if (ffSysctlGetString("machdep.dmi.chassis-vendor", &chassis->vendor) == NULL) { + if (ffSysctlGetString("machdep.dmi.chassis-vendor", &chassis->vendor) == nullptr) { ffCleanUpSmbiosValue(&chassis->vendor); } - if (ffSysctlGetString("machdep.dmi.chassis-serial", &chassis->serial) == NULL) { + if (ffSysctlGetString("machdep.dmi.chassis-serial", &chassis->serial) == nullptr) { ffCleanUpSmbiosValue(&chassis->serial); } - return NULL; + return nullptr; } diff --git a/src/detection/chassis/chassis_windows.c b/src/detection/chassis/chassis_windows.c index 51a4c6c16..5ffc9a45a 100644 --- a/src/detection/chassis/chassis_windows.c +++ b/src/detection/chassis/chassis_windows.c @@ -50,5 +50,5 @@ const char* ffDetectChassis(FFChassisResult* result) { ffCleanUpSmbiosValue(&result->version); ffStrbufSetStatic(&result->type, ffChassisTypeToString(data->Type)); - return NULL; + return nullptr; } diff --git a/src/detection/codec/codec_android.c b/src/detection/codec/codec_android.c index 238dab7e8..89d73a823 100644 --- a/src/detection/codec/codec_android.c +++ b/src/detection/codec/codec_android.c @@ -43,7 +43,7 @@ static bool ffCodecIsHardwareAccelerated( return false; } - char* codecName = NULL; + char* codecName = nullptr; media_status_t status = ffAMediaCodec_getName(codec, &codecName); if (status != AMEDIA_OK || !codecName) { return false; @@ -98,5 +98,5 @@ const char* ffDetectCodecNative(FFCodecOptions* options, FFlist* result /*list o item->platformApi = "AMediaCodec"; } - return NULL; + return nullptr; } diff --git a/src/detection/codec/codec_apple.c b/src/detection/codec/codec_apple.c index 377837303..36ca55a99 100644 --- a/src/detection/codec/codec_apple.c +++ b/src/detection/codec/codec_apple.c @@ -41,8 +41,8 @@ static FFCodecType ffCodecCodecToType(CMVideoCodecType codec) { } static FFCodecType ffCodecDetectEncoders(void) { - CFArrayRef encoderList = NULL; - if (VTCopyVideoEncoderList(NULL, &encoderList) != noErr || !encoderList) { + CFArrayRef encoderList = nullptr; + if (VTCopyVideoEncoderList(nullptr, &encoderList) != noErr || !encoderList) { return FF_CODEC_TYPE_NONE; } @@ -51,9 +51,9 @@ static FFCodecType ffCodecDetectEncoders(void) { CFDictionaryRef encoder = CFArrayGetValueAtIndex(encoderList, i); bool isHardwareAccelerated; int codec; - if (ffCfDictGetBool(encoder, CFSTR("IsHardwareAccelerated"), &isHardwareAccelerated) != NULL || + if (ffCfDictGetBool(encoder, CFSTR("IsHardwareAccelerated"), &isHardwareAccelerated) != nullptr || !isHardwareAccelerated || - ffCfDictGetInt(encoder, CFSTR("CodecType"), &codec) != NULL) { + ffCfDictGetInt(encoder, CFSTR("CodecType"), &codec) != nullptr) { continue; } types |= ffCodecCodecToType((CMVideoCodecType) codec); @@ -92,5 +92,5 @@ const char* ffDetectCodecNative(FFCodecOptions* options, FFlist* result /* list item->platformApi = "VideoToolbox"; } - return NULL; + return nullptr; } diff --git a/src/detection/codec/codec_linux.c b/src/detection/codec/codec_linux.c index 2a2c213ca..f058744bb 100644 --- a/src/detection/codec/codec_linux.c +++ b/src/detection/codec/codec_linux.c @@ -226,13 +226,13 @@ static const char* detectCodecByVaDrm(FFVAData* vaData, FFCodecOptions* options, const char* error = "No DRM device could initialize VA-API"; FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/dev/dri/"); - if (dirp == NULL) { + if (dirp == nullptr) { return "opendir(/dev/dri/) failed"; } int drifd = dirfd(dirp); struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.' || !ffStrStartsWith(entry->d_name, "renderD")) { continue; } @@ -248,7 +248,7 @@ static const char* detectCodecByVaDrm(FFVAData* vaData, FFCodecOptions* options, } if (vaDetectDisplay(display, vaData, options, result, "VA-API (DRM)")) { - error = NULL; + error = nullptr; } } @@ -266,7 +266,7 @@ static const char* detectCodecByVaX11(FFVAData* vaData, FFCodecOptions* options, FF_LIBRARY_LOAD_MESSAGE(libvaX11, "libva-x11" FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libvaX11, vaGetDisplay) - Display* x11Display = ffXOpenDisplay(NULL); + Display* x11Display = ffXOpenDisplay(nullptr); if (!x11Display) { return "XOpenDisplay() failed"; } @@ -283,7 +283,7 @@ static const char* detectCodecByVaX11(FFVAData* vaData, FFCodecOptions* options, } ffXCloseDisplay(x11Display); - return NULL; + return nullptr; } #endif @@ -301,14 +301,14 @@ static const char* detectCodecByVa(FFCodecOptions* options, FFlist* result) { FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libva, vaData, vaGetConfigAttributes) #if FF_HAVE_VADRM - if (detectCodecByVaDrm(&vaData, options, result) == NULL) { - return NULL; + if (detectCodecByVaDrm(&vaData, options, result) == nullptr) { + return nullptr; } #endif #if FF_HAVE_VAX11 - if (detectCodecByVaX11(&vaData, options, result) == NULL) { - return NULL; + if (detectCodecByVaX11(&vaData, options, result) == nullptr) { + return nullptr; } #endif @@ -378,26 +378,26 @@ static const char* detectCodecByVdpau(FFCodecOptions* options, FFlist* result) { FF_LIBRARY_LOAD_MESSAGE(libvdpau, "libvdpau" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libvdpau, vdp_device_create_x11) - Display* x11Display = ffXOpenDisplay(NULL); + Display* x11Display = ffXOpenDisplay(nullptr); if (!x11Display) { return "XOpenDisplay() failed"; } VdpDevice device = VDP_INVALID_HANDLE; - VdpGetProcAddress* ffvdp_get_proc_address = NULL; + VdpGetProcAddress* ffvdp_get_proc_address = nullptr; if (ffvdp_device_create_x11(x11Display, ffXDefaultScreen(x11Display), &device, &ffvdp_get_proc_address) != VDP_STATUS_OK || device == VDP_INVALID_HANDLE || - ffvdp_get_proc_address == NULL) { + ffvdp_get_proc_address == nullptr) { ffXCloseDisplay(x11Display); return "vdp_device_create_x11() failed"; } - VdpDeviceDestroy* ffvdp_device_destroy = NULL; - VdpDecoderQueryCapabilities* ffvdp_decoder_query_capabilities = NULL; + VdpDeviceDestroy* ffvdp_device_destroy = nullptr; + VdpDecoderQueryCapabilities* ffvdp_decoder_query_capabilities = nullptr; if (ffvdp_get_proc_address(device, VDP_FUNC_ID_DEVICE_DESTROY, (void**) &ffvdp_device_destroy) != VDP_STATUS_OK || ffvdp_get_proc_address(device, VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES, (void**) &ffvdp_decoder_query_capabilities) != VDP_STATUS_OK || - ffvdp_device_destroy == NULL || - ffvdp_decoder_query_capabilities == NULL) { + ffvdp_device_destroy == nullptr || + ffvdp_decoder_query_capabilities == nullptr) { if (ffvdp_device_destroy) { ffvdp_device_destroy(device); } @@ -426,7 +426,7 @@ static const char* detectCodecByVdpau(FFCodecOptions* options, FFlist* result) { ffXCloseDisplay(x11Display); if (decoderTypes == FF_CODEC_TYPE_NONE) { - return NULL; + return nullptr; } FFCodecResult* item = FF_LIST_ADD(FFCodecResult, *result); @@ -441,7 +441,7 @@ static const char* detectCodecByVdpau(FFCodecOptions* options, FFlist* result) { item->encoders = FF_CODEC_TYPE_NONE; item->platformApi = "VDPAU"; - return NULL; + return nullptr; } #endif @@ -449,13 +449,13 @@ const char* ffDetectCodecNative(FFCodecOptions* options, FFlist* result /* list FF_SUPPRESS_IO(); #if FF_HAVE_VA - if (detectCodecByVa(options, result) == NULL) { - return NULL; + if (detectCodecByVa(options, result) == nullptr) { + return nullptr; } #endif #if FF_HAVE_VDPAU - if (detectCodecByVdpau(options, result) == NULL) { - return NULL; + if (detectCodecByVdpau(options, result) == nullptr) { + return nullptr; } #endif diff --git a/src/detection/codec/codec_vulkan.c b/src/detection/codec/codec_vulkan.c index eabfe2616..a0c833f2f 100644 --- a/src/detection/codec/codec_vulkan.c +++ b/src/detection/codec/codec_vulkan.c @@ -80,8 +80,8 @@ const char* ffDetectCodecVulkan(FFCodecOptions* options, FFlist* result /*list o FF_SUPPRESS_IO(); uint32_t apiVersion = VK_API_VERSION_1_0; - PFN_vkEnumerateInstanceVersion ffvkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) ffvkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion"); - if (ffvkEnumerateInstanceVersion != NULL) { + PFN_vkEnumerateInstanceVersion ffvkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) ffvkGetInstanceProcAddr(nullptr, "vkEnumerateInstanceVersion"); + if (ffvkEnumerateInstanceVersion != nullptr) { uint32_t detectedApiVersion = 0; if (ffvkEnumerateInstanceVersion(&detectedApiVersion) == VK_SUCCESS) { apiVersion = detectedApiVersion; @@ -105,7 +105,7 @@ const char* ffDetectCodecVulkan(FFCodecOptions* options, FFlist* result /*list o .apiVersion = apiVersion, }, }, - NULL, + nullptr, &vkInstance); if (res != VK_SUCCESS) { FF_DEBUG("ffvkCreateInstance() failed with VkResult=%d", res); @@ -129,25 +129,25 @@ const char* ffDetectCodecVulkan(FFCodecOptions* options, FFlist* result /*list o PFN_vkGetPhysicalDeviceProperties ffvkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceProperties"); if (!ffvkGetPhysicalDeviceProperties) { - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); return "vkGetPhysicalDeviceProperties is not available"; } PFN_vkGetPhysicalDeviceQueueFamilyProperties2 ffvkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceQueueFamilyProperties2"); if (!ffvkGetPhysicalDeviceQueueFamilyProperties2) { - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); return "vkGetPhysicalDeviceQueueFamilyProperties2 is not available"; } uint32_t physicalDeviceCount = 0; - res = ffvkEnumeratePhysicalDevices(vkInstance, &physicalDeviceCount, NULL); + res = ffvkEnumeratePhysicalDevices(vkInstance, &physicalDeviceCount, nullptr); if (res != VK_SUCCESS) { FF_DEBUG("ffvkEnumeratePhysicalDevices(count) failed with VkResult=%d", res); - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); return "ffvkEnumeratePhysicalDevices() failed during Vulkan codec detection"; } if (physicalDeviceCount == 0) { - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); return "No Vulkan physical devices found"; } @@ -156,7 +156,7 @@ const char* ffDetectCodecVulkan(FFCodecOptions* options, FFlist* result /*list o res = ffvkEnumeratePhysicalDevices(vkInstance, &physicalDeviceCount, physicalDevices); if (res != VK_SUCCESS) { FF_DEBUG("ffvkEnumeratePhysicalDevices(list) failed with VkResult=%d", res); - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); return "ffvkEnumeratePhysicalDevices() failed during Vulkan codec detection"; } @@ -167,7 +167,7 @@ const char* ffDetectCodecVulkan(FFCodecOptions* options, FFlist* result /*list o ffvkGetPhysicalDeviceProperties(physicalDevices[i], &properties); uint32_t extensionCount = 0; - res = ffvkEnumerateDeviceExtensionProperties(physicalDevices[i], NULL, &extensionCount, NULL); + res = ffvkEnumerateDeviceExtensionProperties(physicalDevices[i], nullptr, &extensionCount, nullptr); if (res != VK_SUCCESS) { FF_DEBUG("vkEnumerateDeviceExtensionProperties(count) failed for '%s' with VkResult=%d", properties.deviceName, res); continue; @@ -180,7 +180,7 @@ const char* ffDetectCodecVulkan(FFCodecOptions* options, FFlist* result /*list o FF_AUTO_FREE VkExtensionProperties* extensions = (VkExtensionProperties*) malloc(sizeof(VkExtensionProperties) * (size_t) extensionCount); - res = ffvkEnumerateDeviceExtensionProperties(physicalDevices[i], NULL, &extensionCount, extensions); + res = ffvkEnumerateDeviceExtensionProperties(physicalDevices[i], nullptr, &extensionCount, extensions); if (res != VK_SUCCESS) { FF_DEBUG("vkEnumerateDeviceExtensionProperties(list) failed for '%s' with VkResult=%d", properties.deviceName, res); continue; @@ -198,7 +198,7 @@ const char* ffDetectCodecVulkan(FFCodecOptions* options, FFlist* result /*list o sawVideoQueueExtension = true; uint32_t queueFamilyCount = 0; - ffvkGetPhysicalDeviceQueueFamilyProperties2(physicalDevices[i], &queueFamilyCount, NULL); + ffvkGetPhysicalDeviceQueueFamilyProperties2(physicalDevices[i], &queueFamilyCount, nullptr); if (queueFamilyCount == 0) { FF_DEBUG("Skipping Vulkan device '%s' because it has no queue families", properties.deviceName); continue; @@ -248,10 +248,10 @@ const char* ffDetectCodecVulkan(FFCodecOptions* options, FFlist* result /*list o FF_DEBUG("Added Vulkan codec result for '%s': decoders=%u encoders=%u", properties.deviceName, (unsigned) decoders, (unsigned) encoders); } - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); if (result->length > 0) { - return NULL; + return nullptr; } return sawVideoQueueExtension ? "No supported Vulkan video codec operations found" diff --git a/src/detection/command/command.c b/src/detection/command/command.c index 28c6f4b72..5be3d8aea 100644 --- a/src/detection/command/command.c +++ b/src/detection/command/command.c @@ -19,8 +19,8 @@ static const char* spawnProcess(FFCommandOptions* options, FFProcessHandle* hand options->shell.chars, options->param.chars, options->text.chars, - NULL } - : (char* const[]) { options->shell.chars, options->text.chars, NULL }, + nullptr } + : (char* const[]) { options->shell.chars, options->text.chars, nullptr }, options->useStdErr, handle); } @@ -54,5 +54,5 @@ const char* ffDetectCommand(FFCommandOptions* options, FFstrbuf* result) { } ffStrbufTrimRightSpace(result); - return NULL; + return nullptr; } diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index 155c0328c..4f20602a5 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -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; } diff --git a/src/detection/cpu/cpu_apple.c b/src/detection/cpu/cpu_apple.c index 782019255..91beb688e 100644 --- a/src/detection/cpu/cpu_apple.c +++ b/src/detection/cpu/cpu_apple.c @@ -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; } diff --git a/src/detection/cpu/cpu_arm.h b/src/detection/cpu/cpu_arm.h index 571761aeb..23839bbba 100644 --- a/src/detection/cpu/cpu_arm.h +++ b/src/detection/cpu/cpu_arm.h @@ -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; } } diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 4cca30e73..085b01498 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -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) { // // // 0, 1, 2, 3 @@ -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; } diff --git a/src/detection/cpu/cpu_haiku.c b/src/detection/cpu/cpu_haiku.c index 9a8acb587..47399d00c 100644 --- a/src/detection/cpu/cpu_haiku.c +++ b/src/detection/cpu/cpu_haiku.c @@ -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; } diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index df0135ef8..f49924eb8 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -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 diff --git a/src/detection/cpu/cpu_nbsd.c b/src/detection/cpu/cpu_nbsd.c index 9c88c0ece..3cf7dc4fb 100644 --- a/src/detection/cpu/cpu_nbsd.c +++ b/src/detection/cpu/cpu_nbsd.c @@ -10,8 +10,8 @@ #include 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; } diff --git a/src/detection/cpu/cpu_obsd.c b/src/detection/cpu/cpu_obsd.c index e5b8d2fdf..5583fe59f 100644 --- a/src/detection/cpu/cpu_obsd.c +++ b/src/detection/cpu/cpu_obsd.c @@ -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; } diff --git a/src/detection/cpu/cpu_sunos.c b/src/detection/cpu/cpu_sunos.c index 9b1cab503..94fa2436d 100644 --- a/src/detection/cpu/cpu_sunos.c +++ b/src/detection/cpu/cpu_sunos.c @@ -4,28 +4,28 @@ #include 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; } diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index 078ba0b83..dfa82f972 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -10,9 +10,9 @@ #include 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; } diff --git a/src/detection/cpu/cpu_x86.c b/src/detection/cpu/cpu_x86.c index 9deb10374..fbef52723 100644 --- a/src/detection/cpu/cpu_x86.c +++ b/src/detection/cpu/cpu_x86.c @@ -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++) { diff --git a/src/detection/cpucache/cpucache_apple.c b/src/detection/cpucache/cpucache_apple.c index 3d1562cef..50aec0232 100644 --- a/src/detection/cpucache/cpucache_apple.c +++ b/src/detection/cpucache/cpucache_apple.c @@ -59,5 +59,5 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) { } } - return NULL; + return nullptr; } diff --git a/src/detection/cpucache/cpucache_linux.c b/src/detection/cpucache/cpucache_linux.c index 0657c84ae..a55184955 100644 --- a/src/detection/cpucache/cpucache_linux.c +++ b/src/detection/cpucache/cpucache_linux.c @@ -6,7 +6,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result, uint32_t baseLen = path->length; ffStrbufAppendS(path, "/level"); if (!ffReadFileBuffer(path->chars, buffer)) { - return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/level\") == NULL"; + return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/level\") == nullptr"; } uint32_t level = (uint32_t) ffStrbufToUInt(buffer, 0); @@ -17,7 +17,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result, ffStrbufSubstrBefore(path, baseLen); ffStrbufAppendS(path, "/size"); if (!ffReadFileBuffer(path->chars, buffer)) { - return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/size\") == NULL"; + return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/size\") == nullptr"; } uint32_t sizeKb = (uint32_t) ffStrbufToUInt(buffer, 0); @@ -28,7 +28,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result, ffStrbufSubstrBefore(path, baseLen); ffStrbufAppendS(path, "/type"); if (!ffReadFileBuffer(path->chars, buffer)) { - return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/type\") == NULL"; + return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/type\") == nullptr"; } ffStrbufTrimRightSpace(buffer); @@ -62,7 +62,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result, ffStrbufClear(buffer); ffStrbufAppendC(buffer, '['); if (!ffAppendFileBuffer(path->chars, buffer)) { - return "ffAppendFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/shared_cpu_list\") == NULL"; + return "ffAppendFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/shared_cpu_list\") == nullptr"; } ffStrbufTrimRightSpace(buffer); @@ -70,11 +70,11 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result, ffStrbufAppendF(buffer, "_%u_%u_%u_%u]", level, sizeKb, lineSize, cacheType); if (ffStrbufContain(added, buffer)) { - return NULL; + return nullptr; } ffStrbufAppend(added, buffer); ffCPUCacheAddItem(result, level, sizeKb * 1024, lineSize, cacheType); - return NULL; + return nullptr; } static const char* parseCpuCache(FFstrbuf* path, FFCPUCacheResult* result, FFstrbuf* buffer, FFstrbuf* added) { @@ -82,11 +82,11 @@ static const char* parseCpuCache(FFstrbuf* path, FFCPUCacheResult* result, FFstr uint32_t baseLen = path->length; FF_AUTO_CLOSE_DIR DIR* pathCacheDir = opendir(path->chars); if (!pathCacheDir) { - return "opendir(\"/sys/devices/system/cpu/cpuX/cache/\") == NULL"; + return "opendir(\"/sys/devices/system/cpu/cpuX/cache/\") == nullptr"; } struct dirent* pathCacheEntry; - while ((pathCacheEntry = readdir(pathCacheDir)) != NULL) { + while ((pathCacheEntry = readdir(pathCacheDir)) != nullptr) { if (!ffStrStartsWith(pathCacheEntry->d_name, "index") || !ffCharIsDigit(pathCacheEntry->d_name[strlen("index")])) { continue; } @@ -99,7 +99,7 @@ static const char* parseCpuCache(FFstrbuf* path, FFCPUCacheResult* result, FFstr ffStrbufSubstrBefore(path, baseLen); } - return NULL; + return nullptr; } const char* ffDetectCPUCache(FFCPUCacheResult* result) { @@ -108,14 +108,14 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) { uint32_t baseLen = path.length; FF_AUTO_CLOSE_DIR DIR* pathCpuDir = opendir(path.chars); if (!pathCpuDir) { - return "opendir(\"/sys/devices/system/cpu/\") == NULL"; + return "opendir(\"/sys/devices/system/cpu/\") == nullptr"; } FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY added = ffStrbufCreate(); struct dirent* pathCpuEntry; - while ((pathCpuEntry = readdir(pathCpuDir)) != NULL) { + while ((pathCpuEntry = readdir(pathCpuDir)) != nullptr) { if (!ffStrStartsWith(pathCpuEntry->d_name, "cpu") || !ffCharIsDigit(pathCpuEntry->d_name[strlen("cpu")])) { continue; @@ -128,5 +128,5 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) { } ffStrbufSubstrBefore(&path, baseLen); } - return NULL; + return nullptr; } diff --git a/src/detection/cpucache/cpucache_shared.c b/src/detection/cpucache/cpucache_shared.c index c13e35168..60ea3bdd0 100644 --- a/src/detection/cpucache/cpucache_shared.c +++ b/src/detection/cpucache/cpucache_shared.c @@ -78,5 +78,5 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) { ffCPUCacheAddItem(result, level, size, 0, type); } - return NULL; + return nullptr; } diff --git a/src/detection/cpucache/cpucache_windows.c b/src/detection/cpucache/cpucache_windows.c index b9d3815fd..c8459e069 100644 --- a/src/detection/cpucache/cpucache_windows.c +++ b/src/detection/cpucache/cpucache_windows.c @@ -5,9 +5,9 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) { LOGICAL_PROCESSOR_RELATIONSHIP lpr = RelationCache; DWORD length = 0; - NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), NULL, 0, &length); + NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), nullptr, 0, &length); if (length == 0) { - return "GetLogicalProcessorInformationEx(RelationCache, NULL, &length) failed"; + return "GetLogicalProcessorInformationEx(RelationCache, nullptr, &length) failed"; } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE @@ -43,5 +43,5 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) { } } - return NULL; + return nullptr; } diff --git a/src/detection/cpuusage/cpuusage.c b/src/detection/cpuusage/cpuusage.c index a78ae7b13..bbc005476 100644 --- a/src/detection/cpuusage/cpuusage.c +++ b/src/detection/cpuusage/cpuusage.c @@ -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; } diff --git a/src/detection/cpuusage/cpuusage_apple.c b/src/detection/cpuusage/cpuusage_apple.c index 50a8b15b4..bdec58aa1 100644 --- a/src/detection/cpuusage/cpuusage_apple.c +++ b/src/detection/cpuusage/cpuusage_apple.c @@ -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; } diff --git a/src/detection/cpuusage/cpuusage_bsd.c b/src/detection/cpuusage/cpuusage_bsd.c index f690d15d4..d3c43345c 100644 --- a/src/detection/cpuusage/cpuusage_bsd.c +++ b/src/detection/cpuusage/cpuusage_bsd.c @@ -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; } diff --git a/src/detection/cpuusage/cpuusage_haiku.c b/src/detection/cpuusage/cpuusage_haiku.c index f4d3c632d..35fba5949 100644 --- a/src/detection/cpuusage/cpuusage_haiku.c +++ b/src/detection/cpuusage/cpuusage_haiku.c @@ -23,5 +23,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) { info->totalAll = uptime; } - return NULL; + return nullptr; } diff --git a/src/detection/cpuusage/cpuusage_linux.c b/src/detection/cpuusage/cpuusage_linux.c index fd2f43bb8..e4711fff9 100644 --- a/src/detection/cpuusage/cpuusage_linux.c +++ b/src/detection/cpuusage/cpuusage_linux.c @@ -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; } diff --git a/src/detection/cpuusage/cpuusage_sunos.c b/src/detection/cpuusage/cpuusage_sunos.c index 813d74d24..aaefeb6a3 100644 --- a/src/detection/cpuusage/cpuusage_sunos.c +++ b/src/detection/cpuusage/cpuusage_sunos.c @@ -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; } diff --git a/src/detection/cpuusage/cpuusage_windows.c b/src/detection/cpuusage/cpuusage_windows.c index c23c28ac1..abc99882e 100644 --- a/src/detection/cpuusage/cpuusage_windows.c +++ b/src/detection/cpuusage/cpuusage_windows.c @@ -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); } diff --git a/src/detection/cursor/cursor_windows.c b/src/detection/cursor/cursor_windows.c index a6814ecc2..12f8d6a2e 100644 --- a/src/detection/cursor/cursor_windows.c +++ b/src/detection/cursor/cursor_windows.c @@ -4,11 +4,11 @@ #include "common/windows/registry.h" void ffDetectCursor(FFCursorResult* result) { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Cursors", &hKey, &result->error)) { - if (ffRegReadStrbuf(hKey, NULL, &result->theme, &result->error)) { + if (ffRegReadStrbuf(hKey, nullptr, &result->theme, &result->error)) { uint32_t cursorBaseSize; - if (ffRegReadUint(hKey, L"CursorBaseSize", &cursorBaseSize, NULL)) { + if (ffRegReadUint(hKey, L"CursorBaseSize", &cursorBaseSize, nullptr)) { // Not available on Windows 8.1 ffStrbufAppendUInt(&result->size, cursorBaseSize); }; diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c index de7a220c6..531a25004 100644 --- a/src/detection/de/de_linux.c +++ b/src/detection/de/de_linux.c @@ -50,7 +50,7 @@ static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { } if (result->length == 0) { - if (ffProcessAppendStdOut(result, (char* const[]) { "plasmashell", "--version", NULL }) == NULL) { // plasmashell 5.27.5 + if (ffProcessAppendStdOut(result, (char* const[]) { "plasmashell", "--version", nullptr }) == nullptr) { // plasmashell 5.27.5 ffStrbufSubstrAfterLastC(result, ' '); } } @@ -59,12 +59,12 @@ static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { static const char* getGnomeByDbus(FF_A_UNUSED FFstrbuf* result) { #ifdef FF_HAVE_DBUS FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; - if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != NULL) { + if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) { return "ffDBusLoadData() failed"; } ffDBusGetPropertyString(&dbus, "org.gnome.Shell", "/org/gnome/Shell", "org.gnome.Shell", "ShellVersion", result); - return NULL; + return nullptr; #else // FF_HAVE_DBUS return "ffDBusLoadData() failed: dbus support not compiled in"; #endif // FF_HAVE_DBUS @@ -74,7 +74,7 @@ static void getGnome(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { getGnomeByDbus(result); if (result->length == 0) { - if (ffProcessAppendStdOut(result, (char* const[]) { "gnome-shell", "--version", NULL }) == NULL) { // GNOME Shell 44.1 + if (ffProcessAppendStdOut(result, (char* const[]) { "gnome-shell", "--version", nullptr }) == nullptr) { // GNOME Shell 44.1 ffStrbufSubstrAfterLastC(result, ' '); } } @@ -88,7 +88,7 @@ static void getCinnamon(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { } if (result->length == 0) { - if (ffProcessAppendStdOut(result, (char* const[]) { "cinnamon", "--version", NULL }) == NULL) { // Cinnamon 6.2.2 + if (ffProcessAppendStdOut(result, (char* const[]) { "cinnamon", "--version", nullptr }) == nullptr) { // Cinnamon 6.2.2 ffStrbufSubstrAfterLastC(result, ' '); } } @@ -104,7 +104,7 @@ static void getMate(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { ffParseSemver(result, &major, &minor, µ); if (result->length == 0) { - ffProcessAppendStdOut(result, (char* const[]) { "mate-session", "--version", NULL }); + ffProcessAppendStdOut(result, (char* const[]) { "mate-session", "--version", nullptr }); ffStrbufSubstrAfterFirstC(result, ' '); ffStrbufTrim(result, ' '); @@ -117,7 +117,7 @@ static const char* getXfce4ByLib(FFstrbuf* result) { FF_LIBRARY_LOAD_MESSAGE(xfce4util, "libxfce4util" FF_LIBRARY_EXTENSION, 7); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xfce4util, xfce_version_string); ffStrbufSetS(result, ffxfce_version_string()); - return NULL; + return nullptr; #else FF_UNUSED(result); return "dlopen is disabled"; @@ -129,7 +129,7 @@ static void getXFCE4(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { if (result->length == 0) { // This is somewhat slow - ffProcessAppendStdOut(result, (char* const[]) { "xfce4-session", "--version", NULL }); + ffProcessAppendStdOut(result, (char* const[]) { "xfce4-session", "--version", nullptr }); ffStrbufSubstrBeforeFirstC(result, ')'); ffStrbufSubstrAfterLastC(result, ' '); @@ -149,7 +149,7 @@ static void getLXQt(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { if (result->length == 0) { // This is really, really, really slow. Thank you, LXQt developers - ffProcessAppendStdOut(result, (char* const[]) { "lxqt-session", "-v", NULL }); + ffProcessAppendStdOut(result, (char* const[]) { "lxqt-session", "-v", nullptr }); result->length = 0; // don't set '\0' byte ffParsePropLines(result->chars, "liblxqt", result); @@ -187,25 +187,25 @@ static const char* getTrinity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options ffStrbufSubstrBeforeLastC(&path, '/'); ffStrbufAppendS(&path, "/../lib/libtdecore.so"); - if (ffBinaryExtractStrings(path.chars, extractTdeVersion, result, strlen("R0.0.0")) == NULL) { - return NULL; + if (ffBinaryExtractStrings(path.chars, extractTdeVersion, result, strlen("R0.0.0")) == nullptr) { + return nullptr; } ffStrbufClear(&path); - if (ffProcessAppendStdOut(&path, (char* const[]) { "tde-config", "--version", NULL }) == NULL) { + if (ffProcessAppendStdOut(&path, (char* const[]) { "tde-config", "--version", nullptr }) == nullptr) { ffParsePropLines(path.chars, "TDE: ", result); - return NULL; + return nullptr; } return "All methods failed"; } static const char* getCosmic(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { - if (ffProcessAppendStdOut(result, (char* const[]) { "cosmic-comp", "--version", NULL }) == NULL) { + if (ffProcessAppendStdOut(result, (char* const[]) { "cosmic-comp", "--version", nullptr }) == nullptr) { // cosmic-comp 0.1.0 (git commit fa88002ba41d2edec25dd7ffdee9719fbb928fc0) ffStrbufSubstrAfterFirstC(result, ' '); ffStrbufSubstrBeforeFirstC(result, ' '); - return NULL; + return nullptr; } return "All methods failed"; @@ -214,11 +214,11 @@ static const char* getCosmic(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) static const char* getEnlightenmentByDbus(FF_A_UNUSED FFstrbuf* result) { #ifdef FF_HAVE_DBUS FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; - if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != NULL) { + if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) { return "ffDBusLoadData() failed"; } - DBusMessage* reply = ffDBusGetMethodReply(&dbus, "org.enlightenment.wm.service", "/org/enlightenment/wm/RemoteObject", "org.enlightenment.wm.Core", "Version", NULL, NULL); + DBusMessage* reply = ffDBusGetMethodReply(&dbus, "org.enlightenment.wm.service", "/org/enlightenment/wm/RemoteObject", "org.enlightenment.wm.Core", "Version", nullptr, nullptr); if (!reply) { return "ffDBusGetMethodReply() failed"; } @@ -234,7 +234,7 @@ static const char* getEnlightenmentByDbus(FF_A_UNUSED FFstrbuf* result) { } dbus.lib->ffdbus_message_unref(reply); - return NULL; + return nullptr; #else // FF_HAVE_DBUS return "ffDBusLoadData() failed: dbus support not compiled in"; #endif // FF_HAVE_DBUS @@ -244,7 +244,7 @@ static void getEnlightenment(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) getEnlightenmentByDbus(result); if (result->length == 0) { - if (ffProcessAppendStdOut(result, (char* const[]) { "enlightenment", "--version", NULL }) == NULL) { // ...\nVersion: 0.27.1\n... + if (ffProcessAppendStdOut(result, (char* const[]) { "enlightenment", "--version", nullptr }) == nullptr) { // ...\nVersion: 0.27.1\n... ffStrbufSubstrAfterFirstS(result, "Version: "); ffStrbufSubstrBeforeFirstC(result, '\n'); } @@ -280,5 +280,5 @@ const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOpti } else { return "Unsupported DE"; } - return NULL; + return nullptr; } diff --git a/src/detection/disk/disk.c b/src/detection/disk/disk.c index c86282d63..b1ad006bd 100644 --- a/src/detection/disk/disk.c +++ b/src/detection/disk/disk.c @@ -11,7 +11,7 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks) { return error; } if (disks->length == 0) { - return NULL; + return nullptr; } // We need to sort the disks, so that we can detect, which disk a path resides on @@ -27,7 +27,7 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks) { } } - return NULL; + return nullptr; } #ifndef _WIN32 diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index 9156d79ef..65c09cf30 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -51,7 +51,7 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) { ffStrbufSetS(&disk->name, str ? str + 1 : provider->lg_name); } - return NULL; + return nullptr; } #else static const char* detectFsLabel(FF_A_UNUSED struct statfs* fs, FF_A_UNUSED FFDisk* disk) { @@ -127,14 +127,14 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) { const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { #ifndef __NetBSD__ - int size = getfsstat(NULL, 0, MNT_WAIT); + int size = getfsstat(nullptr, 0, MNT_WAIT); if (size <= 0) { - return "getfsstat(NULL, 0, MNT_WAIT) failed"; + return "getfsstat(nullptr, 0, MNT_WAIT) failed"; } #else - int size = getvfsstat(NULL, 0, ST_WAIT); + int size = getvfsstat(nullptr, 0, ST_WAIT); if (size <= 0) { - return "getvfsstat(NULL, 0, ST_WAIT) failed"; + return "getvfsstat(nullptr, 0, ST_WAIT) failed"; } #endif @@ -210,5 +210,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { #endif } - return NULL; + return nullptr; } diff --git a/src/detection/disk/disk_haiku.cpp b/src/detection/disk/disk_haiku.cpp index 098789710..bce8932d6 100644 --- a/src/detection/disk/disk_haiku.cpp +++ b/src/detection/disk/disk_haiku.cpp @@ -70,5 +70,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { disk->createTime = (uint64_t) crTime * 1000; } } - return NULL; + return nullptr; } diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 720531731..9ef3954fa 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -107,14 +107,14 @@ static bool isPhysicalDevice(const struct mntent* device) { static void detectNameFromPath(FFDisk* disk, const struct stat* deviceStat, FFstrbuf* basePath) { FF_AUTO_CLOSE_DIR DIR* dir = opendir(basePath->chars); - if (dir == NULL) { + if (dir == nullptr) { return; } uint32_t basePathLength = basePath->length; struct dirent* entry; - while ((entry = readdir(dir)) != NULL) { + while ((entry = readdir(dir)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -218,11 +218,11 @@ static bool isRemovable(FFDisk* currentDisk) { snprintf(sysBlockPartition, ARRAY_SIZE(sysBlockPartition), "/sys/class/block/%s", currentDisk->mountFrom.chars + strlen("/dev/")); char sysBlockVolume[PATH_MAX]; // /sys/devices/pci0000:00/0000:00:14.0/usb4/4-3/4-3:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 - if (realpath(sysBlockPartition, sysBlockVolume) == NULL) { + if (realpath(sysBlockPartition, sysBlockVolume) == nullptr) { return false; } char* lastSlash = strrchr(sysBlockVolume, '/'); - if (lastSlash == NULL) { + if (lastSlash == nullptr) { return false; } strcpy(lastSlash + 1, "removable"); @@ -284,8 +284,8 @@ static void detectStats(FFDisk* disk) { const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { FILE* mountsFile = setmntent("/proc/mounts", "r"); - if (mountsFile == NULL) { - return "setmntent(\"/proc/mounts\", \"r\") == NULL"; + if (mountsFile == nullptr) { + return "setmntent(\"/proc/mounts\", \"r\") == nullptr"; } struct mntent* device; @@ -333,5 +333,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { endmntent(mountsFile); - return NULL; + return nullptr; } diff --git a/src/detection/disk/disk_sunos.c b/src/detection/disk/disk_sunos.c index 3d811e03e..85087fe7b 100644 --- a/src/detection/disk/disk_sunos.c +++ b/src/detection/disk/disk_sunos.c @@ -107,8 +107,8 @@ static void detectStats(FFDisk* disk) { const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { FF_AUTO_CLOSE_FILE FILE* mountsFile = fopen(MNTTAB, "r"); - if (mountsFile == NULL) { - return "fopen(\"" MNTTAB "\", \"r\") == NULL"; + if (mountsFile == nullptr) { + return "fopen(\"" MNTTAB "\", \"r\") == nullptr"; } struct mnttab device; @@ -141,5 +141,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { detectStats(disk); } - return NULL; + return nullptr; } diff --git a/src/detection/disk/disk_windows.c b/src/detection/disk/disk_windows.c index 0b3c93d3e..c5093fed2 100644 --- a/src/detection/disk/disk_windows.c +++ b/src/detection/disk/disk_windows.c @@ -46,7 +46,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { continue; } - FF_AUTO_CLOSE_FD HANDLE handle = CreateFileW(mountpointW, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + FF_AUTO_CLOSE_FD HANDLE handle = CreateFileW(mountpointW, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (handle == INVALID_HANDLE_VALUE) { continue; } @@ -56,7 +56,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { alignas(FILE_FS_ATTRIBUTE_INFORMATION) uint8_t bufFsAttr[1024]; FILE_FS_ATTRIBUTE_INFORMATION* fsAttr = NT_SUCCESS(NtQueryVolumeInformationFile(handle, &iosb, bufFsAttr, sizeof(bufFsAttr), FileFsAttributeInformation)) ? (FILE_FS_ATTRIBUTE_INFORMATION*) bufFsAttr - : NULL; + : nullptr; FF_STRBUF_AUTO_DESTROY diskFileSystemBuf = ffStrbufCreate(); if (fsAttr) { @@ -97,7 +97,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { alignas(FILE_FS_VOLUME_INFORMATION) uint8_t bufFsVolume[1024]; FILE_FS_VOLUME_INFORMATION* fsVolume = NT_SUCCESS(NtQueryVolumeInformationFile(handle, &iosb, bufFsVolume, sizeof(bufFsVolume), FileFsVolumeInformation)) ? (FILE_FS_VOLUME_INFORMATION*) bufFsVolume - : NULL; + : nullptr; if (fsVolume) { if (fsVolume->VolumeLabelLength > 0) { @@ -124,5 +124,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { } } - return NULL; + return nullptr; } diff --git a/src/detection/diskio/diskio.c b/src/detection/diskio/diskio.c index 6ff66be44..73f0075a7 100644 --- a/src/detection/diskio/diskio.c +++ b/src/detection/diskio/diskio.c @@ -22,14 +22,14 @@ void ffPrepareDiskIO(FFDiskIOOptions* options) { } const char* ffDetectDiskIO(FFlist* result, FFDiskIOOptions* options) { - const char* error = NULL; + const char* error = nullptr; if (options->detectTotal) { error = ffDiskIOGetIoCounters(result, options); if (error) { return error; } - return NULL; + return nullptr; } if (time1 == 0) { @@ -84,5 +84,5 @@ const char* ffDetectDiskIO(FFlist* result, FFDiskIOOptions* options) { time1 = time2; // Leak ioCounters1 here - return NULL; + return nullptr; } diff --git a/src/detection/diskio/diskio_apple.c b/src/detection/diskio/diskio_apple.c index dc2890701..c389cb2c4 100644 --- a/src/detection/diskio/diskio_apple.c +++ b/src/detection/diskio/diskio_apple.c @@ -53,5 +53,5 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { } } - return NULL; + return nullptr; } diff --git a/src/detection/diskio/diskio_bsd.c b/src/detection/diskio/diskio_bsd.c index f5eb4b8b8..dacb58f1f 100644 --- a/src/detection/diskio/diskio_bsd.c +++ b/src/detection/diskio/diskio_bsd.c @@ -27,12 +27,12 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { } struct devstat* snapIter; - while ((snapIter = geom_stats_snapshot_next(snap)) != NULL) { + while ((snapIter = geom_stats_snapshot_next(snap)) != nullptr) { if (snapIter->device_type & DEVSTAT_TYPE_PASS) { continue; } struct gident* geomId = geom_lookupid(&geomTree, snapIter->id); - if (geomId == NULL) { + if (geomId == nullptr) { continue; } if (geomId->lg_what != ISPROVIDER) { @@ -69,7 +69,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { geom_stats_snapshot_free(snap); geom_stats_close(); - return NULL; + return nullptr; } #else @@ -114,7 +114,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { free(stats.dinfo->mem_ptr); free(stats.dinfo); - return NULL; + return nullptr; } #endif diff --git a/src/detection/diskio/diskio_linux.c b/src/detection/diskio/diskio_linux.c index c7ddc55ea..327e75b6d 100644 --- a/src/detection/diskio/diskio_linux.c +++ b/src/detection/diskio/diskio_linux.c @@ -72,17 +72,17 @@ static const char* parseDiskIOCounters(int dfd, const char* devName, FFlist* res device->readCount = nRead; device->writeCount = nWritten; - return NULL; + return nullptr; } const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { FF_AUTO_CLOSE_DIR DIR* sysBlockDirp = opendir("/sys/block/"); - if (sysBlockDirp == NULL) { - return "opendir(\"/sys/block/\") == NULL"; + if (sysBlockDirp == nullptr) { + return "opendir(\"/sys/block/\") == nullptr"; } struct dirent* sysBlockEntry; - while ((sysBlockEntry = readdir(sysBlockDirp)) != NULL) { + while ((sysBlockEntry = readdir(sysBlockDirp)) != nullptr) { const char* const devName = sysBlockEntry->d_name; if (devName[0] == '.') { @@ -95,5 +95,5 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { } } - return NULL; + return nullptr; } diff --git a/src/detection/diskio/diskio_nbsd.c b/src/detection/diskio/diskio_nbsd.c index 9ca9578a8..c8835bf06 100644 --- a/src/detection/diskio/diskio_nbsd.c +++ b/src/detection/diskio/diskio_nbsd.c @@ -9,14 +9,14 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { int mib[] = { CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl) }; size_t len; - if (sysctl(mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0) < 0) { - return "sysctl({HW_IOSTATS}, NULL) failed"; + if (sysctl(mib, ARRAY_SIZE(mib), nullptr, &len, nullptr, 0) < 0) { + return "sysctl({HW_IOSTATS}, nullptr) failed"; } uint32_t nDrive = (uint32_t) (len / sizeof(struct io_sysctl)); FF_AUTO_FREE struct io_sysctl* stats = malloc(len); - if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, NULL, 0) < 0) { + if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, nullptr, 0) < 0) { return "sysctl({HW_IOSTATS}, stats) failed"; } @@ -46,5 +46,5 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { device->writeCount = st->wxfer; } - return NULL; + return nullptr; } diff --git a/src/detection/diskio/diskio_obsd.c b/src/detection/diskio/diskio_obsd.c index 8dbc67ebd..c367dcb98 100644 --- a/src/detection/diskio/diskio_obsd.c +++ b/src/detection/diskio/diskio_obsd.c @@ -8,14 +8,14 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { int mib[] = { CTL_HW, HW_DISKSTATS }; size_t len; - if (sysctl(mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0) < 0) { - return "sysctl({HW_DISKSTATS}, NULL) failed"; + if (sysctl(mib, ARRAY_SIZE(mib), nullptr, &len, nullptr, 0) < 0) { + return "sysctl({HW_DISKSTATS}, nullptr) failed"; } uint32_t nDrive = (uint32_t) (len / sizeof(struct diskstats)); FF_AUTO_FREE struct diskstats* stats = malloc(len); - if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, NULL, 0) < 0) { + if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, nullptr, 0) < 0) { return "sysctl({HW_DISKSTATS}, stats) failed"; } @@ -35,5 +35,5 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { device->writeCount = st->ds_wxfer; } - return NULL; + return nullptr; } diff --git a/src/detection/diskio/diskio_sunos.c b/src/detection/diskio/diskio_sunos.c index 7cda42081..837a7aa64 100644 --- a/src/detection/diskio/diskio_sunos.c +++ b/src/detection/diskio/diskio_sunos.c @@ -38,5 +38,5 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { device->writeCount = kio.writes; } - return NULL; + return nullptr; } diff --git a/src/detection/diskio/diskio_windows.c b/src/detection/diskio/diskio_windows.c index 80ad94e3d..ea0112938 100644 --- a/src/detection/diskio/diskio_windows.c +++ b/src/detection/diskio/diskio_windows.c @@ -6,7 +6,7 @@ #include static bool detectPhysicalDisk(const wchar_t* szDevice, FFlist* result, FFDiskIOOptions* options) { - FF_AUTO_CLOSE_FD HANDLE hDevice = CreateFileW(szDevice, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + FF_AUTO_CLOSE_FD HANDLE hDevice = CreateFileW(szDevice, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (hDevice == INVALID_HANDLE_VALUE) { return false; } @@ -24,7 +24,7 @@ static bool detectPhysicalDisk(const wchar_t* szDevice, FFlist* result, FFDiskIO &sddBuffer, ARRAY_SIZE(sddBuffer), &retSize, - NULL) || + nullptr) || retSize == 0) { return true; } @@ -57,7 +57,7 @@ static bool detectPhysicalDisk(const wchar_t* szDevice, FFlist* result, FFDiskIO } DISK_PERFORMANCE dp = {}; - if (DeviceIoControl(hDevice, IOCTL_DISK_PERFORMANCE, NULL, 0, &dp, sizeof(dp), &retSize, NULL)) { + if (DeviceIoControl(hDevice, IOCTL_DISK_PERFORMANCE, nullptr, 0, &dp, sizeof(dp), &retSize, nullptr)) { device->bytesRead = (uint64_t) dp.BytesRead.QuadPart; device->readCount = (uint64_t) dp.ReadCount; device->bytesWritten = (uint64_t) dp.BytesWritten.QuadPart; @@ -97,5 +97,5 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { } } - return NULL; + return nullptr; } diff --git a/src/detection/displayserver/displayserver.c b/src/detection/displayserver/displayserver.c index e91377109..b5cc8eb7d 100644 --- a/src/detection/displayserver/displayserver.c +++ b/src/detection/displayserver/displayserver.c @@ -18,7 +18,7 @@ FFDisplayResult* ffdsAppendDisplay( uint32_t physicalHeight, const char* platformApi) { if (width == 0 || height == 0) { - return NULL; + return nullptr; } FFDisplayResult* display = FF_LIST_ADD(FFDisplayResult, result->displays); diff --git a/src/detection/displayserver/displayserver_android.c b/src/detection/displayserver/displayserver_android.c index 9b2848a13..13f5fab0e 100644 --- a/src/detection/displayserver/displayserver_android.c +++ b/src/detection/displayserver/displayserver_android.c @@ -33,8 +33,8 @@ static void detectWithDumpsys(FFDisplayServerResult* ds) { if (ffProcessAppendStdOut(&buf, (char*[]) { "/system/bin/dumpsys", "display", - NULL, - }) != NULL || + nullptr, + }) != nullptr || buf.length == 0) { return; // Only works in `adb shell`, or when rooted } @@ -119,7 +119,7 @@ static bool detectWithGetprop(FFDisplayServerResult* ds) { 0, 0, 0, - NULL, + nullptr, FF_DISPLAY_TYPE_BUILTIN, false, 0, diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index a539cb3f9..f761fbb5f 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -50,7 +50,7 @@ static void detectDisplays(FFDisplayServerResult* ds) { } ffStrbufClear(&buffer); - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = NULL; + CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = nullptr; #ifdef MAC_OS_X_VERSION_10_15 if (CoreDisplay_DisplayCreateInfoDictionary) { displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen); @@ -77,14 +77,14 @@ static void detectDisplays(FFDisplayServerResult* ds) { ffEdidGetPhysicalSize(edidData, &physicalWidth, &physicalHeight); ffEdidGetSerial(edidData, &serial); } - } else if (!builtin && ffCfDictGetString(displayInfo, CFSTR(kIODisplayLocationKey), &buffer) == NULL) { + } else if (!builtin && ffCfDictGetString(displayInfo, CFSTR(kIODisplayLocationKey), &buffer) == nullptr) { FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t ioDisplay = IORegistryEntryFromPath(MACH_PORT_NULL, buffer.chars); ffStrbufClear(&buffer); if (ioDisplay) { FF_CFTYPE_AUTO_RELEASE CFDictionaryRef displayAttrRef = IORegistryEntryCreateCFProperty(ioDisplay, CFSTR("DisplayAttributes"), kCFAllocatorDefault, kNilOptions); if (displayAttrRef && CFGetTypeID(displayAttrRef) == CFDictionaryGetTypeID()) { CFDictionaryRef productAttrs; - if (ffCfDictGetDict(displayAttrRef, CFSTR("ProductAttributes"), &productAttrs) == NULL) { + if (ffCfDictGetDict(displayAttrRef, CFSTR("ProductAttributes"), &productAttrs) == nullptr) { ffCfDictGetString(productAttrs, CFSTR("AlphanumericSerialNumber"), &serial); ffCfDictGetString(productAttrs, CFSTR("ProductName"), &buffer); } @@ -94,13 +94,13 @@ static void detectDisplays(FFDisplayServerResult* ds) { if (!buffer.length) { CFDictionaryRef productNames; - if (ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames) == NULL) { + if (ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames) == nullptr) { ffCfDictGetString(productNames, CFSTR("en_US"), &buffer); } } if (!physicalWidth || !physicalHeight) { - if (ffCfDictGetInt(displayInfo, CFSTR(kDisplayHorizontalImageSize), (int*) &physicalWidth) == NULL) { + if (ffCfDictGetInt(displayInfo, CFSTR(kDisplayHorizontalImageSize), (int*) &physicalWidth) == nullptr) { ffCfDictGetInt(displayInfo, CFSTR(kDisplayVerticalImageSize), (int*) &physicalHeight); } } @@ -108,7 +108,7 @@ static void detectDisplays(FFDisplayServerResult* ds) { ffCfDictGetInt(displayInfo, CFSTR("kCGDisplayPixelWidth"), (int*) &preferredWidth); ffCfDictGetInt(displayInfo, CFSTR("kCGDisplayPixelHeight"), (int*) &preferredHeight); if (preferredWidth && preferredHeight) { - FF_CFTYPE_AUTO_RELEASE CFArrayRef allModes = CGDisplayCopyAllDisplayModes(screen, NULL); + FF_CFTYPE_AUTO_RELEASE CFArrayRef allModes = CGDisplayCopyAllDisplayModes(screen, nullptr); if (allModes) { for (CFIndex i = 0, count = CFArrayGetCount(allModes); i < count; i++) { CGDisplayModeRef modeInfo = (CGDisplayModeRef) CFArrayGetValueAtIndex(allModes, i); @@ -196,10 +196,10 @@ static void detectDisplays(FFDisplayServerResult* ds) { if (displayInfo) { int value; - if (ffCfDictGetInt(displayInfo, CFSTR(kDisplayYearOfManufacture), &value) == NULL) { + if (ffCfDictGetInt(displayInfo, CFSTR(kDisplayYearOfManufacture), &value) == nullptr) { display->manufactureYear = (uint16_t) value; } - if (ffCfDictGetInt(displayInfo, CFSTR(kDisplayWeekOfManufacture), &value) == NULL) { + if (ffCfDictGetInt(displayInfo, CFSTR(kDisplayWeekOfManufacture), &value) == nullptr) { display->manufactureWeek = (uint16_t) value; } } diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 5c4f57e63..fe500f86e 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -10,7 +10,7 @@ static inline void freeArgBuffer(FFArgBuffer* buffer) { if (buffer->data) { free(buffer->data); } - buffer->data = NULL; + buffer->data = nullptr; buffer->length = 0; } #define FF_AUTO_FREE_ARG_BUFFER FF_A_CLEANUP(freeArgBuffer) @@ -31,7 +31,7 @@ static void detectDisplays(FFDisplayServerResult* ds) { paths, &modeCount, modes, - NULL) == ERROR_SUCCESS) { + nullptr) == ERROR_SUCCESS) { for (uint32_t i = 0; i < pathCount; ++i) { const DISPLAYCONFIG_PATH_INFO* path = &paths[i]; const DISPLAYCONFIG_SOURCE_MODE* sourceMode = &modes[path->sourceInfo.modeInfoIdx].sourceMode; @@ -64,9 +64,9 @@ static void detectDisplays(FFDisplayServerResult* ds) { } wcscpy(pRegPath, L"Device Parameters"); - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regPath, &hKey, NULL) && - ffRegReadData(hKey, L"EDID", &edid, NULL) && + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regPath, &hKey, nullptr) && + ffRegReadData(hKey, L"EDID", &edid, nullptr) && ffEdidIsValid(edid.data, edid.length)) { ffEdidGetName(edid.data, &name); ffEdidGetPhysicalSize(edid.data, &physicalWidth, &physicalHeight); @@ -122,12 +122,12 @@ static void detectDisplays(FFDisplayServerResult* ds) { } if (systemDpi == 0) { - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); systemDpi = (uint32_t) GetDeviceCaps(hdc, LOGPIXELSX); if (systemDpi == 0) { systemDpi = 96; } - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); } if (path->targetInfo.rotation == DISPLAYCONFIG_ROTATION_ROTATE90 || diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 70d2d4001..8907b7bdf 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -22,12 +22,12 @@ static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) { return; } - if (getenv("WAYLAND_DISPLAY") != NULL || getenv("WAYLAND_SOCKET") != NULL) { + if (getenv("WAYLAND_DISPLAY") != nullptr || getenv("WAYLAND_SOCKET") != nullptr) { ffStrbufSetStatic(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND); return; } - if (getenv("DISPLAY") != NULL) // XWayland also set this + if (getenv("DISPLAY") != nullptr) // XWayland also set this { ffStrbufSetStatic(&result->wmProtocolName, FF_WM_PROTOCOL_X11); return; @@ -73,7 +73,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) { ffStrbufClear(&buf); if (ffSettingsGetFreeBSDKenv("screen.height", &buf)) { uint32_t height = (uint32_t) ffStrbufToUInt(&buf, 0); - ffdsAppendDisplay(ds, width, height, 0, 0, 0, 0, 0, 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, false, 0, 0, 0, "kenv"); + ffdsAppendDisplay(ds, width, height, 0, 0, 0, 0, 0, 0, nullptr, FF_DISPLAY_TYPE_UNKNOWN, false, 0, 0, 0, "kenv"); } } } diff --git a/src/detection/displayserver/linux/drm.c b/src/detection/displayserver/linux/drm.c index 61c30cd14..7c45b36c4 100644 --- a/src/detection/displayserver/linux/drm.c +++ b/src/detection/displayserver/linux/drm.c @@ -11,7 +11,7 @@ static const char* drmParseSysfs(FFDisplayServerResult* result) { const char* drmDirPath = "/sys/class/drm/"; FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath); - if (dirp == NULL) { + if (dirp == nullptr) { return "opendir(drmDirPath) failed"; } @@ -21,7 +21,7 @@ static const char* drmParseSysfs(FFDisplayServerResult* result) { uint32_t drmDirLength = drmDir.length; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -105,7 +105,7 @@ static const char* drmParseSysfs(FFDisplayServerResult* result) { ffStrbufSubstrBefore(&drmDir, drmDirLength); } - return NULL; + return nullptr; } #endif @@ -179,7 +179,7 @@ FF_A_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edid const char* drmDirPath = "/sys/class/drm/"; FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath); - if (dirp == NULL) { + if (dirp == nullptr) { return "opendir(drmDirPath) failed"; } @@ -189,7 +189,7 @@ FF_A_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edid uint32_t drmDirLength = drmDir.length; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -201,7 +201,7 @@ FF_A_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edid ffStrbufAppendS(&drmDir, "/connector_id"); ffReadFileData(drmDir.chars, ARRAY_SIZE(connectorId), connectorId); - if (strtoul(connectorId, NULL, 10) != connId) { + if (strtoul(connectorId, nullptr, 10) != connId) { ffStrbufSubstrBefore(&drmDir, drmDirLength); continue; } @@ -209,7 +209,7 @@ FF_A_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edid ffStrbufSubstrBefore(&drmDir, drmDirWithDnameLength); ffStrbufAppendS(&drmDir, "/edid"); *edidLength = ffReadFileData(drmDir.chars, (uint32_t) *edidLength, edidData); - return NULL; + return nullptr; } return "Failed to match connector ID"; @@ -217,7 +217,7 @@ FF_A_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edid static const char* drmConnectLibdrm(FFDisplayServerResult* result) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/dev/dri/"); - if (dirp == NULL) { + if (dirp == nullptr) { return "opendir(/dev/dri/) failed"; } int drifd = dirfd(dirp); @@ -225,7 +225,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { int nSuccess = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.' || !ffStrStartsWith(entry->d_name, "card")) { continue; } @@ -392,7 +392,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { if (name.length == 0) { const char* connectorTypeName = drmType2Name(conn.connector_type); - if (connectorTypeName == NULL) { + if (connectorTypeName == nullptr) { connectorTypeName = "Unknown"; } ffStrbufSetF(&name, "%s-%d", connectorTypeName, iConn + 1); @@ -429,7 +429,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { } } - return nSuccess > 0 ? NULL : "No connectors found using libdrm"; + return nSuccess > 0 ? nullptr : "No connectors found using libdrm"; } #endif @@ -437,8 +437,8 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { const char* ffdsConnectDrm(FF_A_UNUSED FFDisplayServerResult* result) { #if FF_HAVE_DRM if (instance.config.general.dsForceDrm != FF_DS_FORCE_DRM_TYPE_SYSFS_ONLY) { - if (drmConnectLibdrm(result) == NULL) { - return NULL; + if (drmConnectLibdrm(result) == nullptr) { + return nullptr; } } #endif diff --git a/src/detection/displayserver/linux/wayland/global-output.c b/src/detection/displayserver/linux/wayland/global-output.c index e15199218..de69b2cde 100644 --- a/src/detection/displayserver/linux/wayland/global-output.c +++ b/src/detection/displayserver/linux/wayland/global-output.c @@ -100,8 +100,8 @@ static const struct wp_image_description_info_v1_listener wpImageDescInfoListene const char* ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version) { const char* api = "wayland-base"; uint32_t bindVersion = min(version, WL_OUTPUT_DESCRIPTION_SINCE_VERSION); - struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &wl_output_interface, bindVersion, name, wl_output_interface.name, bindVersion, NULL); - if (output == NULL) { + struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &wl_output_interface, bindVersion, name, wl_output_interface.name, bindVersion, nullptr); + if (output == nullptr) { return "Failed to create wl_output"; } @@ -125,7 +125,7 @@ const char* ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* if (wldata->zxdgOutputManager) { uint32_t bindVersion = min(version, ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION); - struct wl_proxy* zxdgOutput = wldata->ffwl_proxy_marshal_constructor_versioned(wldata->zxdgOutputManager, ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, bindVersion, NULL, output); + struct wl_proxy* zxdgOutput = wldata->ffwl_proxy_marshal_constructor_versioned(wldata->zxdgOutputManager, ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, bindVersion, nullptr, output); if (zxdgOutput) { wldata->ffwl_proxy_add_listener(zxdgOutput, (void (**)(void)) &zxdgOutputListener, &display); @@ -137,12 +137,12 @@ const char* ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* if (wldata->wpColorManager) { uint32_t bindVersion = min(version, WP_COLOR_MANAGER_V1_GET_OUTPUT_SINCE_VERSION); - struct wl_proxy* wpColorOutput = wldata->ffwl_proxy_marshal_constructor_versioned(wldata->wpColorManager, WP_COLOR_MANAGER_V1_GET_OUTPUT, &wp_color_management_output_v1_interface, bindVersion, NULL, output); + struct wl_proxy* wpColorOutput = wldata->ffwl_proxy_marshal_constructor_versioned(wldata->wpColorManager, WP_COLOR_MANAGER_V1_GET_OUTPUT, &wp_color_management_output_v1_interface, bindVersion, nullptr, output); if (wpColorOutput) { - struct wl_proxy* wpImageDesc = wldata->ffwl_proxy_marshal_constructor_versioned(wpColorOutput, WP_COLOR_MANAGEMENT_OUTPUT_V1_GET_IMAGE_DESCRIPTION, &wp_image_description_v1_interface, bindVersion, NULL); + struct wl_proxy* wpImageDesc = wldata->ffwl_proxy_marshal_constructor_versioned(wpColorOutput, WP_COLOR_MANAGEMENT_OUTPUT_V1_GET_IMAGE_DESCRIPTION, &wp_image_description_v1_interface, bindVersion, nullptr); if (wpImageDesc) { - struct wl_proxy* wpImageDescInfo = wldata->ffwl_proxy_marshal_constructor_versioned(wpImageDesc, WP_IMAGE_DESCRIPTION_V1_GET_INFORMATION, &wp_image_description_info_v1_interface, bindVersion, NULL); + struct wl_proxy* wpImageDescInfo = wldata->ffwl_proxy_marshal_constructor_versioned(wpImageDesc, WP_IMAGE_DESCRIPTION_V1_GET_INFORMATION, &wp_image_description_info_v1_interface, bindVersion, nullptr); if (wpImageDescInfo) { wldata->ffwl_proxy_add_listener(wpImageDescInfo, (void (**)(void)) &wpImageDescInfoListener, &display); wldata->ffwl_display_roundtrip(wldata->display); @@ -205,31 +205,31 @@ const char* ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* ffStrbufDestroy(&display.name); ffStrbufDestroy(&display.edidName); - return NULL; + return nullptr; } const char* ffWaylandHandleZxdgOutput(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version) { uint32_t bindVersion = min(version, ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT_SINCE_VERSION); - struct wl_proxy* manager = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &zxdg_output_manager_v1_interface, bindVersion, name, zxdg_output_manager_v1_interface.name, bindVersion, NULL); - if (manager == NULL) { + struct wl_proxy* manager = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &zxdg_output_manager_v1_interface, bindVersion, name, zxdg_output_manager_v1_interface.name, bindVersion, nullptr); + if (manager == nullptr) { return "Failed to create zxdg_output_manager_v1"; } wldata->zxdgOutputManager = manager; - return NULL; + return nullptr; } const char* ffWaylandHandleWpColor(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version) { uint32_t bindVersion = min(version, WP_COLOR_MANAGER_V1_GET_OUTPUT_SINCE_VERSION); - struct wl_proxy* manager = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &wp_color_manager_v1_interface, bindVersion, name, wp_color_manager_v1_interface.name, bindVersion, NULL); - if (manager == NULL) { + struct wl_proxy* manager = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &wp_color_manager_v1_interface, bindVersion, name, wp_color_manager_v1_interface.name, bindVersion, nullptr); + if (manager == nullptr) { return "Failed to create wp_color_manager_v1"; } wldata->wpColorManager = manager; - return NULL; + return nullptr; } #endif diff --git a/src/detection/displayserver/linux/wayland/kde-output-device-v2-client-protocol.h b/src/detection/displayserver/linux/wayland/kde-output-device-v2-client-protocol.h index 44ab8ab13..aee08a11d 100644 --- a/src/detection/displayserver/linux/wayland/kde-output-device-v2-client-protocol.h +++ b/src/detection/displayserver/linux/wayland/kde-output-device-v2-client-protocol.h @@ -252,7 +252,7 @@ kde_output_device_registry_v2_destroy(struct kde_output_device_registry_v2* kde_ // kde_output_device_registry_v2_stop(struct kde_output_device_registry_v2* kde_output_device_registry_v2) { // wl_proxy_marshal_flags((struct wl_proxy*) kde_output_device_registry_v2, // KDE_OUTPUT_DEVICE_REGISTRY_V2_STOP, -// NULL, +// nullptr, // wl_proxy_get_version((struct wl_proxy*) kde_output_device_registry_v2), // 0); // } @@ -1248,7 +1248,7 @@ kde_output_device_v2_destroy(struct kde_output_device_v2* kde_output_device_v2) // kde_output_device_v2_release(struct kde_output_device_v2* kde_output_device_v2) { // wl_proxy_marshal_flags((struct wl_proxy*) kde_output_device_v2, // KDE_OUTPUT_DEVICE_V2_RELEASE, -// NULL, +// nullptr, // wl_proxy_get_version((struct wl_proxy*) kde_output_device_v2), // WL_MARSHAL_FLAG_DESTROY); // } diff --git a/src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c b/src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c index 9dd755676..9f6a4bdaf 100644 --- a/src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c +++ b/src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c @@ -21,14 +21,14 @@ extern const struct wl_interface kde_output_device_mode_v2_interface; extern const struct wl_interface kde_output_device_v2_interface; static const struct wl_interface* kde_output_device_v2_types[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, &kde_output_device_v2_interface, &kde_output_device_mode_v2_interface, &kde_output_device_mode_v2_interface, @@ -120,7 +120,7 @@ WL_EXPORT const struct wl_interface kde_output_device_mode_v2_interface = { "kde_output_device_mode_v2", 22, 0, - NULL, + nullptr, 5, kde_output_device_mode_v2_events, }; diff --git a/src/detection/displayserver/linux/wayland/kde-output.c b/src/detection/displayserver/linux/wayland/kde-output.c index 73f9ac5af..272b03df3 100644 --- a/src/detection/displayserver/linux/wayland/kde-output.c +++ b/src/detection/displayserver/linux/wayland/kde-output.c @@ -103,7 +103,7 @@ static void waylandKdeEdidListener(void* data, FF_A_UNUSED struct kde_output_dev static void waylandKdeEnabledListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, int32_t enabled) { WaylandDisplay* wldata = (WaylandDisplay*) data; if (!enabled) { - wldata->internal = NULL; + wldata->internal = nullptr; } } @@ -217,7 +217,7 @@ static const char* waylandKdeHandleOutput(WaylandData* wldata, struct wl_proxy* FF_LIST_FOR_EACH (WaylandKdeMode, m, modes) { if (m->pMode) { wldata->ffwl_proxy_destroy((struct wl_proxy*) m->pMode); - m->pMode = NULL; + m->pMode = nullptr; } } @@ -268,14 +268,14 @@ static const char* waylandKdeHandleOutput(WaylandData* wldata, struct wl_proxy* ffStrbufDestroy(&display.name); ffStrbufDestroy(&display.edidName); - return NULL; + return nullptr; } const char* ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version) { // TODO: remove this in future versions uint32_t bindVersion = min(version, KDE_OUTPUT_DEVICE_V2_PRIORITY_SINCE_VERSION); - struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &kde_output_device_v2_interface, bindVersion, name, kde_output_device_v2_interface.name, bindVersion, NULL); - if (output == NULL) { + struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &kde_output_device_v2_interface, bindVersion, name, kde_output_device_v2_interface.name, bindVersion, nullptr); + if (output == nullptr) { return "Failed to create kde_output_device_v2"; } @@ -293,8 +293,8 @@ static struct kde_output_device_registry_v2_listener registryListener = { const char* ffWaylandHandleKdeOutputRegistry(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version) { uint32_t bindVersion = min(version, KDE_OUTPUT_DEVICE_REGISTRY_V2_OUTPUT_SINCE_VERSION); - struct wl_proxy* outputRegistry = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &kde_output_device_registry_v2_interface, bindVersion, name, kde_output_device_registry_v2_interface.name, bindVersion, NULL); - if (outputRegistry == NULL) { + struct wl_proxy* outputRegistry = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &kde_output_device_registry_v2_interface, bindVersion, name, kde_output_device_registry_v2_interface.name, bindVersion, nullptr); + if (outputRegistry == nullptr) { return "Failed to create kde_output_device_registry_v2"; } if (wldata->ffwl_proxy_add_listener(outputRegistry, (void (**)(void)) ®istryListener, wldata) < 0) { @@ -307,7 +307,7 @@ const char* ffWaylandHandleKdeOutputRegistry(WaylandData* wldata, struct wl_regi } wldata->ffwl_proxy_destroy(outputRegistry); - return NULL; + return nullptr; } #endif diff --git a/src/detection/displayserver/linux/wayland/wayland.c b/src/detection/displayserver/linux/wayland/wayland.c index 647aa067f..a1d7edf34 100644 --- a/src/detection/displayserver/linux/wayland/wayland.c +++ b/src/detection/displayserver/linux/wayland/wayland.c @@ -48,7 +48,7 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) { size_t size = 4096; ffStrbufEnsureFixedLengthFree(&result->wmProcessName, (uint32_t) size); - if (sysctl((int[]) { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, ucred.cr_pid }, 4, result->wmProcessName.chars, &size, NULL, 0) != 0) { + if (sysctl((int[]) { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, ucred.cr_pid }, 4, result->wmProcessName.chars, &size, nullptr, 0) != 0) { return false; } result->wmProcessName.length = (uint32_t) size - 1; @@ -82,17 +82,17 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u if ((wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_NONE || wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_GLOBAL) && ffStrEquals(interface, wl_output_interface.name)) { wldata->protocolType = FF_WAYLAND_PROTOCOL_TYPE_GLOBAL; - if (ffWaylandHandleGlobalOutput(wldata, registry, name, version) != NULL) { + if (ffWaylandHandleGlobalOutput(wldata, registry, name, version) != nullptr) { wldata->protocolType = FF_WAYLAND_PROTOCOL_TYPE_NONE; } } else if ((wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_NONE) && ffStrEquals(interface, kde_output_device_registry_v2_interface.name)) { wldata->protocolType = FF_WAYLAND_PROTOCOL_TYPE_KDE_REGISTRY; - if (ffWaylandHandleKdeOutputRegistry(wldata, registry, name, version) != NULL) { + if (ffWaylandHandleKdeOutputRegistry(wldata, registry, name, version) != nullptr) { wldata->protocolType = FF_WAYLAND_PROTOCOL_TYPE_NONE; } } else if ((wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_NONE || wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_KDE_DEPRECATED) && ffStrEquals(interface, kde_output_device_v2_interface.name)) { wldata->protocolType = FF_WAYLAND_PROTOCOL_TYPE_KDE_DEPRECATED; - if (ffWaylandHandleKdeOutput(wldata, registry, name, version) != NULL) { + if (ffWaylandHandleKdeOutput(wldata, registry, name, version) != nullptr) { wldata->protocolType = FF_WAYLAND_PROTOCOL_TYPE_NONE; } } else if ((wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_GLOBAL || wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_NONE) && ffStrEquals(interface, zxdg_output_manager_v1_interface.name)) { @@ -109,12 +109,12 @@ static FF_A_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* const char* drmDirPath = "/sys/class/drm/"; FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath); - if (dirp == NULL) { + if (dirp == nullptr) { return false; } struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { const char* plainName = entry->d_name; if (ffStrStartsWith(plainName, "card")) { const char* tmp = strchr(plainName + strlen("card"), '-'); @@ -218,7 +218,7 @@ uint32_t ffWaylandHandleRotation(WaylandDisplay* display) { } const char* ffdsConnectWayland(FFDisplayServerResult* result) { - if (getenv("XDG_RUNTIME_DIR") == NULL) { + if (getenv("XDG_RUNTIME_DIR") == nullptr) { return "Wayland requires $XDG_RUNTIME_DIR being set"; } @@ -236,17 +236,17 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) { FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(wayland, data, wl_proxy_destroy) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(wayland, data, wl_display_roundtrip) - data.display = ffwl_display_connect(NULL); - if (data.display == NULL) { - return "wl_display_connect returned NULL"; + data.display = ffwl_display_connect(nullptr); + if (data.display == nullptr) { + return "wl_display_connect returned nullptr"; } waylandDetectWM(ffwl_display_get_fd(data.display), result); - struct wl_proxy* registry = ffwl_proxy_marshal_constructor((struct wl_proxy*) data.display, WL_DISPLAY_GET_REGISTRY, &wl_registry_interface, NULL); - if (registry == NULL) { + struct wl_proxy* registry = ffwl_proxy_marshal_constructor((struct wl_proxy*) data.display, WL_DISPLAY_GET_REGISTRY, &wl_registry_interface, nullptr); + if (registry == nullptr) { ffwl_display_disconnect(data.display); - return "wl_display_get_registry returned NULL"; + return "wl_display_get_registry returned nullptr"; } data.result = result; @@ -275,7 +275,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) { ? "monitors.xml" : ffStrbufEqualS(&result->wmProcessName, "cinnamon") ? "cinnamon-monitors.xml" - : NULL; + : nullptr; if (fileName) { FF_STRBUF_AUTO_DESTROY monitorsXml = ffStrbufCreate(); FF_LIST_FOR_EACH (FFstrbuf, basePath, instance.state.platform.configDirs) { @@ -336,7 +336,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) { // So we can set set the session type to wayland. // This is used as an indicator that we are running wayland by the x11 backends. ffStrbufSetStatic(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND); - return NULL; + return nullptr; } #else diff --git a/src/detection/displayserver/linux/wayland/wl-output-protocol.c b/src/detection/displayserver/linux/wayland/wl-output-protocol.c index 86701209a..7f50c7e60 100644 --- a/src/detection/displayserver/linux/wayland/wl-output-protocol.c +++ b/src/detection/displayserver/linux/wayland/wl-output-protocol.c @@ -52,38 +52,38 @@ extern const struct wl_interface wl_surface_interface; extern const struct wl_interface wl_touch_interface; static const struct wl_interface *wayland_types[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, &wl_callback_interface, &wl_registry_interface, &wl_surface_interface, &wl_region_interface, &wl_buffer_interface, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, &wl_shm_pool_interface, - NULL, - NULL, + nullptr, + nullptr, &wl_data_source_interface, &wl_surface_interface, &wl_surface_interface, - NULL, + nullptr, &wl_data_source_interface, - NULL, + nullptr, &wl_data_offer_interface, - NULL, + nullptr, &wl_surface_interface, - NULL, - NULL, + nullptr, + nullptr, &wl_data_offer_interface, &wl_data_offer_interface, &wl_data_source_interface, @@ -92,27 +92,27 @@ static const struct wl_interface *wayland_types[] = { &wl_shell_surface_interface, &wl_surface_interface, &wl_seat_interface, - NULL, + nullptr, &wl_seat_interface, - NULL, - NULL, + nullptr, + nullptr, &wl_surface_interface, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, &wl_output_interface, &wl_seat_interface, - NULL, + nullptr, &wl_surface_interface, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, &wl_output_interface, &wl_buffer_interface, - NULL, - NULL, + nullptr, + nullptr, &wl_callback_interface, &wl_region_interface, &wl_region_interface, @@ -121,27 +121,27 @@ static const struct wl_interface *wayland_types[] = { &wl_pointer_interface, &wl_keyboard_interface, &wl_touch_interface, - NULL, + nullptr, &wl_surface_interface, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, &wl_surface_interface, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, &wl_surface_interface, - NULL, + nullptr, &wl_surface_interface, - NULL, - NULL, + nullptr, + nullptr, &wl_surface_interface, - NULL, - NULL, + nullptr, + nullptr, &wl_surface_interface, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, &wl_subsurface_interface, &wl_surface_interface, &wl_surface_interface, @@ -187,7 +187,7 @@ static const struct wl_message wl_callback_events[] = { WL_EXPORT const struct wl_interface wl_callback_interface = { "wl_callback", 1, - 0, NULL, + 0, nullptr, 1, wl_callback_events, }; @@ -199,7 +199,7 @@ static const struct wl_message wl_compositor_requests[] = { WL_EXPORT const struct wl_interface wl_compositor_interface = { "wl_compositor", 6, 2, wl_compositor_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wl_shm_pool_requests[] = { @@ -211,7 +211,7 @@ static const struct wl_message wl_shm_pool_requests[] = { WL_EXPORT const struct wl_interface wl_shm_pool_interface = { "wl_shm_pool", 2, 3, wl_shm_pool_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wl_shm_requests[] = { @@ -313,7 +313,7 @@ static const struct wl_message wl_data_device_manager_requests[] = { WL_EXPORT const struct wl_interface wl_data_device_manager_interface = { "wl_data_device_manager", 3, 2, wl_data_device_manager_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wl_shell_requests[] = { @@ -323,7 +323,7 @@ static const struct wl_message wl_shell_requests[] = { WL_EXPORT const struct wl_interface wl_shell_interface = { "wl_shell", 1, 1, wl_shell_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wl_shell_surface_requests[] = { @@ -488,7 +488,7 @@ static const struct wl_message wl_region_requests[] = { WL_EXPORT const struct wl_interface wl_region_interface = { "wl_region", 1, 3, wl_region_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wl_subcompositor_requests[] = { @@ -499,7 +499,7 @@ static const struct wl_message wl_subcompositor_requests[] = { WL_EXPORT const struct wl_interface wl_subcompositor_interface = { "wl_subcompositor", 1, 2, wl_subcompositor_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wl_subsurface_requests[] = { @@ -514,7 +514,7 @@ static const struct wl_message wl_subsurface_requests[] = { WL_EXPORT const struct wl_interface wl_subsurface_interface = { "wl_subsurface", 1, 6, wl_subsurface_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wl_fixes_requests[] = { @@ -525,7 +525,7 @@ static const struct wl_message wl_fixes_requests[] = { WL_EXPORT const struct wl_interface wl_fixes_interface = { "wl_fixes", 1, 2, wl_fixes_requests, - 0, NULL, + 0, nullptr, }; #endif diff --git a/src/detection/displayserver/linux/wayland/wp-color-management-v1-client-protocol.h b/src/detection/displayserver/linux/wayland/wp-color-management-v1-client-protocol.h index 5db1d7121..0b8a4926b 100644 --- a/src/detection/displayserver/linux/wayland/wp-color-management-v1-client-protocol.h +++ b/src/detection/displayserver/linux/wayland/wp-color-management-v1-client-protocol.h @@ -1059,7 +1059,7 @@ static inline void wp_color_manager_v1_destroy(struct wp_color_manager_v1 *wp_color_manager_v1) { wl_proxy_marshal_flags((struct wl_proxy *) wp_color_manager_v1, - WP_COLOR_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), WL_MARSHAL_FLAG_DESTROY); + WP_COLOR_MANAGER_V1_DESTROY, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), WL_MARSHAL_FLAG_DESTROY); } /** @@ -1076,7 +1076,7 @@ wp_color_manager_v1_get_output(struct wp_color_manager_v1 *wp_color_manager_v1, struct wl_proxy *id; id = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_manager_v1, - WP_COLOR_MANAGER_V1_GET_OUTPUT, &wp_color_management_output_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, NULL, output); + WP_COLOR_MANAGER_V1_GET_OUTPUT, &wp_color_management_output_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, nullptr, output); return (struct wp_color_management_output_v1 *) id; } @@ -1098,7 +1098,7 @@ wp_color_manager_v1_get_surface(struct wp_color_manager_v1 *wp_color_manager_v1, struct wl_proxy *id; id = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_manager_v1, - WP_COLOR_MANAGER_V1_GET_SURFACE, &wp_color_management_surface_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, NULL, surface); + WP_COLOR_MANAGER_V1_GET_SURFACE, &wp_color_management_surface_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, nullptr, surface); return (struct wp_color_management_surface_v1 *) id; } @@ -1118,7 +1118,7 @@ wp_color_manager_v1_get_surface_feedback(struct wp_color_manager_v1 *wp_color_ma struct wl_proxy *id; id = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_manager_v1, - WP_COLOR_MANAGER_V1_GET_SURFACE_FEEDBACK, &wp_color_management_surface_feedback_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, NULL, surface); + WP_COLOR_MANAGER_V1_GET_SURFACE_FEEDBACK, &wp_color_management_surface_feedback_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, nullptr, surface); return (struct wp_color_management_surface_feedback_v1 *) id; } @@ -1141,7 +1141,7 @@ wp_color_manager_v1_create_icc_creator(struct wp_color_manager_v1 *wp_color_mana struct wl_proxy *obj; obj = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_manager_v1, - WP_COLOR_MANAGER_V1_CREATE_ICC_CREATOR, &wp_image_description_creator_icc_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, NULL); + WP_COLOR_MANAGER_V1_CREATE_ICC_CREATOR, &wp_image_description_creator_icc_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, nullptr); return (struct wp_image_description_creator_icc_v1 *) obj; } @@ -1164,7 +1164,7 @@ wp_color_manager_v1_create_parametric_creator(struct wp_color_manager_v1 *wp_col struct wl_proxy *obj; obj = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_manager_v1, - WP_COLOR_MANAGER_V1_CREATE_PARAMETRIC_CREATOR, &wp_image_description_creator_params_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, NULL); + WP_COLOR_MANAGER_V1_CREATE_PARAMETRIC_CREATOR, &wp_image_description_creator_params_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, nullptr); return (struct wp_image_description_creator_params_v1 *) obj; } @@ -1223,7 +1223,7 @@ wp_color_manager_v1_create_windows_scrgb(struct wp_color_manager_v1 *wp_color_ma struct wl_proxy *image_description; image_description = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_manager_v1, - WP_COLOR_MANAGER_V1_CREATE_WINDOWS_SCRGB, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, NULL); + WP_COLOR_MANAGER_V1_CREATE_WINDOWS_SCRGB, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, nullptr); return (struct wp_image_description_v1 *) image_description; } @@ -1242,7 +1242,7 @@ wp_color_manager_v1_get_image_description(struct wp_color_manager_v1 *wp_color_m struct wl_proxy *image_description; image_description = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_manager_v1, - WP_COLOR_MANAGER_V1_GET_IMAGE_DESCRIPTION, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, NULL, reference); + WP_COLOR_MANAGER_V1_GET_IMAGE_DESCRIPTION, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_manager_v1), 0, nullptr, reference); return (struct wp_image_description_v1 *) image_description; } @@ -1325,7 +1325,7 @@ static inline void wp_color_management_output_v1_destroy(struct wp_color_management_output_v1 *wp_color_management_output_v1) { wl_proxy_marshal_flags((struct wl_proxy *) wp_color_management_output_v1, - WP_COLOR_MANAGEMENT_OUTPUT_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_color_management_output_v1), WL_MARSHAL_FLAG_DESTROY); + WP_COLOR_MANAGEMENT_OUTPUT_V1_DESTROY, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_color_management_output_v1), WL_MARSHAL_FLAG_DESTROY); } /** @@ -1369,7 +1369,7 @@ wp_color_management_output_v1_get_image_description(struct wp_color_management_o struct wl_proxy *image_description; image_description = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_management_output_v1, - WP_COLOR_MANAGEMENT_OUTPUT_V1_GET_IMAGE_DESCRIPTION, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_management_output_v1), 0, NULL); + WP_COLOR_MANAGEMENT_OUTPUT_V1_GET_IMAGE_DESCRIPTION, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_management_output_v1), 0, nullptr); return (struct wp_image_description_v1 *) image_description; } @@ -1444,7 +1444,7 @@ static inline void wp_color_management_surface_v1_destroy(struct wp_color_management_surface_v1 *wp_color_management_surface_v1) { wl_proxy_marshal_flags((struct wl_proxy *) wp_color_management_surface_v1, - WP_COLOR_MANAGEMENT_SURFACE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_v1), WL_MARSHAL_FLAG_DESTROY); + WP_COLOR_MANAGEMENT_SURFACE_V1_DESTROY, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_v1), WL_MARSHAL_FLAG_DESTROY); } /** @@ -1494,7 +1494,7 @@ static inline void wp_color_management_surface_v1_set_image_description(struct wp_color_management_surface_v1 *wp_color_management_surface_v1, struct wp_image_description_v1 *image_description, uint32_t render_intent) { wl_proxy_marshal_flags((struct wl_proxy *) wp_color_management_surface_v1, - WP_COLOR_MANAGEMENT_SURFACE_V1_SET_IMAGE_DESCRIPTION, NULL, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_v1), 0, image_description, render_intent); + WP_COLOR_MANAGEMENT_SURFACE_V1_SET_IMAGE_DESCRIPTION, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_v1), 0, image_description, render_intent); } /** @@ -1511,7 +1511,7 @@ static inline void wp_color_management_surface_v1_unset_image_description(struct wp_color_management_surface_v1 *wp_color_management_surface_v1) { wl_proxy_marshal_flags((struct wl_proxy *) wp_color_management_surface_v1, - WP_COLOR_MANAGEMENT_SURFACE_V1_UNSET_IMAGE_DESCRIPTION, NULL, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_v1), 0); + WP_COLOR_MANAGEMENT_SURFACE_V1_UNSET_IMAGE_DESCRIPTION, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_v1), 0); } #ifndef WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_ENUM @@ -1647,7 +1647,7 @@ static inline void wp_color_management_surface_feedback_v1_destroy(struct wp_color_management_surface_feedback_v1 *wp_color_management_surface_feedback_v1) { wl_proxy_marshal_flags((struct wl_proxy *) wp_color_management_surface_feedback_v1, - WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_feedback_v1), WL_MARSHAL_FLAG_DESTROY); + WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_DESTROY, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_feedback_v1), WL_MARSHAL_FLAG_DESTROY); } /** @@ -1693,7 +1693,7 @@ wp_color_management_surface_feedback_v1_get_preferred(struct wp_color_management struct wl_proxy *image_description; image_description = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_management_surface_feedback_v1, - WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_GET_PREFERRED, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_feedback_v1), 0, NULL); + WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_GET_PREFERRED, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_feedback_v1), 0, nullptr); return (struct wp_image_description_v1 *) image_description; } @@ -1714,7 +1714,7 @@ wp_color_management_surface_feedback_v1_get_preferred_parametric(struct wp_color struct wl_proxy *image_description; image_description = wl_proxy_marshal_flags((struct wl_proxy *) wp_color_management_surface_feedback_v1, - WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_GET_PREFERRED_PARAMETRIC, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_feedback_v1), 0, NULL); + WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_GET_PREFERRED_PARAMETRIC, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_color_management_surface_feedback_v1), 0, nullptr); return (struct wp_image_description_v1 *) image_description; } @@ -1818,7 +1818,7 @@ wp_image_description_creator_icc_v1_create(struct wp_image_description_creator_i struct wl_proxy *image_description; image_description = wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_icc_v1, - WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_CREATE, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_icc_v1), WL_MARSHAL_FLAG_DESTROY, NULL); + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_CREATE, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_icc_v1), WL_MARSHAL_FLAG_DESTROY, nullptr); return (struct wp_image_description_v1 *) image_description; } @@ -1870,7 +1870,7 @@ static inline void wp_image_description_creator_icc_v1_set_icc_file(struct wp_image_description_creator_icc_v1 *wp_image_description_creator_icc_v1, int32_t icc_profile, uint32_t offset, uint32_t length) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_icc_v1, - WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_SET_ICC_FILE, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_icc_v1), 0, icc_profile, offset, length); + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_SET_ICC_FILE, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_icc_v1), 0, icc_profile, offset, length); } #ifndef WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ENUM @@ -2027,7 +2027,7 @@ wp_image_description_creator_params_v1_create(struct wp_image_description_creato struct wl_proxy *image_description; image_description = wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_CREATE, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), WL_MARSHAL_FLAG_DESTROY, NULL); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_CREATE, &wp_image_description_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), WL_MARSHAL_FLAG_DESTROY, nullptr); return (struct wp_image_description_v1 *) image_description; } @@ -2052,7 +2052,7 @@ static inline void wp_image_description_creator_params_v1_set_tf_named(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, uint32_t tf) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_TF_NAMED, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, tf); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_TF_NAMED, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, tf); } /** @@ -2081,7 +2081,7 @@ static inline void wp_image_description_creator_params_v1_set_tf_power(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, uint32_t eexp) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_TF_POWER, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, eexp); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_TF_POWER, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, eexp); } /** @@ -2102,7 +2102,7 @@ static inline void wp_image_description_creator_params_v1_set_primaries_named(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, uint32_t primaries) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_PRIMARIES_NAMED, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, primaries); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_PRIMARIES_NAMED, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, primaries); } /** @@ -2126,7 +2126,7 @@ static inline void wp_image_description_creator_params_v1_set_primaries(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_PRIMARIES, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_PRIMARIES, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); } /** @@ -2186,7 +2186,7 @@ static inline void wp_image_description_creator_params_v1_set_luminances(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_LUMINANCES, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, min_lum, max_lum, reference_lum); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_LUMINANCES, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, min_lum, max_lum, reference_lum); } /** @@ -2243,7 +2243,7 @@ static inline void wp_image_description_creator_params_v1_set_mastering_display_primaries(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_MASTERING_DISPLAY_PRIMARIES, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_MASTERING_DISPLAY_PRIMARIES, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); } /** @@ -2287,7 +2287,7 @@ static inline void wp_image_description_creator_params_v1_set_mastering_luminance(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, uint32_t min_lum, uint32_t max_lum) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_MASTERING_LUMINANCE, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, min_lum, max_lum); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_MASTERING_LUMINANCE, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, min_lum, max_lum); } /** @@ -2301,7 +2301,7 @@ static inline void wp_image_description_creator_params_v1_set_max_cll(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, uint32_t max_cll) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_MAX_CLL, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, max_cll); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_MAX_CLL, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, max_cll); } /** @@ -2316,7 +2316,7 @@ static inline void wp_image_description_creator_params_v1_set_max_fall(struct wp_image_description_creator_params_v1 *wp_image_description_creator_params_v1, uint32_t max_fall) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_creator_params_v1, - WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_MAX_FALL, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, max_fall); + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_SET_MAX_FALL, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_creator_params_v1), 0, max_fall); } #ifndef WP_IMAGE_DESCRIPTION_V1_ERROR_ENUM @@ -2515,7 +2515,7 @@ static inline void wp_image_description_v1_destroy(struct wp_image_description_v1 *wp_image_description_v1) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_v1, - WP_IMAGE_DESCRIPTION_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_v1), WL_MARSHAL_FLAG_DESTROY); + WP_IMAGE_DESCRIPTION_V1_DESTROY, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_v1), WL_MARSHAL_FLAG_DESTROY); } /** @@ -2535,7 +2535,7 @@ wp_image_description_v1_get_information(struct wp_image_description_v1 *wp_image struct wl_proxy *information; information = wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_v1, - WP_IMAGE_DESCRIPTION_V1_GET_INFORMATION, &wp_image_description_info_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_image_description_v1), 0, NULL); + WP_IMAGE_DESCRIPTION_V1_GET_INFORMATION, &wp_image_description_info_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_image_description_v1), 0, nullptr); return (struct wp_image_description_info_v1 *) information; } @@ -2861,7 +2861,7 @@ static inline void wp_image_description_reference_v1_destroy(struct wp_image_description_reference_v1 *wp_image_description_reference_v1) { wl_proxy_marshal_flags((struct wl_proxy *) wp_image_description_reference_v1, - WP_IMAGE_DESCRIPTION_REFERENCE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_image_description_reference_v1), WL_MARSHAL_FLAG_DESTROY); + WP_IMAGE_DESCRIPTION_REFERENCE_V1_DESTROY, nullptr, wl_proxy_get_version((struct wl_proxy *) wp_image_description_reference_v1), WL_MARSHAL_FLAG_DESTROY); } #ifdef __cplusplus diff --git a/src/detection/displayserver/linux/wayland/wp-color-management-v1-protocol.c b/src/detection/displayserver/linux/wayland/wp-color-management-v1-protocol.c index fd2ce26bd..b57873782 100644 --- a/src/detection/displayserver/linux/wayland/wp-color-management-v1-protocol.c +++ b/src/detection/displayserver/linux/wayland/wp-color-management-v1-protocol.c @@ -47,14 +47,14 @@ extern const struct wl_interface wp_image_description_reference_v1_interface; extern const struct wl_interface wp_image_description_v1_interface; static const struct wl_interface *color_management_v1_types[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, &wp_color_management_output_v1_interface, &wl_output_interface, &wp_color_management_surface_v1_interface, @@ -68,7 +68,7 @@ static const struct wl_interface *color_management_v1_types[] = { &wp_image_description_reference_v1_interface, &wp_image_description_v1_interface, &wp_image_description_v1_interface, - NULL, + nullptr, &wp_image_description_v1_interface, &wp_image_description_v1_interface, &wp_image_description_v1_interface, @@ -125,7 +125,7 @@ static const struct wl_message wp_color_management_surface_v1_requests[] = { WL_EXPORT const struct wl_interface wp_color_management_surface_v1_interface = { "wp_color_management_surface_v1", 2, 3, wp_color_management_surface_v1_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wp_color_management_surface_feedback_v1_requests[] = { @@ -153,7 +153,7 @@ static const struct wl_message wp_image_description_creator_icc_v1_requests[] = WL_EXPORT const struct wl_interface wp_image_description_creator_icc_v1_interface = { "wp_image_description_creator_icc_v1", 2, 2, wp_image_description_creator_icc_v1_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wp_image_description_creator_params_v1_requests[] = { @@ -172,7 +172,7 @@ static const struct wl_message wp_image_description_creator_params_v1_requests[] WL_EXPORT const struct wl_interface wp_image_description_creator_params_v1_interface = { "wp_image_description_creator_params_v1", 2, 10, wp_image_description_creator_params_v1_requests, - 0, NULL, + 0, nullptr, }; static const struct wl_message wp_image_description_v1_requests[] = { @@ -208,7 +208,7 @@ static const struct wl_message wp_image_description_info_v1_events[] = { WL_EXPORT const struct wl_interface wp_image_description_info_v1_interface = { "wp_image_description_info_v1", 2, - 0, NULL, + 0, nullptr, 11, wp_image_description_info_v1_events, }; @@ -219,7 +219,7 @@ static const struct wl_message wp_image_description_reference_v1_requests[] = { WL_EXPORT const struct wl_interface wp_image_description_reference_v1_interface = { "wp_image_description_reference_v1", 1, 1, wp_image_description_reference_v1_requests, - 0, NULL, + 0, nullptr, }; #endif diff --git a/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-client-protocol.h b/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-client-protocol.h index 51784c6c1..2998d51a0 100644 --- a/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-client-protocol.h +++ b/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-client-protocol.h @@ -172,7 +172,7 @@ extern const struct wl_interface zxdg_output_v1_interface; // zxdg_output_manager_v1_destroy(struct zxdg_output_manager_v1 *zxdg_output_manager_v1) // { // wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_manager_v1, -// ZXDG_OUTPUT_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), WL_MARSHAL_FLAG_DESTROY); +// ZXDG_OUTPUT_MANAGER_V1_DESTROY, nullptr, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), WL_MARSHAL_FLAG_DESTROY); // } // /** @@ -186,7 +186,7 @@ extern const struct wl_interface zxdg_output_v1_interface; // struct wl_proxy *id; // id = wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_manager_v1, -// ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), 0, NULL, output); +// ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), 0, nullptr, output); // return (struct zxdg_output_v1 *) id; // } @@ -404,7 +404,7 @@ zxdg_output_v1_add_listener(struct zxdg_output_v1* zxdg_output_v1, // zxdg_output_v1_destroy(struct zxdg_output_v1 *zxdg_output_v1) // { // wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_v1, -// ZXDG_OUTPUT_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1), WL_MARSHAL_FLAG_DESTROY); +// ZXDG_OUTPUT_V1_DESTROY, nullptr, wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1), WL_MARSHAL_FLAG_DESTROY); // } #ifdef __cplusplus diff --git a/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c b/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c index fb1273e63..64367f1db 100644 --- a/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c +++ b/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c @@ -32,8 +32,8 @@ extern const struct wl_interface wl_output_interface; extern const struct wl_interface zxdg_output_v1_interface; static const struct wl_interface* xdg_output_unstable_v1_types[] = { - NULL, - NULL, + nullptr, + nullptr, &zxdg_output_v1_interface, &wl_output_interface, }; @@ -49,7 +49,7 @@ WL_EXPORT const struct wl_interface zxdg_output_manager_v1_interface = { 2, zxdg_output_manager_v1_requests, 0, - NULL, + nullptr, }; static const struct wl_message zxdg_output_v1_requests[] = { diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index f0321c8ad..8044c4a95 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -51,39 +51,39 @@ static const char* parseEnv(void) { return env; } - if (getenv("KDE_FULL_SESSION") != NULL || getenv("KDE_SESSION_UID") != NULL || getenv("KDE_SESSION_VERSION") != NULL) { + if (getenv("KDE_FULL_SESSION") != nullptr || getenv("KDE_SESSION_UID") != nullptr || getenv("KDE_SESSION_VERSION") != nullptr) { return "KDE"; } - if (getenv("GNOME_DESKTOP_SESSION_ID") != NULL) { + if (getenv("GNOME_DESKTOP_SESSION_ID") != nullptr) { return "GNOME"; } - if (getenv("MATE_DESKTOP_SESSION_ID") != NULL) { + if (getenv("MATE_DESKTOP_SESSION_ID") != nullptr) { return "Mate"; } - if (getenv("TDE_FULL_SESSION") != NULL) { + if (getenv("TDE_FULL_SESSION") != nullptr) { return "Trinity"; } - if (getenv("HYPRLAND_CMD") != NULL) { + if (getenv("HYPRLAND_CMD") != nullptr) { return "Hyprland"; } - if (getenv("SWAYSOCK") != NULL) { + if (getenv("SWAYSOCK") != nullptr) { return "Sway"; } #if __linux__ && !__ANDROID__ if ( - getenv("WAYLAND_DISPLAY") != NULL && + getenv("WAYLAND_DISPLAY") != nullptr && ffPathExists("/mnt/wslg/", FF_PATHTYPE_DIRECTORY)) { return "WSLg"; } #endif - return NULL; + return nullptr; } static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) { @@ -285,12 +285,12 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { int request[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId }; size_t length = 0; - if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) { - return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, NULL) failed"; + if (sysctl(request, ARRAY_SIZE(request), nullptr, &length, nullptr, 0) != 0) { + return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, nullptr) failed"; } FF_AUTO_FREE struct kinfo_proc* procs = (struct kinfo_proc*) malloc(length); - if (sysctl(request, ARRAY_SIZE(request), procs, &length, NULL, 0) != 0) { + if (sysctl(request, ARRAY_SIZE(request), procs, &length, nullptr, 0) != 0) { return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, procs) failed"; } @@ -310,7 +310,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { } } #elif __OpenBSD__ - kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); + kvm_t* kd = kvm_open(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr); int count = 0; const struct kinfo_proc* proc = kvm_getprocs(kd, KERN_PROC_UID, (int) userId, sizeof(*proc), &count); if (proc) { @@ -331,7 +331,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { kvm_close(kd); #elif __sun FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc"); - if (procdir == NULL) { + if (procdir == nullptr) { return "opendir(\"/proc\") failed"; } @@ -341,7 +341,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { uint32_t procPathLength = procPath.length; struct dirent* dirent; - while ((dirent = readdir(procdir)) != NULL) { + while ((dirent = readdir(procdir)) != nullptr) { if (!ffCharIsDigit(dirent->d_name[0])) { continue; } @@ -371,7 +371,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { } #elif __linux__ || __GNU__ FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc"); - if (procdir == NULL) { + if (procdir == nullptr) { return "opendir(\"/proc\") failed"; } @@ -384,7 +384,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { FF_STRBUF_AUTO_DESTROY processName = ffStrbufCreateA(256); // Some processes have large command lines (looking at you chrome) struct dirent* dirent; - while ((dirent = readdir(procdir)) != NULL) { + while ((dirent = readdir(procdir)) != nullptr) { // Match only folders starting with a number (the pid folders) if (dirent->d_type != DT_DIR || !ffCharIsDigit(dirent->d_name[0])) { continue; @@ -428,13 +428,13 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { int request[] = { CTL_KERN, KERN_PROC2, KERN_PROC_UID, (int) userId, sizeof(struct kinfo_proc2), INT_MAX }; size_t size = 0; - if (sysctl(request, ARRAY_SIZE(request), NULL, &size, NULL, 0) != 0) { - return "sysctl(KERN_PROC_UID, NULL) failed"; + if (sysctl(request, ARRAY_SIZE(request), nullptr, &size, nullptr, 0) != 0) { + return "sysctl(KERN_PROC_UID, nullptr) failed"; } FF_AUTO_FREE struct kinfo_proc2* procs = malloc(size); - if (sysctl(request, ARRAY_SIZE(request), procs, &size, NULL, 0) != 0) { + if (sysctl(request, ARRAY_SIZE(request), procs, &size, nullptr, 0) != 0) { return "sysctl(KERN_PROC_UID, procs) failed"; } @@ -453,7 +453,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { } #endif - return NULL; + return nullptr; } void ffdsDetectWMDE(FFDisplayServerResult* result) { diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 8ad663d17..f3c371137 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -55,20 +55,20 @@ typedef struct XcbRandrData { static void* xcbGetProperty(XcbRandrData* data, xcb_window_t window, const char* request) { xcb_intern_atom_cookie_t requestAtomCookie = data->ffxcb_intern_atom(data->connection, true, (uint16_t) strlen(request), request); - FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(data->connection, requestAtomCookie, NULL); - if (requestAtomReply == NULL) { - return NULL; + FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(data->connection, requestAtomCookie, nullptr); + if (requestAtomReply == nullptr) { + return nullptr; } xcb_get_property_cookie_t propertyCookie = data->ffxcb_get_property(data->connection, false, window, requestAtomReply->atom, XCB_ATOM_ANY, 0, 8 * 1024); - FF_AUTO_FREE xcb_get_property_reply_t* propertyReply = data->ffxcb_get_property_reply(data->connection, propertyCookie, NULL); - if (propertyReply == NULL) { - return NULL; + FF_AUTO_FREE xcb_get_property_reply_t* propertyReply = data->ffxcb_get_property_reply(data->connection, propertyCookie, nullptr); + if (propertyReply == nullptr) { + return nullptr; } int length = data->ffxcb_get_property_value_length(propertyReply); if (length <= 0) { - return NULL; + return nullptr; } // Why are xcb property strings not null terminated??? @@ -81,13 +81,13 @@ static void* xcbGetProperty(XcbRandrData* data, xcb_window_t window, const char* static xcb_randr_get_output_property_reply_t* xcbRandrGetProperty(XcbRandrData* data, xcb_randr_output_t output, const char* name) { xcb_intern_atom_cookie_t requestAtomCookie = data->ffxcb_intern_atom(data->connection, true, (uint16_t) strlen(name), name); - FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(data->connection, requestAtomCookie, NULL); + FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(data->connection, requestAtomCookie, nullptr); if (requestAtomReply) { xcb_randr_get_output_property_cookie_t outputPropertyCookie = data->ffxcb_randr_get_output_property(data->connection, output, requestAtomReply->atom, XCB_GET_PROPERTY_TYPE_ANY, 0, 100, false, false); - return data->ffxcb_randr_get_output_property_reply(data->connection, outputPropertyCookie, NULL); + return data->ffxcb_randr_get_output_property_reply(data->connection, outputPropertyCookie, nullptr); } - return NULL; + return nullptr; } static void xcbDetectWMfromEWMH(XcbRandrData* data, xcb_window_t rootWindow, FFDisplayServerResult* result) { @@ -96,7 +96,7 @@ static void xcbDetectWMfromEWMH(XcbRandrData* data, xcb_window_t rootWindow, FFD } FF_AUTO_FREE xcb_window_t* wmWindow = (xcb_window_t*) xcbGetProperty(data, rootWindow, "_NET_SUPPORTING_WM_CHECK"); - if (wmWindow == NULL) { + if (wmWindow == nullptr) { return; } @@ -131,13 +131,13 @@ static void xcbFetchServerVendor(XcbRandrData* data, FFDisplayServerResult* resu static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name, bool primary, FFDisplayType displayType, struct xcb_randr_get_screen_resources_current_reply_t* screenResources, uint8_t bitDepth, uint32_t dpi) { xcb_randr_get_output_info_cookie_t outputInfoCookie = data->ffxcb_randr_get_output_info(data->connection, output, XCB_CURRENT_TIME); - FF_AUTO_FREE xcb_randr_get_output_info_reply_t* outputInfoReply = data->ffxcb_randr_get_output_info_reply(data->connection, outputInfoCookie, NULL); - if (outputInfoReply == NULL) { + FF_AUTO_FREE xcb_randr_get_output_info_reply_t* outputInfoReply = data->ffxcb_randr_get_output_info_reply(data->connection, outputInfoCookie, nullptr); + if (outputInfoReply == nullptr) { return false; } FF_AUTO_FREE xcb_randr_get_output_property_reply_t* edidReply = xcbRandrGetProperty(data, output, "EDID"); - uint8_t* edidData = NULL; + uint8_t* edidData = nullptr; uint32_t edidLength = 0; if (edidReply) { int len = data->ffxcb_randr_get_output_property_data_length(edidReply); @@ -162,8 +162,8 @@ static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, } xcb_randr_get_crtc_info_cookie_t crtcInfoCookie = data->ffxcb_randr_get_crtc_info(data->connection, outputInfoReply->crtc, XCB_CURRENT_TIME); - FF_AUTO_FREE xcb_randr_get_crtc_info_reply_t* crtcInfoReply = data->ffxcb_randr_get_crtc_info_reply(data->connection, crtcInfoCookie, NULL); - if (crtcInfoReply == NULL) { + FF_AUTO_FREE xcb_randr_get_crtc_info_reply_t* crtcInfoReply = data->ffxcb_randr_get_crtc_info_reply(data->connection, crtcInfoCookie, nullptr); + if (crtcInfoReply == nullptr) { return false; } @@ -183,8 +183,8 @@ static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, break; } - xcb_randr_mode_info_t* currentMode = NULL; - xcb_randr_mode_info_t* preferredMode = NULL; + xcb_randr_mode_info_t* currentMode = nullptr; + xcb_randr_mode_info_t* preferredMode = nullptr; if (screenResources) { xcb_randr_mode_info_iterator_t modesIterator = data->ffxcb_randr_get_screen_resources_current_modes_iterator(screenResources); @@ -253,7 +253,7 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* FF_AUTO_FREE xcb_get_atom_name_reply_t* nameReply = data->ffxcb_get_atom_name_reply( data->connection, data->ffxcb_get_atom_name(data->connection, monitor->name), - NULL); + nullptr); FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateNS( (uint32_t) data->ffxcb_get_atom_name_name_length(nameReply), data->ffxcb_get_atom_name_name(nameReply)); @@ -297,14 +297,14 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* static bool xcbRandrHandleMonitors(XcbRandrData* data, xcb_screen_t* screen) { xcb_randr_get_monitors_cookie_t monitorsCookie = data->ffxcb_randr_get_monitors(data->connection, screen->root, true); - FF_AUTO_FREE xcb_randr_get_monitors_reply_t* monitorsReply = data->ffxcb_randr_get_monitors_reply(data->connection, monitorsCookie, NULL); - if (monitorsReply == NULL) { + FF_AUTO_FREE xcb_randr_get_monitors_reply_t* monitorsReply = data->ffxcb_randr_get_monitors_reply(data->connection, monitorsCookie, nullptr); + if (monitorsReply == nullptr) { return false; } - // Init screen resources. They are used to iterate over all modes. xcbRandrHandleMode checks for " == NULL", to fail as late as possible. + // Init screen resources. They are used to iterate over all modes. xcbRandrHandleMode checks for " == nullptr", to fail as late as possible. xcb_randr_get_screen_resources_current_cookie_t screenResourcesCookie = data->ffxcb_randr_get_screen_resources_current(data->connection, screen->root); - FF_AUTO_FREE struct xcb_randr_get_screen_resources_current_reply_t* screenResources = data->ffxcb_randr_get_screen_resources_current_reply(data->connection, screenResourcesCookie, NULL); + FF_AUTO_FREE struct xcb_randr_get_screen_resources_current_reply_t* screenResources = data->ffxcb_randr_get_screen_resources_current_reply(data->connection, screenResourcesCookie, nullptr); uint32_t dpi = 0; FF_AUTO_FREE const char* resourceManager = xcbGetProperty(data, screen->root, "RESOURCE_MANAGER"); @@ -347,7 +347,7 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) { 0, 0, 0, - NULL, + nullptr, FF_DISPLAY_TYPE_UNKNOWN, false, (uint64_t) screen->root, @@ -401,7 +401,7 @@ const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) { FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_crtc_info) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_crtc_info_reply) - data.connection = ffxcb_connect(NULL, NULL); + data.connection = ffxcb_connect(nullptr, nullptr); if (ffxcb_connection_has_error(data.connection) > 0) { ffxcb_disconnect(data.connection); return "xcb_connect() failed"; @@ -428,7 +428,7 @@ const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) { ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11); } - return NULL; + return nullptr; } #else diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 642a0d2f2..00ec05e40 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -34,15 +34,15 @@ typedef struct XrandrData { static unsigned char* x11GetProperty(XrandrData* data, Display* display, Window window, const char* request) { Atom requestAtom = data->ffXInternAtom(display, request, False); if (requestAtom == None) { - return NULL; + return nullptr; } Atom actualType; unsigned long unused; - unsigned char* result = NULL; + unsigned char* result = nullptr; if (data->ffXGetWindowProperty(display, window, requestAtom, 0, 64, False, AnyPropertyType, &actualType, (int*) &unused, &unused, &unused, &result) != Success) { - return NULL; + return nullptr; } return result; @@ -50,7 +50,7 @@ static unsigned char* x11GetProperty(XrandrData* data, Display* display, Window static uint8_t* xrandrGetProperty(XrandrData* data, RROutput output, const char* name, uint32_t* bufSize) { unsigned long size = 0; - uint8_t* result = NULL; + uint8_t* result = nullptr; Atom atomEdid = data->ffXInternAtom(data->display, name, true); if (atomEdid != None) { int actual_format = 0; @@ -68,7 +68,7 @@ static uint8_t* xrandrGetProperty(XrandrData* data, RROutput output, const char* } } - return NULL; + return nullptr; } static void x11DetectWMFromEWMH(XrandrData* data, FFDisplayServerResult* result) { @@ -77,7 +77,7 @@ static void x11DetectWMFromEWMH(XrandrData* data, FFDisplayServerResult* result) } Window* wmWindow = (Window*) x11GetProperty(data, data->display, DefaultRootWindow(data->display), "_NET_SUPPORTING_WM_CHECK"); - if (wmWindow == NULL) { + if (wmWindow == nullptr) { return; } @@ -103,12 +103,12 @@ static void x11FetchServerVendor(XrandrData* data, FFDisplayServerResult* result static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf* name, bool primary, FFDisplayType displayType, uint8_t* edidData, uint32_t edidLength, XRRScreenResources* screenResources, uint8_t bitDepth, uint32_t dpi, bool randrEmulation) { // We do the check here, because we want the best fallback display if this call failed - if (screenResources == NULL) { + if (screenResources == nullptr) { return false; } XRRCrtcInfo* crtcInfo = data->ffXRRGetCrtcInfo(data->display, screenResources, output->crtc); - if (crtcInfo == NULL) { + if (crtcInfo == nullptr) { return false; } @@ -128,7 +128,7 @@ static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf* break; } - XRRModeInfo* currentMode = NULL; + XRRModeInfo* currentMode = nullptr; for (int i = 0; i < screenResources->nmode; i++) { if (screenResources->modes[i].id == crtcInfo->mode) { currentMode = &screenResources->modes[i]; @@ -136,7 +136,7 @@ static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf* } } - XRRModeInfo* preferredMode = output->npreferred > 0 ? &screenResources->modes[0] : NULL; + XRRModeInfo* preferredMode = output->npreferred > 0 ? &screenResources->modes[0] : nullptr; FFDisplayResult* item = ffdsAppendDisplay( data->result, @@ -179,7 +179,7 @@ static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf* static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name, bool primary, FFDisplayType displayType, XRRScreenResources* screenResources, uint8_t bitDepth, uint32_t dpi) { XRROutputInfo* outputInfo = data->ffXRRGetOutputInfo(data->display, screenResources, output); - if (outputInfo == NULL) { + if (outputInfo == nullptr) { return false; } @@ -193,7 +193,7 @@ static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name edidLength = 0; } - uint8_t* randrEmulation = xrandrGetProperty(data, output, "RANDR Emulation", NULL); + uint8_t* randrEmulation = xrandrGetProperty(data, output, "RANDR Emulation", nullptr); bool res = xrandrHandleCrtc(data, outputInfo, name, primary, displayType, edidData, edidLength, screenResources, bitDepth, dpi, randrEmulation ? !!randrEmulation[0] : false); @@ -250,7 +250,7 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo, X static bool xrandrHandleMonitors(XrandrData* data, Screen* screen) { int numberOfMonitors; XRRMonitorInfo* monitorInfos = data->ffXRRGetMonitors(data->display, RootWindowOfScreen(screen), True, &numberOfMonitors); - if (monitorInfos == NULL) { + if (monitorInfos == nullptr) { return false; } @@ -297,7 +297,7 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) { 0, 0, 0, - NULL, + nullptr, FF_DISPLAY_TYPE_UNKNOWN, false, RootWindowOfScreen(screen), @@ -329,8 +329,8 @@ const char* ffdsConnectXrandr(FFDisplayServerResult* result) { FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeScreenResources); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeMonitors); - data.display = ffXOpenDisplay(NULL); - if (data.display == NULL) { + data.display = ffXOpenDisplay(nullptr); + if (data.display == nullptr) { return "XOpenDisplay() failed"; } @@ -352,7 +352,7 @@ const char* ffdsConnectXrandr(FFDisplayServerResult* result) { ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11); } - return NULL; + return nullptr; } #else diff --git a/src/detection/dns/dns_apple.c b/src/detection/dns/dns_apple.c index e490ffe74..e04bb5256 100644 --- a/src/detection/dns/dns_apple.c +++ b/src/detection/dns/dns_apple.c @@ -25,7 +25,7 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF ffListClear(results); } - FF_AUTO_FREE char* line = NULL; + FF_AUTO_FREE char* line = nullptr; size_t len = 0; while (getline(&line, &len, file) != -1) { @@ -56,7 +56,7 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF } FF_DEBUG("Found %u DNS servers in %s", results->length, path); - return NULL; + return nullptr; } const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { @@ -64,10 +64,10 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { FF_DEBUG("Using SystemConfiguration framework for macOS"); // Create a reference to the dynamic store - FF_CFTYPE_AUTO_RELEASE SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("fastfetch"), NULL, NULL); + FF_CFTYPE_AUTO_RELEASE SCDynamicStoreRef store = SCDynamicStoreCreate(nullptr, CFSTR("fastfetch"), nullptr, nullptr); if (store) { // Get the network global IPv4 and IPv6 configuration - FF_CFTYPE_AUTO_RELEASE CFStringRef key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, kSCEntNetDNS); + FF_CFTYPE_AUTO_RELEASE CFStringRef key = SCDynamicStoreKeyCreateNetworkGlobalEntity(nullptr, kSCDynamicStoreDomainState, kSCEntNetDNS); if (key) { FF_CFTYPE_AUTO_RELEASE CFDictionaryRef dict = SCDynamicStoreCopyValue(store, key); if (dict) { @@ -77,7 +77,7 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { if (dnsServers) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); for (CFIndex i = 0; i < CFArrayGetCount(dnsServers); i++) { - if (ffCfStrGetString(CFArrayGetValueAtIndex(dnsServers, i), &buffer) == NULL) { + if (ffCfStrGetString(CFArrayGetValueAtIndex(dnsServers, i), &buffer) == nullptr) { // Check if the address matches our filter if ((ffStrbufContainC(&buffer, ':') && !(options->showType & FF_DNS_TYPE_IPV6_BIT)) || (ffStrbufContainC(&buffer, '.') && !(options->showType & FF_DNS_TYPE_IPV4_BIT))) { @@ -97,7 +97,7 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { // If we didn't find any servers, try resolv.conf as fallback if (results->length > 0) { - return NULL; + return nullptr; } FF_DEBUG("No DNS servers found via SystemConfiguration, trying resolv.conf"); diff --git a/src/detection/dns/dns_linux.c b/src/detection/dns/dns_linux.c index 41e008cc2..a92057575 100644 --- a/src/detection/dns/dns_linux.c +++ b/src/detection/dns/dns_linux.c @@ -28,7 +28,7 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF ffListClear(results); } - FF_AUTO_FREE char* line = NULL; + FF_AUTO_FREE char* line = nullptr; size_t len = 0; while (getline(&line, &len, file) != -1) { @@ -59,14 +59,14 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF } FF_DEBUG("Found %u DNS servers in %s", results->length, path); - return NULL; + return nullptr; } const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { FF_DEBUG("Starting DNS detection"); const char* error = detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT RESOLV_CONF, options, results); - if (error != NULL) { + if (error != nullptr) { FF_DEBUG("Error detecting DNS: %s", error); return error; } @@ -79,14 +79,14 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { if (ffStrbufEqualS(firstEntry, "127.0.0.53")) { FF_DEBUG("Detected systemd-resolved (127.0.0.53), checking actual DNS servers"); // Managed by systemd-resolved - if (detectDnsFromConf("/run/systemd/resolve/resolv.conf", options, results) == NULL) { - return NULL; + if (detectDnsFromConf("/run/systemd/resolve/resolv.conf", options, results) == nullptr) { + return nullptr; } } else if (ffStrbufEqualS(firstEntry, "127.0.0.1")) { FF_DEBUG("Detected possible NetworkManager (127.0.0.1), checking actual DNS servers"); // Managed by NetworkManager - if (detectDnsFromConf("/var/run/NetworkManager/resolv.conf", options, results) == NULL) { - return NULL; + if (detectDnsFromConf("/var/run/NetworkManager/resolv.conf", options, results) == nullptr) { + return nullptr; } } } @@ -97,20 +97,20 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { // Try resolvconf FF_DEBUG("Trying resolvconf configuration"); - if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/run/resolvconf/resolv.conf", options, results) == NULL && results->length > 0) { - return NULL; + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/run/resolvconf/resolv.conf", options, results) == nullptr && results->length > 0) { + return nullptr; } // Try dnsmasq FF_DEBUG("Trying dnsmasq configuration"); - if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/dnsmasq/resolv.conf", options, results) == NULL && results->length > 0) { - return NULL; + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/dnsmasq/resolv.conf", options, results) == nullptr && results->length > 0) { + return nullptr; } // Try openresolv FF_DEBUG("Trying openresolv configuration"); - if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/resolv.conf.openresolv", options, results) == NULL && results->length > 0) { - return NULL; + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/resolv.conf.openresolv", options, results) == nullptr && results->length > 0) { + return nullptr; } } #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) @@ -120,24 +120,24 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { // FreeBSD and other BSDs may use resolvconf service FF_DEBUG("Trying BSD resolvconf configuration"); - if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/resolvconf/resolv.conf", options, results) == NULL && results->length > 0) { - return NULL; + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/resolvconf/resolv.conf", options, results) == nullptr && results->length > 0) { + return nullptr; } // Some BSDs store DNS configuration here FF_DEBUG("Trying BSD nameserver configuration"); - if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/nameserver", options, results) == NULL && results->length > 0) { - return NULL; + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/nameserver", options, results) == nullptr && results->length > 0) { + return nullptr; } // Try common BSD paths FF_DEBUG("Trying BSD common paths"); - if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/nameserver", options, results) == NULL && results->length > 0) { - return NULL; + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/nameserver", options, results) == nullptr && results->length > 0) { + return nullptr; } } #endif FF_DEBUG("DNS detection completed with %u servers found", results->length); - return NULL; + return nullptr; } diff --git a/src/detection/dns/dns_windows.c b/src/detection/dns/dns_windows.c index b28eefb9e..5d2ab5534 100644 --- a/src/detection/dns/dns_windows.c +++ b/src/detection/dns/dns_windows.c @@ -6,7 +6,7 @@ #include const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { - IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = NULL; + IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = nullptr; // Multiple attempts in case interfaces change while // we are in the middle of querying them. @@ -22,7 +22,7 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { ? options->showType & FF_DNS_TYPE_IPV6_BIT ? AF_UNSPEC : AF_INET : AF_INET6, GAA_FLAG_SKIP_UNICAST | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_FRIENDLY_NAME, - NULL, + nullptr, adapter_addresses, &adapter_addresses_buffer_size); @@ -59,5 +59,5 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { } break; } - return NULL; + return nullptr; } diff --git a/src/detection/editor/editor.c b/src/detection/editor/editor.c index b84f279bb..6d4974686 100644 --- a/src/detection/editor/editor.c +++ b/src/detection/editor/editor.c @@ -50,14 +50,14 @@ const char* ffDetectEditor(FFEditorResult* result) { } else { const char* error = ffFindExecutableInPath(result->name.chars, &result->path); if (error) { - return NULL; + return nullptr; } } { char buf[PATH_MAX + 1]; if (!realpath(result->path.chars, buf)) { - return NULL; + return nullptr; } // WIN32: Should we handle scoop shim exe here? @@ -77,11 +77,11 @@ const char* ffDetectEditor(FFEditorResult* result) { #endif ); if (index == result->path.length) { - return NULL; + return nullptr; } ffStrbufSetS(&result->exe, &result->path.chars[index + 1]); if (!result->exe.length) { - return NULL; + return nullptr; } #ifdef _WIN32 @@ -92,7 +92,7 @@ const char* ffDetectEditor(FFEditorResult* result) { } if (!instance.config.general.detectVersion) { - return NULL; + return nullptr; } if (ffStrbufEqualS(&result->exe, "nvim")) { @@ -104,10 +104,10 @@ const char* ffDetectEditor(FFEditorResult* result) { } if (result->version.length > 0) { - return NULL; + return nullptr; } - const char* param = NULL; + const char* param = nullptr; if ( ffStrbufEqualS(&result->exe, "nano") || ffStrbufEqualS(&result->exe, "vim") || @@ -130,24 +130,24 @@ const char* ffDetectEditor(FFEditorResult* result) { ffStrbufEqualS(&result->exe, "ne")) { param = "-h"; } else { - return NULL; + return nullptr; } ffProcessAppendStdOut(&result->version, (char* const[]) { result->path.chars, (char*) param, - NULL, + nullptr, }); if (result->version.length == 0) { - return NULL; + return nullptr; } ffStrbufSubstrBeforeFirstC(&result->version, '\n'); const char* versionStart = strpbrk(result->version.chars, "0123456789"); - if (versionStart != NULL) { + if (versionStart != nullptr) { const char* versionEnd = strpbrk(versionStart, " \t\v\f\r"); - if (versionEnd != NULL) { + if (versionEnd != nullptr) { ffStrbufSubstrBefore(&result->version, (uint32_t) (versionEnd - result->version.chars)); } @@ -156,5 +156,5 @@ const char* ffDetectEditor(FFEditorResult* result) { } } - return NULL; + return nullptr; } diff --git a/src/detection/font/font.c b/src/detection/font/font.c index c651f29bd..4c223224c 100644 --- a/src/detection/font/font.c +++ b/src/detection/font/font.c @@ -11,7 +11,7 @@ const char* ffDetectFont(FFFontResult* font) { for (uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i) { if (font->fonts[i].length > 0) { - return NULL; + return nullptr; } } diff --git a/src/detection/font/font_apple.m b/src/detection/font/font_apple.m index e8aff3c5f..ba92981c7 100644 --- a/src/detection/font/font_apple.m +++ b/src/detection/font/font_apple.m @@ -33,5 +33,5 @@ const char* ffDetectFontImpl(FFFontResult* result) ffStrbufAppendS(&result->fonts[3], [NSFont userFixedPitchFontOfSize:12].familyName.UTF8String); generateString(result); - return NULL; + return nullptr; } diff --git a/src/detection/font/font_haiku.cpp b/src/detection/font/font_haiku.cpp index dc29dd004..b00b9d6f6 100644 --- a/src/detection/font/font_haiku.cpp +++ b/src/detection/font/font_haiku.cpp @@ -32,23 +32,23 @@ const char* ffDetectFontImpl(FFFontResult* result) { // We need a valid be_app to query the app_server here. BApplication app("application/x-vnd.fastfetch-cli-fastfetch"); - if ((f = be_plain_font) != NULL) { + if ((f = be_plain_font) != nullptr) { f->GetFamilyAndStyle(&menuInfo.f_family, &menuInfo.f_style); ffStrbufAppendF(&result->fonts[0], "%s %s (%dpt)", menuInfo.f_family, menuInfo.f_style, (int) f->Size()); } if (get_menu_info(&menuInfo) == B_OK) { ffStrbufAppendF(&result->fonts[1], "%s %s (%dpt)", menuInfo.f_family, menuInfo.f_style, (int) menuInfo.font_size); } - if ((f = be_bold_font) != NULL) { + if ((f = be_bold_font) != nullptr) { f->GetFamilyAndStyle(&menuInfo.f_family, &menuInfo.f_style); ffStrbufAppendF(&result->fonts[2], "%s %s (%dpt)", menuInfo.f_family, menuInfo.f_style, (int) f->Size()); } - if ((f = be_fixed_font) != NULL) { + if ((f = be_fixed_font) != nullptr) { f->GetFamilyAndStyle(&menuInfo.f_family, &menuInfo.f_style); ffStrbufAppendF(&result->fonts[3], "%s %s (%dpt)", menuInfo.f_family, menuInfo.f_style, (int) f->Size()); } generateString(result); - return NULL; + return nullptr; } diff --git a/src/detection/font/font_linux.c b/src/detection/font/font_linux.c index 5e82b682c..29f95e2a7 100644 --- a/src/detection/font/font_linux.c +++ b/src/detection/font/font_linux.c @@ -49,5 +49,5 @@ const char* ffDetectFontImpl(FFFontResult* result) { generateString(result); - return NULL; + return nullptr; } diff --git a/src/detection/font/font_windows.c b/src/detection/font/font_windows.c index 4fc28d320..960a75abd 100644 --- a/src/detection/font/font_windows.c +++ b/src/detection/font/font_windows.c @@ -21,8 +21,8 @@ static void generateString(FFFontResult* font) { } const char* ffDetectFontImpl(FFFontResult* result) { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics", &hKey, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics", &hKey, nullptr)) { return "ffRegOpenKeyForRead(HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics) failed"; } @@ -40,7 +40,7 @@ const char* ffDetectFontImpl(FFFontResult* result) { FF_ARG(fontBuffers[2], L"MessageFont"), FF_ARG(fontBuffers[3], L"StatusFont"), }, - NULL)) { + nullptr)) { return "ffRegReadValues(HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics) failed"; } @@ -59,5 +59,5 @@ const char* ffDetectFontImpl(FFFontResult* result) { generateString(result); - return NULL; + return nullptr; } diff --git a/src/detection/gamepad/gamepad_apple.c b/src/detection/gamepad/gamepad_apple.c index c262c8668..fa927c306 100644 --- a/src/detection/gamepad/gamepad_apple.c +++ b/src/detection/gamepad/gamepad_apple.c @@ -44,5 +44,5 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { } IOHIDManagerClose(manager, kIOHIDOptionsTypeNone); - return NULL; + return nullptr; } diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index b67b8fd2d..475bd061f 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -61,5 +61,5 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { hid_dispose_report_desc(repDesc); } - return NULL; + return nullptr; } diff --git a/src/detection/gamepad/gamepad_haiku.cpp b/src/detection/gamepad/gamepad_haiku.cpp index 50b43a043..ae601064c 100644 --- a/src/detection/gamepad/gamepad_haiku.cpp +++ b/src/detection/gamepad/gamepad_haiku.cpp @@ -14,5 +14,5 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { device->battery = 0; } } - return NULL; + return nullptr; } diff --git a/src/detection/gamepad/gamepad_linux.c b/src/detection/gamepad/gamepad_linux.c index 6bb4ee214..2c2e10587 100644 --- a/src/detection/gamepad/gamepad_linux.c +++ b/src/detection/gamepad/gamepad_linux.c @@ -20,7 +20,7 @@ static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir(path->chars); if (dirp) { struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.' || (entry->d_type != DT_DIR && entry->d_type != DT_UNKNOWN)) { continue; } @@ -31,7 +31,7 @@ static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path) { if (nRead > 0) // Tested with a PS4 controller { capacity[nRead] = '\0'; - device->battery = (uint8_t) strtoul(capacity, NULL, 10); + device->battery = (uint8_t) strtoul(capacity, nullptr, 10); break; } @@ -64,15 +64,15 @@ static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path) { const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/input/"); - if (dirp == NULL) { - return "opendir(\"/sys/class/input/\") == NULL"; + if (dirp == nullptr) { + return "opendir(\"/sys/class/input/\") == nullptr"; } FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/class/input/"); uint32_t baseLen = path.length; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (!ffStrStartsWith(entry->d_name, "js")) { continue; } @@ -93,5 +93,5 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { ffStrbufSubstrBefore(&path, baseLen); } - return NULL; + return nullptr; } diff --git a/src/detection/gamepad/gamepad_windows.c b/src/detection/gamepad/gamepad_windows.c index 9cbb5618e..34199c569 100644 --- a/src/detection/gamepad/gamepad_windows.c +++ b/src/detection/gamepad/gamepad_windows.c @@ -23,7 +23,7 @@ static const char* detectKnownDeviceName(uint32_t vendorId, uint32_t productId) return "Nintendo Switch SNES Controller"; default: - return NULL; + return nullptr; } } @@ -46,7 +46,7 @@ static const char* detectKnownDeviceName(uint32_t vendorId, uint32_t productId) return "Sony DualSense Edge"; default: - return NULL; + return nullptr; } } @@ -67,20 +67,20 @@ static const char* detectKnownDeviceName(uint32_t vendorId, uint32_t productId) return "Logitech F710"; default: - return NULL; + return nullptr; } } case 0x045E: // Microsoft Xbox compatible controllers should be handled by Windows without problems default: - return NULL; + return nullptr; } } const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { UINT nDevices = 0; - if (GetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST))) { - return "GetRawInputDeviceList(NULL) failed"; + if (GetRawInputDeviceList(nullptr, &nDevices, sizeof(RAWINPUTDEVICELIST))) { + return "GetRawInputDeviceList(nullptr) failed"; } if (nDevices == 0) { return "No HID devices found"; @@ -122,7 +122,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { if (knownGamepad) { ffStrbufSetS(&device->name, knownGamepad); } - HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr); if (hHidFile == INVALID_HANDLE_VALUE) { if (!knownGamepad) { ffStrbufSetF(&device->name, "Unknown gamepad %04X-%04X", (unsigned) rdi.hid.dwVendorId, (unsigned) rdi.hid.dwProductId); @@ -150,7 +150,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { ffStrbufSetWS(&device->serial, serialNumber); } - PHIDP_PREPARSED_DATA preparsedData = NULL; + PHIDP_PREPARSED_DATA preparsedData = nullptr; if (HidD_GetPreparsedData(hHidFile, &preparsedData)) { HIDP_CAPS caps; NTSTATUS capsResult = HidP_GetCaps(preparsedData, &caps); @@ -197,5 +197,5 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { } } - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index 7400652ad..2a74a54b2 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -73,7 +73,7 @@ const char* ffGPUGetVendorString(unsigned vendorId) { case 0x1234: // https://admin.pci-ids.ucw.cz/read/PC/1234 return FF_GPU_VENDOR_NAME_QEMU; default: - return NULL; + return nullptr; } } @@ -202,7 +202,7 @@ const char* detectByEglext(FFlist* result) { const char* name = ffeglQueryDeviceStringEXT(device, EGL_RENDERER_EXT); if (!name) { - FF_DEBUG("eglQueryDeviceStringEXT() returned NULL name for device %d, skipping", i); + FF_DEBUG("eglQueryDeviceStringEXT() returned nullptr name for device %d, skipping", i); continue; } @@ -222,7 +222,7 @@ const char* detectByEglext(FFlist* result) { gpu->frequency = FF_GPU_FREQUENCY_UNSET; gpu->pcieSpeed = FF_GPU_PCIE_SPEED_UNSET; - ffeglQueryDeviceBinaryEXT(device, EGL_DEVICE_UUID_EXT, sizeof(gpu->deviceId), &gpu->deviceId, NULL); + ffeglQueryDeviceBinaryEXT(device, EGL_DEVICE_UUID_EXT, sizeof(gpu->deviceId), &gpu->deviceId, nullptr); if (!normalizeVendorName(gpu)) { ffStrbufSetS(&gpu->vendor, ffeglQueryDeviceStringEXT(device, EGL_VENDOR)); @@ -234,7 +234,7 @@ const char* detectByEglext(FFlist* result) { FF_DEBUG("eglQueryDevicesEXT() returned EGL_FALSE"); } - return NULL; + return nullptr; } #endif @@ -249,7 +249,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { const char* error = ffDetectGPUImpl(options, result); if (!error && result->length > 0) { FF_DEBUG("PCI/native GPU detection succeeded with %u GPU(s)", result->length); - return NULL; + return nullptr; } FF_DEBUG("PCI/native GPU detection did not produce results (error=%s, gpuCount=%u)", @@ -272,7 +272,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { } #endif - return NULL; + return nullptr; } FF_DEBUG("Vulkan detection did not produce results (error=%s, gpuCount=%u)", @@ -286,7 +286,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { FF_DEBUG("OpenCL detection succeeded with %u GPU(s)", opencl->gpus.length); ffListDestroy(result); ffListInitMove(result, &opencl->gpus); - return NULL; + return nullptr; } FF_DEBUG("OpenCL detection did not produce results (error=%s, gpuCount=%u)", @@ -299,7 +299,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { const char* error = detectByEglext(result); if (!error && result->length > 0) { FF_DEBUG("EGL_EXT GPU detection succeeded with %u GPU(s)", result->length); - return NULL; + return nullptr; } FF_DEBUG("EGL_EXT GPU detection did not produce results (error=%s, gpuCount=%u)", @@ -312,9 +312,9 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_OPENGL) { FF_DEBUG("Trying OpenGL GPU detection fallback"); const char* error = detectByOpenGL(result); - if (error == NULL) { + if (error == nullptr) { FF_DEBUG("OpenGL fallback succeeded with %u GPU(s)", result->length); - return NULL; + return nullptr; } FF_DEBUG("OpenGL fallback failed: %s", error); diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 32b6ff636..546de0749 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -64,8 +64,8 @@ typedef struct FFGPUResult { uint64_t deviceId; } FFGPUResult; -static_assert(sizeof(((FFGPUResult*) NULL)->pcieSpeed) == 8, "pcieSpeed is not 8 bytes"); -static_assert(sizeof(((FFGPUResult*) NULL)->psMax) == 4, "psMax has padding"); +static_assert(sizeof(((FFGPUResult*) nullptr)->pcieSpeed) == 8, "pcieSpeed is not 8 bytes"); +static_assert(sizeof(((FFGPUResult*) nullptr)->psMax) == 4, "psMax has padding"); const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result); const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus); diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index 4a8134cf8..8569ee03f 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -72,7 +72,7 @@ static void shutdownAdl() { if (adlData.apiHandle) { FF_DEBUG("Destroying ADL context"); adlData.ffADL2_Main_Control_Destroy(adlData.apiHandle); - adlData.apiHandle = NULL; + adlData.apiHandle = nullptr; } } @@ -110,7 +110,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu } atexit(shutdownAdl); - atiadl = NULL; // don't close atiadl + atiadl = nullptr; // don't close atiadl FF_DEBUG("ADL initialization complete"); } @@ -119,7 +119,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu return "ffADL2_Main_Control_Create() failed"; } - FF_AUTO_FREE AdapterInfo* devices = NULL; + FF_AUTO_FREE AdapterInfo* devices = nullptr; int numDevices = 0; int adapterResult = adlData.ffADL2_Adapter_AdapterInfoX3_Get(adlData.apiHandle, -1, &numDevices, &devices); FF_DEBUG("ADL2_Adapter_AdapterInfoX3_Get returned %s (%d)", ffAdlStatusToString(adapterResult), adapterResult); @@ -131,7 +131,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu return "ffADL2_Adapter_AdapterInfoX3_Get() failed"; } - const AdapterInfo* device = NULL; + const AdapterInfo* device = nullptr; for (int iDev = 0; iDev < numDevices; iDev++) { if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID) { FF_DEBUG("Checking device %d: bus=%d, device=%d, func=%d against requested bus=%u, device=%u, func=%u", @@ -492,5 +492,5 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu return "Unknown Overdrive version"; } FF_DEBUG("AMD GPU detection complete - returning success"); - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu_android.c b/src/detection/gpu/gpu_android.c index 08fd48af2..f25756b4c 100644 --- a/src/detection/gpu/gpu_android.c +++ b/src/detection/gpu/gpu_android.c @@ -27,7 +27,7 @@ double ffGPUDetectTempFromTZ(void) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); int dfd = dirfd(dirp); struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index fc9fd457d..494225298 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -9,10 +9,10 @@ const char* ffGpuDetectDriverVersion(FFlist* gpus); static double detectGpuTemp(const FFstrbuf* gpuName) { double result = 0; - const char* error = NULL; + const char* error = nullptr; if (ffStrbufStartsWithS(gpuName, "Apple M")) { - switch (strtol(gpuName->chars + strlen("Apple M"), NULL, 10)) { + switch (strtol(gpuName->chars + strlen("Apple M"), nullptr, 10)) { case 0: error = "Invalid Apple Silicon GPU"; break; @@ -88,7 +88,7 @@ static const char* detectFrequency(FFGPUResult* gpu) { } } - return NULL; + return nullptr; } #endif @@ -123,27 +123,27 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { ffStrbufInit(&gpu->driver); // Ok for both Apple and Intel ffCfDictGetString(properties, CFSTR("CFBundleIdentifier"), &gpu->driver); - if (ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount) != NULL) { // For Apple + if (ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount) != nullptr) { // For Apple gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; } gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; - CFDictionaryRef perfStatistics = NULL; + CFDictionaryRef perfStatistics = nullptr; uint64_t vramUsed = 0, vramTotal = 0; - if (ffCfDictGetDict(properties, CFSTR("PerformanceStatistics"), &perfStatistics) == NULL) { + if (ffCfDictGetDict(properties, CFSTR("PerformanceStatistics"), &perfStatistics) == nullptr) { int64_t utilization; - if (ffCfDictGetInt64(perfStatistics, CFSTR("Device Utilization %"), &utilization) == NULL) { + if (ffCfDictGetInt64(perfStatistics, CFSTR("Device Utilization %"), &utilization) == nullptr) { gpu->coreUsage = (double) utilization; - } else if (ffCfDictGetInt64(perfStatistics, CFSTR("GPU Core Utilization"), &utilization) == NULL) { + } else if (ffCfDictGetInt64(perfStatistics, CFSTR("GPU Core Utilization"), &utilization) == nullptr) { gpu->coreUsage = (double) utilization / 10000000.; // Nvidia? } - if (ffCfDictGetInt64(perfStatistics, CFSTR("Alloc system memory"), (int64_t*) &vramTotal) == NULL) { - if (ffCfDictGetInt64(perfStatistics, CFSTR("In use system memory"), (int64_t*) &vramUsed) != NULL) { + if (ffCfDictGetInt64(perfStatistics, CFSTR("Alloc system memory"), (int64_t*) &vramTotal) == nullptr) { + if (ffCfDictGetInt64(perfStatistics, CFSTR("In use system memory"), (int64_t*) &vramUsed) != nullptr) { vramTotal = 0; } - } else if (ffCfDictGetInt64(perfStatistics, CFSTR("vramFreeBytes"), (int64_t*) &vramTotal) == NULL) { - if (ffCfDictGetInt64(perfStatistics, CFSTR("vramUsedBytes"), (int64_t*) &vramUsed) == NULL) { + } else if (ffCfDictGetInt64(perfStatistics, CFSTR("vramFreeBytes"), (int64_t*) &vramTotal) == nullptr) { + if (ffCfDictGetInt64(perfStatistics, CFSTR("vramUsedBytes"), (int64_t*) &vramUsed) == nullptr) { vramTotal += vramUsed; } else { vramTotal = 0; @@ -154,9 +154,9 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { ffStrbufInit(&gpu->name); // IOAccelerator returns model / vendor-id properties for Apple Silicon, but not for Intel Iris GPUs. // Still needs testing for AMD's - if (ffCfDictGetString(properties, CFSTR("model"), &gpu->name) != NULL) { + if (ffCfDictGetString(properties, CFSTR("model"), &gpu->name) != nullptr) { CFRelease(properties); - properties = NULL; + properties = nullptr; FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t parentEntry = 0; if (IORegistryEntryGetParentEntry(registryEntry, kIOServicePlane, &parentEntry) != kIOReturnSuccess || @@ -169,7 +169,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { ffStrbufInit(&gpu->vendor); int vendorId; - if (ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId) == NULL) { + if (ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId) == nullptr) { const char* vendorStr = ffGPUGetVendorString((unsigned) vendorId); ffStrbufAppendS(&gpu->vendor, vendorStr); if (vendorStr == FF_GPU_VENDOR_NAME_APPLE || vendorStr == FF_GPU_VENDOR_NAME_INTEL) { @@ -203,5 +203,5 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { if (instance.config.general.detectVersion) { ffGpuDetectDriverVersion(gpus); } - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu_apple.m b/src/detection/gpu/gpu_apple.m index e206bdc1a..24ede6de2 100644 --- a/src/detection/gpu/gpu_apple.m +++ b/src/detection/gpu/gpu_apple.m @@ -32,7 +32,7 @@ const char* ffGpuDetectDriverVersion(FFlist* gpus) ffStrbufAppendS(&x->driver, version.UTF8String); } } - return NULL; + return nullptr; } return "Unsupported macOS version"; } @@ -43,7 +43,7 @@ const char* ffGpuDetectMetal(FFlist* gpus) { for (id device in MTLCopyAllDevices()) { - FFGPUResult* gpu = NULL; + FFGPUResult* gpu = nullptr; FF_LIST_FOR_EACH(FFGPUResult, x, *gpus) { if (x->deviceId == device.registryID) @@ -81,7 +81,7 @@ const char* ffGpuDetectMetal(FFlist* gpus) gpu->shared.total = device.recommendedMaxWorkingSetSize; #endif } - return NULL; + return nullptr; } return "Metal API is not supported by this macOS version"; } diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index f5f8d5800..64e1a74ec 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -80,7 +80,7 @@ static const char* detectByPci(const FFGPUOptions* options, FFlist* gpus) { ffGPUDetectTypeByVendorAndName(gpu); } - return NULL; + return nullptr; } const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { @@ -88,7 +88,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO) { ffGPUDetectByDrmBSD(options, gpus); if (gpus->length > 0) { - return NULL; + return nullptr; } } #endif diff --git a/src/detection/gpu/gpu_bsddrm.c b/src/detection/gpu/gpu_bsddrm.c index 2fcf9c96d..c90a37f4d 100644 --- a/src/detection/gpu/gpu_bsddrm.c +++ b/src/detection/gpu/gpu_bsddrm.c @@ -46,7 +46,7 @@ static const char* drmGetPciinfo(int drmfd, const char* drmId, struct drm_pciinf snprintf(requestBuf, ARRAY_SIZE(requestBuf), "hw.dri.%s.busid", drmId); char pciidBuf[64]; size_t pciidLen = ARRAY_SIZE(pciidBuf); - if (sysctlbyname(requestBuf, pciidBuf, &pciidLen, NULL, 0) < 0) { + if (sysctlbyname(requestBuf, pciidBuf, &pciidLen, nullptr, 0) < 0) { return "sysctlbyname(hw.dri.%s.busid) failed"; } // hw.dri.0.busid: pci:0000:01:00.0 @@ -100,18 +100,18 @@ static const char* drmGetPciinfo(int drmfd, const char* drmId, struct drm_pciinf // dev.drm.0.PCI_ID: 10de:2782 #endif - return NULL; + return nullptr; } const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/dev/dri/"); - if (dirp == NULL) { + if (dirp == nullptr) { return "opendir(/dev/dri/) failed"; } int drifd = dirfd(dirp); struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.' || !ffStrStartsWith(entry->d_name, "card")) { continue; } @@ -123,7 +123,7 @@ const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) { // Currently, DRM_BUS_PCI is the only bus type supported by drm-kmod on BSD (hard-coded in libdrm source tree) struct drm_pciinfo pciInfo; - if (drmGetPciinfo(fd, entry->d_name + strlen("card"), &pciInfo) != NULL) { + if (drmGetPciinfo(fd, entry->d_name + strlen("card"), &pciInfo) != nullptr) { continue; } @@ -157,11 +157,11 @@ const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) { if (ffStrStartsWith(driverName, "i915")) { ffDrmDetectI915(gpu, fd); } else if (ffStrStartsWith(driverName, "amdgpu")) { - uint32_t primaryNodeId = (uint32_t) strtoul(entry->d_name + strlen("card"), NULL, 10); + uint32_t primaryNodeId = (uint32_t) strtoul(entry->d_name + strlen("card"), nullptr, 10); FF_STRBUF_AUTO_DESTROY renderNode = ffStrbufCreateF("/dev/dri/renderD%d", primaryNodeId + 128); ffDrmDetectAmdgpu(options, gpu, renderNode.chars); } else if (ffStrStartsWith(driverName, "radeon")) { - uint32_t primaryNodeId = (uint32_t) strtoul(entry->d_name + strlen("card"), NULL, 10); + uint32_t primaryNodeId = (uint32_t) strtoul(entry->d_name + strlen("card"), nullptr, 10); FF_STRBUF_AUTO_DESTROY renderNode = ffStrbufCreateF("/dev/dri/renderD%d", primaryNodeId + 128); ffDrmDetectRadeon(options, gpu, renderNode.chars); } else if (ffStrStartsWith(driverName, "xe")) { @@ -191,7 +191,7 @@ const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) { ffGPUDetectTypeByVendorAndName(gpu); } - return NULL; + return nullptr; } #else diff --git a/src/detection/gpu/gpu_driver_specific.h b/src/detection/gpu/gpu_driver_specific.h index c4f7e8b3d..3500a51e2 100644 --- a/src/detection/gpu/gpu_driver_specific.h +++ b/src/detection/gpu/gpu_driver_specific.h @@ -15,7 +15,7 @@ typedef struct FFGpuDriverPciDeviceId { uint32_t revId; } FFGpuDriverPciDeviceId; -// Use pciBusId if not NULL; use pciDeviceId otherwise +// Use pciBusId if not nullptr; use pciDeviceId otherwise typedef struct FFGpuDriverCondition { FFGpuDriverConditionType type; FFGpuDriverPciBusId pciBusId; @@ -23,7 +23,7 @@ typedef struct FFGpuDriverCondition { uint64_t luid; } FFGpuDriverCondition; -// detect x if not NULL +// detect x if not nullptr typedef struct FFGpuDriverResult { uint32_t* index; double* temp; @@ -82,8 +82,8 @@ FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, } #endif else { - *pDetectFn = NULL; - *pDllName = NULL; + *pDetectFn = nullptr; + *pDllName = nullptr; return false; } diff --git a/src/detection/gpu/gpu_drm.c b/src/detection/gpu/gpu_drm.c index b22d0a7a9..6b94299a4 100644 --- a/src/detection/gpu/gpu_drm.c +++ b/src/detection/gpu/gpu_drm.c @@ -80,7 +80,7 @@ const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, con } } - return NULL; + return nullptr; } const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath) { @@ -172,7 +172,7 @@ const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, con gpu->coreUsage = value; } - return NULL; + return nullptr; } const char* ffDrmDetectI915(FFGPUResult* gpu, int fd) { @@ -213,7 +213,7 @@ const char* ffDrmDetectI915(FFGPUResult* gpu, int fd) { } } } - return NULL; + return nullptr; } static inline int popcountBytes(uint8_t* bytes, uint32_t length) { @@ -296,7 +296,7 @@ const char* ffDrmDetectXe(FFGPUResult* gpu, int fd) { } } } - return flag ? NULL : "Failed to query Xe GPU information"; + return flag ? nullptr : "Failed to query Xe GPU information"; } const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd) { @@ -334,7 +334,7 @@ const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd) { ffStrbufSetF(&gpu->name, "Apple M%d%s (G%d%c %02X)", paramsGlobal.gpu_generation - 12, variant, paramsGlobal.gpu_generation, paramsGlobal.gpu_variant, paramsGlobal.gpu_revision + 0xA0); } - return NULL; + return nullptr; } return "Failed to query Asahi GPU information"; @@ -362,7 +362,7 @@ const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd) { gpu->coreCount = (int32_t) getparam.value; } - return NULL; + return nullptr; } #endif // FF_HAVE_DRM @@ -380,17 +380,17 @@ const char* ffGPUDetectDriverSpecific(const FFGPUOptions* options, FFGPUResult* }, (FFGpuDriverResult) { .index = &gpu->index, - .temp = options->temp ? &gpu->temperature : NULL, - .memory = options->driverSpecific ? &gpu->dedicated : NULL, - .sharedMemory = options->driverSpecific ? &gpu->shared : NULL, - .memoryType = options->driverSpecific ? &gpu->memoryType : NULL, - .coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL, - .coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL, + .temp = options->temp ? &gpu->temperature : nullptr, + .memory = options->driverSpecific ? &gpu->dedicated : nullptr, + .sharedMemory = options->driverSpecific ? &gpu->shared : nullptr, + .memoryType = options->driverSpecific ? &gpu->memoryType : nullptr, + .coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : nullptr, + .coreUsage = options->driverSpecific ? &gpu->coreUsage : nullptr, .type = &gpu->type, - .frequency = options->driverSpecific ? &gpu->frequency : NULL, + .frequency = options->driverSpecific ? &gpu->frequency : nullptr, .name = &gpu->name, - .psCurr = options->driverSpecific ? &gpu->psCurr : NULL, - .psMax = options->driverSpecific ? &gpu->psMax : NULL, + .psCurr = options->driverSpecific ? &gpu->psCurr : nullptr, + .psMax = options->driverSpecific ? &gpu->psMax : nullptr, }, soName); } diff --git a/src/detection/gpu/gpu_gnu.c b/src/detection/gpu/gpu_gnu.c index 30cadf81b..113b34b45 100644 --- a/src/detection/gpu/gpu_gnu.c +++ b/src/detection/gpu/gpu_gnu.c @@ -22,12 +22,12 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu } FF_AUTO_CLOSE_DIR DIR* dirDomain = fdopendir(dDomainFd); - if (dirDomain == NULL) { + if (dirDomain == nullptr) { return "fdopendir(domain) failed"; } struct dirent* busEntry; - while ((busEntry = readdir(dirDomain)) != NULL) { + while ((busEntry = readdir(dirDomain)) != nullptr) { if (busEntry->d_type != DT_DIR || busEntry->d_name[0] == '.') { continue; } @@ -44,12 +44,12 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu } FF_AUTO_CLOSE_DIR DIR* dirBus = fdopendir(dBusFd); - if (dirBus == NULL) { + if (dirBus == nullptr) { continue; } struct dirent* devEntry; - while ((devEntry = readdir(dirBus)) != NULL) { + while ((devEntry = readdir(dirBus)) != nullptr) { if (devEntry->d_type != DT_DIR || devEntry->d_name[0] == '.') { continue; } @@ -65,12 +65,12 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu } FF_AUTO_CLOSE_DIR DIR* dirDev = fdopendir(dDevFd); - if (dirDev == NULL) { + if (dirDev == nullptr) { continue; } struct dirent* funcEntry; - while ((funcEntry = readdir(dirDev)) != NULL) { + while ((funcEntry = readdir(dirDev)) != nullptr) { if (funcEntry->d_type != DT_DIR || funcEntry->d_name[0] == '.') { continue; } @@ -143,5 +143,5 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu } } - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu_haiku.c b/src/detection/gpu/gpu_haiku.c index 20a4ae5f6..cf4704acd 100644 --- a/src/detection/gpu/gpu_haiku.c +++ b/src/detection/gpu/gpu_haiku.c @@ -48,5 +48,5 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu } } - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu_intel.c b/src/detection/gpu/gpu_intel.c index 04025b36c..f19a00e24 100644 --- a/src/detection/gpu/gpu_intel.c +++ b/src/detection/gpu/gpu_intel.c @@ -26,7 +26,7 @@ struct FFIgclData { static void shutdownIgcl() { if (igclData.apiHandle) { igclData.ffctlClose(igclData.apiHandle); - igclData.apiHandle = NULL; + igclData.apiHandle = nullptr; } } @@ -58,7 +58,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe return "loading igcl library failed"; } atexit(shutdownIgcl); - libigcl = NULL; // don't close igcl + libigcl = nullptr; // don't close igcl } if (!igclData.apiHandle) { @@ -66,11 +66,11 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe } uint32_t deviceCount = 0; - // ctlEnumerateDevices MUST be called with deviceCount = 0 and devices = NULL first, + // ctlEnumerateDevices MUST be called with deviceCount = 0 and devices = nullptr first, // otherwise it will be silently ignored and return CTL_RESULT_SUCCESS with deviceCount and devices unmodified. // VERY STRANGE BEHAVIOR - if (igclData.ffctlEnumerateDevices(igclData.apiHandle, &deviceCount, NULL) != CTL_RESULT_SUCCESS) { - return "ctlEnumerateDevices(NULL) failed"; + if (igclData.ffctlEnumerateDevices(igclData.apiHandle, &deviceCount, nullptr) != CTL_RESULT_SUCCESS) { + return "ctlEnumerateDevices(nullptr) failed"; } if (deviceCount == 0) { return "No Intel graphics adapter found"; @@ -81,7 +81,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe return "ctlEnumerateDevices(devices) failed"; } - ctl_device_adapter_handle_t device = NULL; + ctl_device_adapter_handle_t device = nullptr; uint64_t /* LUID */ deviceId = 0; ctl_device_adapter_properties_t properties = { @@ -257,5 +257,5 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe } } - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 91f6b566d..5b8dff471 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -61,11 +61,11 @@ FF_A_UNUSED static const char* drmFindRenderFromCard(const char* drmCardKey, FFs } struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (ffStrStartsWith(entry->d_name, "render")) { ffStrbufSetS(result, "/dev/dri/"); ffStrbufAppendS(result, entry->d_name); - return NULL; + return nullptr; } } return "Failed to find render device"; @@ -95,7 +95,7 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu, } struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -186,7 +186,7 @@ static void pciDetectIntelSpecific(const FFGPUOptions* options, FFGPUResult* gpu FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDir->chars); if (dirp) { struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -249,7 +249,7 @@ static const char* pciDetectTempGeneral(const FFGPUOptions* options, FFGPUResult } ffStrbufSubstrBefore(pciDir, pciDirLen); } - return NULL; + return nullptr; } static const char* drmDetectNouveauSpecific(FFGPUResult* gpu, const char* drmKey, FFstrbuf* buffer) { @@ -302,7 +302,7 @@ static const char* pciDetectZxSpecific(const FFGPUOptions* options, FFGPUResult* } } - return NULL; + return nullptr; } static inline uint16_t pcieLinkSpeedToGen(const FFstrbuf* buffer) { @@ -344,7 +344,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf } char pciPath[PATH_MAX]; - const char* pPciPath = NULL; + const char* pPciPath = nullptr; if (drmKey) { ssize_t pathLength = readlink(deviceDir->chars, pciPath, ARRAY_SIZE(pciPath) - 1); if (pathLength <= 0) { @@ -352,7 +352,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf } pciPath[pathLength] = '\0'; pPciPath = strrchr(pciPath, '/'); - if (__builtin_expect(pPciPath != NULL, true)) { + if (__builtin_expect(pPciPath != nullptr, true)) { pPciPath++; } else { pPciPath = pciPath; @@ -394,7 +394,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf FF_AUTO_CLOSE_DIR DIR* dirp = opendir(deviceDir->chars); if (dirp) { struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (ffStrStartsWith(entry->d_name, "card")) { ffStrCopy(drmKeyBuffer, entry->d_name, ARRAY_SIZE(drmKeyBuffer)); drmKey = drmKeyBuffer; @@ -415,7 +415,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) { bool ok = false; if (drmKey && options->driverSpecific) { - ok = drmDetectAmdSpecific(options, gpu, drmKey, buffer) == NULL; + ok = drmDetectAmdSpecific(options, gpu, drmKey, buffer) == nullptr; } if (!ok) { @@ -491,7 +491,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf } } - return NULL; + return nullptr; } #if __aarch64__ @@ -510,7 +510,7 @@ FF_A_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const ch return ffDrmDetectAsahi(gpu, fd); } - return NULL; + return nullptr; } #endif @@ -563,7 +563,7 @@ static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, co } } - return NULL; + return nullptr; } static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) { @@ -572,16 +572,16 @@ static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) { const uint32_t drmDirLength = drmDir.length; FF_AUTO_CLOSE_DIR DIR* dir = opendir(drmDir.chars); - if (dir == NULL) { + if (dir == nullptr) { return "Failed to open `/sys/class/drm/`"; } FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); struct dirent* entry; - while ((entry = readdir(dir)) != NULL) { + while ((entry = readdir(dir)) != nullptr) { if (!ffStrStartsWith(entry->d_name, "card") || - strchr(entry->d_name + 4, '-') != NULL) { + strchr(entry->d_name + 4, '-') != nullptr) { continue; } @@ -603,7 +603,7 @@ static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) { ffStrbufSubstrBefore(&drmDir, drmDirLength); } - return NULL; + return nullptr; } static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) { @@ -611,7 +611,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) { const char* pciDirPath = "/sys/bus/pci/devices/"; FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDirPath); - if (dirp == NULL) { + if (dirp == nullptr) { return "Failed to open `/sys/bus/pci/devices/`"; } @@ -623,7 +623,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -639,24 +639,24 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) { ffStrbufSubstrBefore(&pciDir, pciDevDirLength); assert(ffStrbufStartsWithS(&buffer, "pci:")); - detectPci(options, gpus, &buffer, &pciDir, NULL); + detectPci(options, gpus, &buffer, &pciDir, nullptr); ffStrbufSubstrBefore(&pciDir, pciBaseDirLength); } - return NULL; + return nullptr; } const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { #if __x86_64__ || __aarch64__ const char* ffGPUDetectWsl2(const FFGPUOptions* options, FFlist* gpus); - if (ffGPUDetectWsl2(options, gpus) == NULL) { - return NULL; + if (ffGPUDetectWsl2(options, gpus) == nullptr) { + return nullptr; } #endif if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO) { - if (drmDetectGPUs(options, gpus) == NULL && gpus->length > 0) { - return NULL; + if (drmDetectGPUs(options, gpus) == nullptr && gpus->length > 0) { + return nullptr; } } return pciDetectGPUs(options, gpus); diff --git a/src/detection/gpu/gpu_mthreads.c b/src/detection/gpu/gpu_mthreads.c index 8d5271935..a38887a85 100644 --- a/src/detection/gpu/gpu_mthreads.c +++ b/src/detection/gpu/gpu_mthreads.c @@ -61,23 +61,23 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlLibraryShutDown) if (ffmtmlLibraryInit(&mtmlData.lib) != MTML_SUCCESS) { - mtmlData.ffmtmlLibraryInitSystem = NULL; + mtmlData.ffmtmlLibraryInitSystem = nullptr; return "mtmlLibraryInit failed"; } if (mtmlData.ffmtmlLibraryInitSystem(mtmlData.lib, &mtmlData.sys) != MTML_SUCCESS) { mtmlData.ffmtmlLibraryShutDown(mtmlData.lib); - mtmlData.ffmtmlLibraryInitSystem = NULL; + mtmlData.ffmtmlLibraryInitSystem = nullptr; return "mtmlLibraryInitSystem failed"; } atexit(shutdownMtml); - libmtml = NULL; // don't close mtml + libmtml = nullptr; // don't close mtml } - if (mtmlData.ffmtmlLibraryInitSystem == NULL) { + if (mtmlData.ffmtmlLibraryInitSystem == nullptr) { return "loading mtml library failed"; } - MtmlDevice* device = NULL; + MtmlDevice* device = nullptr; if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID) { char pciBusIdStr[32]; snprintf(pciBusIdStr, ARRAY_SIZE(pciBusIdStr) - 1, "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func); @@ -92,7 +92,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive return "mtmlLibraryCountDevice() failed"; } - for (uint32_t i = 0; i < count; i++, device = NULL) { + for (uint32_t i = 0; i < count; i++, device = nullptr) { if (mtmlData.ffmtmlLibraryInitDeviceByIndex(mtmlData.lib, i, &device) != MTML_SUCCESS) { continue; } @@ -135,7 +135,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive } if (result.temp) { - MtmlGpu* gpu = NULL; + MtmlGpu* gpu = nullptr; if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS) { uint32_t value; if (mtmlData.ffmtmlGpuGetTemperature(gpu, &value) == MTML_SUCCESS) { @@ -145,7 +145,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive } if (result.memory) { - MtmlMemory* mem = NULL; + MtmlMemory* mem = nullptr; if (mtmlData.ffmtmlDeviceInitMemory(device, &mem) == MTML_SUCCESS) { unsigned long long total; if (mtmlData.ffmtmlMemoryGetTotal(mem, &total) == MTML_SUCCESS) { @@ -164,7 +164,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive } if (result.frequency) { - MtmlGpu* gpu = NULL; + MtmlGpu* gpu = nullptr; if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS) { uint32_t clockMHz; if (mtmlData.ffmtmlGpuGetMaxClock(gpu, &clockMHz) == MTML_SUCCESS) { @@ -174,7 +174,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive } if (result.coreUsage) { - MtmlGpu* gpu = NULL; + MtmlGpu* gpu = nullptr; if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS) { unsigned int utilization; if (mtmlData.ffmtmlGpuGetUtilization(gpu, &utilization) == MTML_SUCCESS) { @@ -204,7 +204,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive } } - return NULL; + return nullptr; #else diff --git a/src/detection/gpu/gpu_nbsd.c b/src/detection/gpu/gpu_nbsd.c index 10b920da9..dd51d32d1 100644 --- a/src/detection/gpu/gpu_nbsd.c +++ b/src/detection/gpu/gpu_nbsd.c @@ -117,5 +117,5 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu } } - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu_nvidia.c b/src/detection/gpu/gpu_nvidia.c index 4ec979f6b..2754ab89e 100644 --- a/src/detection/gpu/gpu_nvidia.c +++ b/src/detection/gpu/gpu_nvidia.c @@ -53,7 +53,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) { FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvapi, nvapi_QueryInterface) #define FF_NVAPI_INTERFACE(iName, iOffset) \ __typeof__(&iName) ff##iName = ffnvapi_QueryInterface(iOffset); \ - if (ff##iName == NULL) return "nvapi_QueryInterface " #iName " failed"; + if (ff##iName == nullptr) return "nvapi_QueryInterface " #iName " failed"; FF_NVAPI_INTERFACE(nvapi_Initialize, NVAPI_INTERFACE_OFFSET_INITIALIZE) FF_NVAPI_INTERFACE(nvapi_Unload, NVAPI_INTERFACE_OFFSET_UNLOAD) @@ -72,10 +72,10 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) { nvapiData.ffnvapi_Unload = ffnvapi_Unload; atexit((void*) ffnvapi_Unload); - libnvapi = NULL; // don't close nvapi + libnvapi = nullptr; // don't close nvapi } - if (nvapiData.ffnvapi_EnumPhysicalGPUs == NULL) { + if (nvapiData.ffnvapi_EnumPhysicalGPUs == nullptr) { return "loading nvapi library failed"; } @@ -141,7 +141,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) { } } - return NULL; + return nullptr; } #endif @@ -173,18 +173,18 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetName) if (ffnvmlInit_v2() != NVML_SUCCESS) { - nvmlData.ffnvmlDeviceGetNumGpuCores = NULL; + nvmlData.ffnvmlDeviceGetNumGpuCores = nullptr; return "nvmlInit_v2() failed"; } atexit((void*) ffnvmlShutdown); - libnvml = NULL; // don't close nvml + libnvml = nullptr; // don't close nvml } - if (nvmlData.ffnvmlDeviceGetNumGpuCores == NULL) { + if (nvmlData.ffnvmlDeviceGetNumGpuCores == nullptr) { return "loading nvml library failed"; } - nvmlDevice_t device = NULL; + nvmlDevice_t device = nullptr; if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID) { char pciBusIdStr[32]; snprintf(pciBusIdStr, ARRAY_SIZE(pciBusIdStr), "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func); @@ -199,7 +199,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR return "nvmlDeviceGetCount_v2() failed"; } - for (uint32_t i = 0; i < count; i++, device = NULL) { + for (uint32_t i = 0; i < count; i++, device = nullptr) { if (nvmlData.ffnvmlDeviceGetHandleByIndex_v2(i, &device) != NVML_SUCCESS) { continue; } @@ -319,7 +319,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR } } - return NULL; + return nullptr; #else diff --git a/src/detection/gpu/gpu_obsd.c b/src/detection/gpu/gpu_obsd.c index 8d0ee9a31..25c8f5396 100644 --- a/src/detection/gpu/gpu_obsd.c +++ b/src/detection/gpu/gpu_obsd.c @@ -98,7 +98,7 @@ const char* detectByPci(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) { } } - return NULL; + return nullptr; } const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { @@ -106,7 +106,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO) { ffGPUDetectByDrmBSD(options, gpus); if (gpus->length > 0) { - return NULL; + return nullptr; } } #endif diff --git a/src/detection/gpu/gpu_sunos.c b/src/detection/gpu/gpu_sunos.c index dbf168c57..fe9a8b43c 100644 --- a/src/detection/gpu/gpu_sunos.c +++ b/src/detection/gpu/gpu_sunos.c @@ -19,7 +19,7 @@ static int walkDevTree(di_node_t node, FF_A_UNUSED di_minor_t minor, FFlist* gpu gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; gpu->type = FF_GPU_TYPE_UNKNOWN; gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; - gpu->deviceId = strtoul(di_bus_addr(node), NULL, 16); + gpu->deviceId = strtoul(di_bus_addr(node), nullptr, 16); gpu->frequency = FF_GPU_FREQUENCY_UNSET; gpu->pcieSpeed = FF_GPU_PCIE_SPEED_UNSET; @@ -51,5 +51,5 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu di_walk_minor(rootNode, DDI_NT_DISPLAY, DI_WALK_CLDFIRST, gpus, (void*) walkDevTree); di_fini(rootNode); - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 589fee4e1..9e0e3b573 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -94,10 +94,10 @@ static bool queryPciDeviceInfo(FFGPUResult* gpu, D3DKMT_DEVICE_IDS* outDeviceIds uint32_t pciBus = 0; ULONG pciBufLen = sizeof(pciBus); - if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_BUSNUMBER, NULL, &pciBus, &pciBufLen, 0) == CR_SUCCESS) { + if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_BUSNUMBER, nullptr, &pciBus, &pciBufLen, 0) == CR_SUCCESS) { uint32_t pciAddr = 0; pciBufLen = sizeof(pciAddr); - if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_ADDRESS, NULL, &pciAddr, &pciBufLen, 0) == CR_SUCCESS) { + if (CM_Get_DevNode_Registry_PropertyW(devInst, CM_DRP_ADDRESS, nullptr, &pciAddr, &pciBufLen, 0) == CR_SUCCESS) { entry->adapterAddress = ffGPUPciAddr2Id(0, pciBus, (pciAddr >> 16) & 0xFFFF, pciAddr & 0xFFFF); FF_DEBUG("Cached device IDs for PCI bus %u: vendor=0x%04x device=0x%04x", pciBus, entry->deviceIds.VendorID, entry->deviceIds.DeviceID); } else { @@ -190,12 +190,12 @@ static bool queryVendorNameViaRegistry(FFstrbuf* vendor, D3DKMT_HANDLE hAdapter) swprintf(path, ARRAY_SIZE(path), L"SYSTEM\\CurrentControlSet\\Control\\Video\\{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\\0000", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); FF_DEBUG("Querying registry: HKEY_LOCAL_MACHINE\\%ls\\ProviderName", path); - FF_AUTO_CLOSE_FD HANDLE key = NULL; - if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, path, &key, NULL)) { + FF_AUTO_CLOSE_FD HANDLE key = nullptr; + if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, path, &key, nullptr)) { return false; } - return ffRegReadStrbuf(key, L"ProviderName", vendor, NULL); + return ffRegReadStrbuf(key, L"ProviderName", vendor, nullptr); } #else @@ -428,17 +428,17 @@ ffGPUDetectWsl2 }, (FFGpuDriverResult) { .index = &gpu->index, - .temp = options->temp ? &gpu->temperature : NULL, - .memory = options->driverSpecific ? &gpu->dedicated : NULL, - .sharedMemory = options->driverSpecific ? &gpu->shared : NULL, - .memoryType = options->driverSpecific ? &gpu->memoryType : NULL, - .coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL, - .coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL, + .temp = options->temp ? &gpu->temperature : nullptr, + .memory = options->driverSpecific ? &gpu->dedicated : nullptr, + .sharedMemory = options->driverSpecific ? &gpu->shared : nullptr, + .memoryType = options->driverSpecific ? &gpu->memoryType : nullptr, + .coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : nullptr, + .coreUsage = options->driverSpecific ? &gpu->coreUsage : nullptr, .type = &gpu->type, - .frequency = options->driverSpecific ? &gpu->frequency : NULL, + .frequency = options->driverSpecific ? &gpu->frequency : nullptr, .name = &gpu->name, - .psCurr = options->driverSpecific ? &gpu->psCurr : NULL, - .psMax = options->driverSpecific ? &gpu->psMax : NULL, + .psCurr = options->driverSpecific ? &gpu->psCurr : nullptr, + .psMax = options->driverSpecific ? &gpu->psMax : nullptr, }, dllName); FF_DEBUG("Driver-specific detection completed: %s", error ?: "Success"); @@ -638,5 +638,5 @@ ffGPUDetectWsl2 } } - return NULL; + return nullptr; } diff --git a/src/detection/gpu/gpu_windows.cpp b/src/detection/gpu/gpu_windows.cpp index ae6f00ef9..e5cdecede 100644 --- a/src/detection/gpu/gpu_windows.cpp +++ b/src/detection/gpu/gpu_windows.cpp @@ -18,7 +18,7 @@ static IDXCoreAdapterFactory* loadDxCoreFactory() { } initialized = true; - FF_LIBRARY_LOAD(dxcore, NULL, "dxcore" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(dxcore, nullptr, "dxcore" FF_LIBRARY_EXTENSION, 1) // DXCoreCreateAdapterFactory is a reloaded function, so we can't use FF_LIBRARY_LOAD_SYMBOL_MESSAGE here typedef HRESULT (*DXCoreCreateAdapterFactory_t)(REFIID riid, void** ppvFactory); @@ -26,7 +26,7 @@ static IDXCoreAdapterFactory* loadDxCoreFactory() { #ifndef FF_DISABLE_DLOPEN auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) dlsym(dxcore, "DXCoreCreateAdapterFactory"); if (ffDXCoreCreateAdapterFactory == nullptr) { - return NULL; + return nullptr; } #else auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) DXCoreCreateAdapterFactory; @@ -35,10 +35,10 @@ static IDXCoreAdapterFactory* loadDxCoreFactory() { HRESULT hr = ffDXCoreCreateAdapterFactory(IID_PPV_ARGS(&factory)); if (FAILED(hr)) { FF_DEBUG("DXCoreCreateAdapterFactory failed with HRESULT: 0x%08lX (%s)", hr, ffDebugHResult(hr)); - return NULL; + return nullptr; } - dxcore = NULL; // Don't unload + dxcore = nullptr; // Don't unload return factory; } diff --git a/src/detection/gpu/mtml.h b/src/detection/gpu/mtml.h index 9f62fc326..1ebd5398b 100644 --- a/src/detection/gpu/mtml.h +++ b/src/detection/gpu/mtml.h @@ -32,7 +32,7 @@ typedef struct MtmlMemory MtmlMemory; */ typedef struct { - char sbdf[MTML_DEVICE_PCI_SBDF_BUFFER_SIZE]; //!< The tuple segment:bus:device.function PCI identifier (& NULL terminator). + char sbdf[MTML_DEVICE_PCI_SBDF_BUFFER_SIZE]; //!< The tuple segment:bus:device.function PCI identifier (& nullptr terminator). unsigned int segment; //!< The PCI segment group(domain) on which the device's bus resides, 0 to 0xffffffff. unsigned int bus; //!< The bus on which the device resides, 0 to 0xff. unsigned int device; //!< The device ID on the bus, 0 to 31. diff --git a/src/detection/gpu/nvml.h b/src/detection/gpu/nvml.h index 52adaa3b5..ea2455179 100644 --- a/src/detection/gpu/nvml.h +++ b/src/detection/gpu/nvml.h @@ -18,7 +18,7 @@ typedef struct nvmlDevice_t* nvmlDevice_t; // https://docs.nvidia.com/deploy/nvml-api/structnvmlPciInfo__t.html // PCI information about a GPU device typedef struct { - // The legacy tuple domain:bus:device.function PCI identifier (& NULL terminator) + // The legacy tuple domain:bus:device.function PCI identifier (& nullptr terminator) char busIdLegacy[NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE]; // The PCI domain on which the device's bus resides, 0 to 0xffffffff unsigned int domain; @@ -30,7 +30,7 @@ typedef struct { unsigned int pciDeviceId; // The 32-bit Sub System Device ID unsigned int pciSubSystemId; - // The tuple domain:bus:device.function PCI identifier (& NULL terminator) + // The tuple domain:bus:device.function PCI identifier (& nullptr terminator) char busId[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE]; } nvmlPciInfo_t; diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index 05a8db1b3..3cc7911e2 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -44,12 +44,12 @@ static bool testXfconfWallpaperPropKey(FF_A_UNUSED void* data, const char* key) } static void detectGTKFromSettings(FFGTKResult* result) { - static const char* themeName = NULL; - static const char* iconsName = NULL; - static const char* fontName = NULL; - static const char* cursorTheme = NULL; + static const char* themeName = nullptr; + static const char* iconsName = nullptr; + static const char* fontName = nullptr; + static const char* cursorTheme = nullptr; static int cursorSize = 0; - static const char* wallpaper = NULL; + static const char* wallpaper = nullptr; static bool init = false; @@ -68,33 +68,33 @@ static void detectGTKFromSettings(FFGTKResult* result) { fontName = ffSettingsGetXFConf("xsettings", "/Gtk/FontName", FF_VARIANT_TYPE_STRING).strValue; cursorTheme = ffSettingsGetXFConf("xsettings", "/Gtk/CursorThemeName", FF_VARIANT_TYPE_STRING).strValue; cursorSize = ffSettingsGetXFConf("xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue; - wallpaper = ffSettingsGetXFConfFirstMatch("xfce4-desktop", "/backdrop/screen0", FF_VARIANT_TYPE_STRING, NULL, testXfconfWallpaperPropKey).strValue; + wallpaper = ffSettingsGetXFConfFirstMatch("xfce4-desktop", "/backdrop/screen0", FF_VARIANT_TYPE_STRING, nullptr, testXfconfWallpaperPropKey).strValue; } else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_CINNAMON)) { - themeName = ffSettingsGetGnome("/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; - iconsName = ffSettingsGetGnome("/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; - fontName = ffSettingsGetGnome("/org/cinnamon/desktop/interface/font-name", "org.cinnamon.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; - cursorTheme = ffSettingsGetGnome("/org/cinnamon/desktop/interface/cursor-theme", "org.cinnamon.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; - cursorSize = ffSettingsGetGnome("/org/cinnamon/desktop/interface/cursor-size", "org.cinnamon.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; - wallpaper = ffSettingsGetGnome("/org/cinnamon/desktop/background/picture-uri", "org.cinnamon.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; + themeName = ffSettingsGetGnome("/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", nullptr, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; + iconsName = ffSettingsGetGnome("/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", nullptr, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; + fontName = ffSettingsGetGnome("/org/cinnamon/desktop/interface/font-name", "org.cinnamon.desktop.interface", nullptr, "font-name", FF_VARIANT_TYPE_STRING).strValue; + cursorTheme = ffSettingsGetGnome("/org/cinnamon/desktop/interface/cursor-theme", "org.cinnamon.desktop.interface", nullptr, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; + cursorSize = ffSettingsGetGnome("/org/cinnamon/desktop/interface/cursor-size", "org.cinnamon.desktop.interface", nullptr, "cursor-size", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGetGnome("/org/cinnamon/desktop/background/picture-uri", "org.cinnamon.desktop.background", nullptr, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; } else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_MATE)) { - themeName = ffSettingsGetGnome("/org/mate/interface/gtk-theme", "org.mate.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; - iconsName = ffSettingsGetGnome("/org/mate/interface/icon-theme", "org.mate.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; - fontName = ffSettingsGetGnome("/org/mate/interface/font-name", "org.mate.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; - cursorTheme = ffSettingsGetGnome("/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; - cursorSize = ffSettingsGetGnome("/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; - wallpaper = ffSettingsGetGnome("/org/mate/desktop/background", "org.mate.background", NULL, "picture-filename", FF_VARIANT_TYPE_STRING).strValue; + themeName = ffSettingsGetGnome("/org/mate/interface/gtk-theme", "org.mate.interface", nullptr, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; + iconsName = ffSettingsGetGnome("/org/mate/interface/icon-theme", "org.mate.interface", nullptr, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; + fontName = ffSettingsGetGnome("/org/mate/interface/font-name", "org.mate.interface", nullptr, "font-name", FF_VARIANT_TYPE_STRING).strValue; + cursorTheme = ffSettingsGetGnome("/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", nullptr, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; + cursorSize = ffSettingsGetGnome("/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", nullptr, "cursor-size", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGetGnome("/org/mate/desktop/background", "org.mate.background", nullptr, "picture-filename", FF_VARIANT_TYPE_STRING).strValue; } else if ( ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_GNOME) || ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_GNOME_CLASSIC) || ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_UNITY) || ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_BUDGIE) || ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_NEBIDE)) { - themeName = ffSettingsGetGnome("/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; - iconsName = ffSettingsGetGnome("/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; - fontName = ffSettingsGetGnome("/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; - cursorTheme = ffSettingsGetGnome("/org/gnome/desktop/interface/cursor-theme", "org.gnome.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; - cursorSize = ffSettingsGetGnome("/org/gnome/desktop/interface/cursor-size", "org.gnome.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; - wallpaper = ffSettingsGetGnome("/org/gnome/desktop/background/picture-uri", "org.gnome.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; + themeName = ffSettingsGetGnome("/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", nullptr, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; + iconsName = ffSettingsGetGnome("/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", nullptr, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; + fontName = ffSettingsGetGnome("/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", nullptr, "font-name", FF_VARIANT_TYPE_STRING).strValue; + cursorTheme = ffSettingsGetGnome("/org/gnome/desktop/interface/cursor-theme", "org.gnome.desktop.interface", nullptr, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; + cursorSize = ffSettingsGetGnome("/org/gnome/desktop/interface/cursor-size", "org.gnome.desktop.interface", nullptr, "cursor-size", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGetGnome("/org/gnome/desktop/background/picture-uri", "org.gnome.desktop.background", nullptr, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; } else if ( ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_ENLIGHTENMENT)) { ffEnlightenmentSettings settings = {}; diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index 8a7d974c3..f7eb22bc4 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -25,11 +25,11 @@ typedef enum PlasmaCategory: uint8_t { static bool detectPlasmaFromFile(const char* filename, FFQtResult* result) { FILE* kdeglobals = fopen(filename, "r"); - if (kdeglobals == NULL) { + if (kdeglobals == nullptr) { return false; } - char* line = NULL; + char* line = nullptr; size_t len = 0; PlasmaCategory category = PLASMA_CATEGORY_OTHER; @@ -153,7 +153,7 @@ static void detectQtCt(char qver, FFQtResult* result) { while (*p) { if (p[0] == '\\' && p[1] == 'x' && isxdigit(p[2]) && isxdigit(p[3]) && isxdigit(p[4]) && isxdigit(p[5])) { - uint32_t codepoint = (uint32_t) strtoul((char[]) { p[2], p[3], p[4], p[5], '\0' }, NULL, 16); + uint32_t codepoint = (uint32_t) strtoul((char[]) { p[2], p[3], p[4], p[5], '\0' }, nullptr, 16); ffStrbufAppendUtf32CodePoint(&result->font, codepoint); p += 6; } else { diff --git a/src/detection/host/host_android.c b/src/detection/host/host_android.c index 1157a92f0..dffe066b9 100644 --- a/src/detection/host/host_android.c +++ b/src/detection/host/host_android.c @@ -23,5 +23,5 @@ const char* ffDetectHost(FFHostResult* host) { ffStrbufPrepend(&host->name, &host->vendor); } - return NULL; + return nullptr; } diff --git a/src/detection/host/host_apple.c b/src/detection/host/host_apple.c index a177bf405..a855ba5a4 100644 --- a/src/detection/host/host_apple.c +++ b/src/detection/host/host_apple.c @@ -44,7 +44,7 @@ const char* getOthersByIokit(FFHostResult* host) { ffCfStrGetString(version, &host->version); } - return NULL; + return nullptr; } const char* ffDetectHost(FFHostResult* host) { @@ -64,5 +64,5 @@ const char* ffDetectHost(FFHostResult* host) { ffStrbufSet(&host->name, &host->family); } getOthersByIokit(host); - return NULL; + return nullptr; } diff --git a/src/detection/host/host_bsd.c b/src/detection/host/host_bsd.c index 3eb547d1b..8b5269d42 100644 --- a/src/detection/host/host_bsd.c +++ b/src/detection/host/host_bsd.c @@ -22,5 +22,5 @@ const char* ffDetectHost(FFHostResult* host) { ffHostDetectMac(host); #endif - return NULL; + return nullptr; } diff --git a/src/detection/host/host_linux.c b/src/detection/host/host_linux.c index 81418a81d..9252c7629 100644 --- a/src/detection/host/host_linux.c +++ b/src/detection/host/host_linux.c @@ -86,7 +86,7 @@ const char* ffDetectHost(FFHostResult* host) { if (host->family.length == 0 && host->name.length == 0) { const char* wslDistroName = getenv("WSL_DISTRO_NAME"); // On WSL, the real host can't be detected. Instead use WSL as host. - if (wslDistroName != NULL || getenv("WSL_DISTRO") != NULL || getenv("WSL_INTEROP") != NULL) { + if (wslDistroName != nullptr || getenv("WSL_DISTRO") != nullptr || getenv("WSL_INTEROP") != nullptr) { ffStrbufSetStatic(&host->name, "Windows Subsystem for Linux"); if (wslDistroName) { ffStrbufAppendF(&host->name, " - %s", wslDistroName); @@ -99,7 +99,7 @@ const char* ffDetectHost(FFHostResult* host) { "wslinfo", "--wsl-version", "-n", - NULL, + nullptr, }); // supported in 2.2.3 and later } } else if (ffStrbufStartsWithS(&instance.state.platform.sysinfo.version, "FreeBSD ")) { @@ -113,5 +113,5 @@ const char* ffDetectHost(FFHostResult* host) { } } - return NULL; + return nullptr; } diff --git a/src/detection/host/host_mac.c b/src/detection/host/host_mac.c index d68033263..f610c3dde 100644 --- a/src/detection/host/host_mac.c +++ b/src/detection/host/host_mac.c @@ -425,7 +425,7 @@ const char* ffHostGetMacProductNameWithHwModel(const FFstrbuf* hwModel) { return "iMac (24/20-inch, Early 2009)"; } } - return NULL; + return nullptr; } #ifdef __x86_64__ diff --git a/src/detection/host/host_nbsd.c b/src/detection/host/host_nbsd.c index a5a29d289..265641ddd 100644 --- a/src/detection/host/host_nbsd.c +++ b/src/detection/host/host_nbsd.c @@ -3,23 +3,23 @@ #include "common/smbios.h" const char* ffDetectHost(FFHostResult* host) { - const char* error = NULL; + const char* error = nullptr; if ((error = ffSysctlGetString("machdep.dmi.system-product", &host->name))) { return error; } ffCleanUpSmbiosValue(&host->name); - if (ffSysctlGetString("machdep.dmi.system-vendor", &host->vendor) == NULL) { + if (ffSysctlGetString("machdep.dmi.system-vendor", &host->vendor) == nullptr) { ffCleanUpSmbiosValue(&host->vendor); } - if (ffSysctlGetString("machdep.dmi.system-version", &host->version) == NULL) { + if (ffSysctlGetString("machdep.dmi.system-version", &host->version) == nullptr) { ffCleanUpSmbiosValue(&host->version); } - if (ffSysctlGetString("machdep.dmi.system-serial", &host->serial) == NULL) { + if (ffSysctlGetString("machdep.dmi.system-serial", &host->serial) == nullptr) { ffCleanUpSmbiosValue(&host->serial); } - if (ffSysctlGetString("machdep.dmi.system-uuid", &host->uuid) == NULL) { + if (ffSysctlGetString("machdep.dmi.system-uuid", &host->uuid) == nullptr) { ffCleanUpSmbiosValue(&host->uuid); } - return NULL; + return nullptr; } diff --git a/src/detection/host/host_obsd.c b/src/detection/host/host_obsd.c index cb16ecf39..85d2c0836 100644 --- a/src/detection/host/host_obsd.c +++ b/src/detection/host/host_obsd.c @@ -3,20 +3,20 @@ #include "common/smbios.h" const char* ffDetectHost(FFHostResult* host) { - const char* error = NULL; + const char* error = nullptr; if ((error = ffSysctlGetString(CTL_HW, HW_PRODUCT, &host->name))) { return error; } ffCleanUpSmbiosValue(&host->name); - if (ffSysctlGetString(CTL_HW, HW_VENDOR, &host->vendor) == NULL) { + if (ffSysctlGetString(CTL_HW, HW_VENDOR, &host->vendor) == nullptr) { ffCleanUpSmbiosValue(&host->vendor); } - if (ffSysctlGetString(CTL_HW, HW_VERSION, &host->version) == NULL) { + if (ffSysctlGetString(CTL_HW, HW_VERSION, &host->version) == nullptr) { ffCleanUpSmbiosValue(&host->version); } - if (ffSysctlGetString(CTL_HW, HW_SERIALNO, &host->serial) == NULL) { + if (ffSysctlGetString(CTL_HW, HW_SERIALNO, &host->serial) == nullptr) { ffCleanUpSmbiosValue(&host->serial); } - return NULL; + return nullptr; } diff --git a/src/detection/host/host_windows.c b/src/detection/host/host_windows.c index 9f2582911..0aa90ee08 100644 --- a/src/detection/host/host_windows.c +++ b/src/detection/host/host_windows.c @@ -70,5 +70,5 @@ const char* ffDetectHost(FFHostResult* host) { ffHostDetectMac(host); #endif - return NULL; + return nullptr; } diff --git a/src/detection/icons/icons_linux.c b/src/detection/icons/icons_linux.c index 0ecaa0704..fb1b12621 100644 --- a/src/detection/icons/icons_linux.c +++ b/src/detection/icons/icons_linux.c @@ -26,5 +26,5 @@ const char* ffDetectIcons(FFIconsResult* result) { ffStrbufAppendS(&result->icons1, " [Qt]"); } - return NULL; + return nullptr; } diff --git a/src/detection/icons/icons_windows.c b/src/detection/icons/icons_windows.c index e19943265..407dd7fe0 100644 --- a/src/detection/icons/icons_windows.c +++ b/src/detection/icons/icons_windows.c @@ -2,21 +2,21 @@ #include "common/windows/registry.h" const char* ffDetectIcons(FFIconsResult* result) { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel", &hKey, NULL) && - !ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu", &hKey, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel", &hKey, nullptr) && + !ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu", &hKey, nullptr)) { // If the key doesn't exist, it means that the user never changed the default settings. ffStrbufSetStatic(&result->icons2, "Recycle Bin"); - return NULL; + return nullptr; } // Whether these icons are hidden uint32_t ThisPC = 1, UsersFiles = 1, RemoteNetwork = 1, RecycleBin = 0 /* Shown by default */, ControlPanel = 1; - ffRegReadUint(hKey, L"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", &ThisPC, NULL); - ffRegReadUint(hKey, L"{59031a47-3f72-44a7-89c5-5595fe6b30ee}", &UsersFiles, NULL); - ffRegReadUint(hKey, L"{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", &RemoteNetwork, NULL); - ffRegReadUint(hKey, L"{645FF040-5081-101B-9F08-00AA002F954E}", &RecycleBin, NULL); - ffRegReadUint(hKey, L"{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", &ControlPanel, NULL); + ffRegReadUint(hKey, L"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", &ThisPC, nullptr); + ffRegReadUint(hKey, L"{59031a47-3f72-44a7-89c5-5595fe6b30ee}", &UsersFiles, nullptr); + ffRegReadUint(hKey, L"{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", &RemoteNetwork, nullptr); + ffRegReadUint(hKey, L"{645FF040-5081-101B-9F08-00AA002F954E}", &RecycleBin, nullptr); + ffRegReadUint(hKey, L"{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", &ControlPanel, nullptr); if (ThisPC && UsersFiles && RemoteNetwork && RecycleBin && ControlPanel) { return "All icons are hidden"; @@ -43,5 +43,5 @@ const char* ffDetectIcons(FFIconsResult* result) { ffStrbufTrimRight(&result->icons2, ' '); ffStrbufTrimRight(&result->icons2, ','); - return NULL; + return nullptr; } diff --git a/src/detection/initsystem/initsystem_haiku.c b/src/detection/initsystem/initsystem_haiku.c index 04857bca3..bdcb64d9a 100644 --- a/src/detection/initsystem/initsystem_haiku.c +++ b/src/detection/initsystem/initsystem_haiku.c @@ -31,5 +31,5 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) { ffGetFileVersion(path, &result->version); } - return NULL; + return nullptr; } diff --git a/src/detection/initsystem/initsystem_linux.c b/src/detection/initsystem/initsystem_linux.c index 445657bad..bd2715293 100644 --- a/src/detection/initsystem/initsystem_linux.c +++ b/src/detection/initsystem/initsystem_linux.c @@ -20,13 +20,13 @@ FF_A_UNUSED static bool extractSystemdVersion(const char* str, uint32_t len, voi } const char* ffDetectInitSystem(FFInitSystemResult* result) { - const char* error = ffProcessGetBasicInfoLinux((int) result->pid, &result->name, NULL, NULL); + const char* error = ffProcessGetBasicInfoLinux((int) result->pid, &result->name, nullptr, nullptr); if (error) { #ifdef __ANDROID__ if (access("/system/bin/init", F_OK) == 0) { ffStrbufSetStatic(&result->exe, "/system/bin/init"); ffStrbufSetStatic(&result->name, "init"); - return NULL; + return nullptr; } #endif return error; @@ -34,7 +34,7 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) { const char* _; // In linux /proc/1/exe is not readable - ffProcessGetInfoLinux((int) result->pid, &result->name, &result->exe, &_, NULL); + ffProcessGetInfoLinux((int) result->pid, &result->name, &result->exe, &_, nullptr); if (result->exe.chars[0] == '/') { // In some old system, /sbin/init is a symlink char buf[PATH_MAX]; @@ -52,8 +52,8 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) { if (ffProcessAppendStdOut(&result->version, (char* const[]) { ffStrbufEndsWithS(&result->exe, "/systemd") ? result->exe.chars : "systemctl", // use exe path in case users have another systemd installed "--version", - NULL, - }) == NULL && + nullptr, + }) == nullptr && result->version.length) { uint32_t iStart = ffStrbufFirstIndexC(&result->version, '('); if (iStart < result->version.length) { @@ -67,8 +67,8 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) { if (ffProcessAppendStdOut(&result->version, (char* const[]) { ffStrbufEndsWithS(&result->exe, "/dinit") ? result->exe.chars : "dinit", "--version", - NULL, - }) == NULL && + nullptr, + }) == nullptr && result->version.length) { // Dinit version 0.18.0. ffStrbufSubstrBeforeFirstC(&result->version, '\n'); @@ -79,8 +79,8 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) { if (ffProcessAppendStdOut(&result->version, (char* const[]) { ffStrbufEndsWithS(&result->exe, "/shepherd") ? result->exe.chars : "shepherd", "--version", - NULL, - }) == NULL && + nullptr, + }) == nullptr && result->version.length) { // shepherd (GNU Shepherd) 1.0.6 // The first line in the output might not contain the version @@ -97,8 +97,8 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) { if (ffProcessAppendStdOut(&result->version, (char* const[]) { "/bin/launchctl", "version", - NULL, - }) == NULL && + nullptr, + }) == nullptr && result->version.length) { uint32_t iStart = ffStrbufFirstIndexS(&result->version, "Version "); if (iStart < result->version.length) { @@ -112,5 +112,5 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) { #endif } - return NULL; + return nullptr; } diff --git a/src/detection/keyboard/keyboard_apple.c b/src/detection/keyboard/keyboard_apple.c index e2ecc37e4..5d4602257 100644 --- a/src/detection/keyboard/keyboard_apple.c +++ b/src/detection/keyboard/keyboard_apple.c @@ -32,5 +32,5 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { } IOHIDManagerClose(manager, kIOHIDOptionsTypeNone); - return NULL; + return nullptr; } diff --git a/src/detection/keyboard/keyboard_bsd.c b/src/detection/keyboard/keyboard_bsd.c index 4b0ee574a..46a703b57 100644 --- a/src/detection/keyboard/keyboard_bsd.c +++ b/src/detection/keyboard/keyboard_bsd.c @@ -35,7 +35,7 @@ static const char* detectByIoctl(FFlist* devices) { ffStrbufAppendF(&device->name, " (kbd%d)", kbdInfo.kb_index); ffStrbufInit(&device->serial); - return NULL; + return nullptr; } #define MAX_UHID_KBDS 64 @@ -80,13 +80,13 @@ static const char* detectByUsbhid(FFlist* devices) { hid_dispose_report_desc(repDesc); } - return NULL; + return nullptr; } const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { detectByUsbhid(devices); if (devices->length > 0) { - return NULL; + return nullptr; } return detectByIoctl(devices); } diff --git a/src/detection/keyboard/keyboard_haiku.cpp b/src/detection/keyboard/keyboard_haiku.cpp index dc1d28a0e..2063f059f 100644 --- a/src/detection/keyboard/keyboard_haiku.cpp +++ b/src/detection/keyboard/keyboard_haiku.cpp @@ -23,5 +23,5 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { ffStrbufInitS(&item->name, device->Name()); } - return NULL; + return nullptr; } diff --git a/src/detection/keyboard/keyboard_linux.c b/src/detection/keyboard/keyboard_linux.c index 1a29abb01..539282ab8 100644 --- a/src/detection/keyboard/keyboard_linux.c +++ b/src/detection/keyboard/keyboard_linux.c @@ -9,7 +9,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { // This detects both wired and Bluetooth keyboards uniformly. FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); if (!ffAppendFileBuffer("/proc/bus/input/devices", &content)) { - return "ffAppendFileBuffer(\"/proc/bus/input/devices\") == NULL"; + return "ffAppendFileBuffer(\"/proc/bus/input/devices\") == nullptr"; } FFstrbuf kbd = ffStrbufCreateStatic("kbd"); @@ -19,7 +19,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { .serial = ffStrbufCreate() }; - char* line = NULL; + char* line = nullptr; size_t len = 0; while (ffStrbufGetline(&line, &len, &content)) { switch (line[0]) { @@ -51,7 +51,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { if (ffStrStartsWith(bits, "EV=")) { // Check EV_REP (auto-repeat, bit 20) to filter pseudo-keyboards (Power Button, PC Speaker). const char* evBits = bits + strlen("EV="); - uint64_t val = strtoull(evBits, NULL, 16); + uint64_t val = strtoull(evBits, nullptr, 16); if (!(val & (1ULL << EV_REP))) { goto skipDevice; } @@ -63,7 +63,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { const char* lastWord = memrchr(keyBits, ' ', len - (size_t) (keyBits - line)); lastWord = lastWord ? lastWord + 1 : keyBits; - uint64_t val = strtoull(lastWord, NULL, 16); + uint64_t val = strtoull(lastWord, nullptr, 16); if (!(val & (1ULL << KEY_A))) { goto skipDevice; } @@ -100,5 +100,5 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { ffStrbufDestroy(&device.serial); } - return NULL; + return nullptr; } diff --git a/src/detection/keyboard/keyboard_windows.c b/src/detection/keyboard/keyboard_windows.c index 272f632e5..8dc1fc41e 100644 --- a/src/detection/keyboard/keyboard_windows.c +++ b/src/detection/keyboard/keyboard_windows.c @@ -12,8 +12,8 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { UINT nDevices = 0; - if (GetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST))) { - return "GetRawInputDeviceList(NULL) failed"; + if (GetRawInputDeviceList(nullptr, &nDevices, sizeof(RAWINPUTDEVICELIST))) { + return "GetRawInputDeviceList(nullptr) failed"; } if (nDevices == 0) { return "No HID devices found"; @@ -49,7 +49,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { wchar_t buffer[MAX_PATH]; - HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, 0 /* must be 0 instead of GENERIC_READ */, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, 0 /* must be 0 instead of GENERIC_READ */, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (hHidFile != INVALID_HANDLE_VALUE) { if (HidD_GetProductString(hHidFile, buffer, (ULONG) sizeof(buffer))) { ffStrbufSetWS(&device->name, buffer); @@ -81,5 +81,5 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { } } - return NULL; + return nullptr; } diff --git a/src/detection/libc/libc_android.c b/src/detection/libc/libc_android.c index 9d7762c78..14f4ab1ba 100644 --- a/src/detection/libc/libc_android.c +++ b/src/detection/libc/libc_android.c @@ -15,7 +15,7 @@ const char* ffDetectLibc(FFLibcResult* result) { #endif ; - return NULL; + return nullptr; #else return "Unknown Android libc"; #endif diff --git a/src/detection/libc/libc_apple.c b/src/detection/libc/libc_apple.c index 07ca2b5a8..51b8d1d5c 100644 --- a/src/detection/libc/libc_apple.c +++ b/src/detection/libc/libc_apple.c @@ -6,7 +6,7 @@ const char* ffDetectLibc(FFLibcResult* result) { #ifdef FF_LIBSYSTEM_VERSION result->version = FF_LIBSYSTEM_VERSION; #else - result->version = NULL; + result->version = nullptr; #endif - return NULL; + return nullptr; } diff --git a/src/detection/libc/libc_bsd.c b/src/detection/libc/libc_bsd.c index bd73165c0..de5176acf 100644 --- a/src/detection/libc/libc_bsd.c +++ b/src/detection/libc/libc_bsd.c @@ -2,7 +2,7 @@ const char* ffDetectLibc(FFLibcResult* result) { result->name = "Unknown"; - result->version = NULL; + result->version = nullptr; #ifdef __DragonFly__ // We define `__FreeBSD__` on DragonFly BSD for simplification result->name = "DF"; @@ -16,5 +16,5 @@ const char* ffDetectLibc(FFLibcResult* result) { #endif #endif - return NULL; + return nullptr; } diff --git a/src/detection/libc/libc_linux.c b/src/detection/libc/libc_linux.c index a445c7b9b..358b717eb 100644 --- a/src/detection/libc/libc_linux.c +++ b/src/detection/libc/libc_linux.c @@ -15,9 +15,9 @@ const char* ffDetectLibc(FFLibcResult* result) { #ifdef FF_MUSL_VERSION result->version = FF_MUSL_VERSION; #else - result->version = NULL; + result->version = nullptr; #endif #endif - return NULL; + return nullptr; } diff --git a/src/detection/libc/libc_nosupport.c b/src/detection/libc/libc_nosupport.c index e4687b072..9aacd5947 100644 --- a/src/detection/libc/libc_nosupport.c +++ b/src/detection/libc/libc_nosupport.c @@ -2,6 +2,6 @@ const char* ffDetectLibc(FFLibcResult* result) { result->name = "Unknown"; - result->version = NULL; - return NULL; + result->version = nullptr; + return nullptr; } diff --git a/src/detection/libc/libc_windows.cpp b/src/detection/libc/libc_windows.cpp index c94062a4b..20bbeda00 100644 --- a/src/detection/libc/libc_windows.cpp +++ b/src/detection/libc/libc_windows.cpp @@ -64,5 +64,5 @@ extern "C" const char* ffDetectLibc(FFLibcResult* result) { #endif result->version = version<(__MSVCRT_VERSION__ >> 8), (__MSVCRT_VERSION__ & 8)>; - return NULL; + return nullptr; } diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index 140205d31..fbce9e0ee 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -10,9 +10,9 @@ #define FF_SYSTEMD_USERS_PATH "/run/systemd/users/" static const char* getGdmVersion(FFstrbuf* version) { - const char* error = ffProcessAppendStdOut(version, (char* const[]) { "gdm", "--version", NULL }); + const char* error = ffProcessAppendStdOut(version, (char* const[]) { "gdm", "--version", nullptr }); if (error || version->length == 0) { - error = ffProcessAppendStdOut(version, (char* const[]) { "gdm3", "--version", NULL }); + error = ffProcessAppendStdOut(version, (char* const[]) { "gdm3", "--version", nullptr }); if (error || version->length == 0) { return "Failed to get GDM version"; } @@ -20,11 +20,11 @@ static const char* getGdmVersion(FFstrbuf* version) { // GDM 44.1 ffStrbufSubstrAfterFirstC(version, ' '); - return NULL; + return nullptr; } static const char* getSshdVersion(FFstrbuf* version) { - const char* error = ffProcessAppendStdErr(version, (char* const[]) { "sshd", "-V", NULL }); + const char* error = ffProcessAppendStdErr(version, (char* const[]) { "sshd", "-V", nullptr }); if (error) { return error; } @@ -32,7 +32,7 @@ static const char* getSshdVersion(FFstrbuf* version) { // OpenSSH_9.0p1, OpenSSL 3.0.9 30 May 2023... ffStrbufSubstrBeforeFirstC(version, ','); ffStrbufSubstrAfterFirstC(version, '_'); - return NULL; + return nullptr; } #ifdef FF_HAVE_ZLIB @@ -78,7 +78,7 @@ static const char* getSddmVersion(FFstrbuf* version) { ffStrbufTrimRight(version, '"'); ffStrbufSubstrAfterLastC(version, ' '); - return NULL; + return nullptr; } #else static const char* getSddmVersion(FF_A_UNUSED FFstrbuf* version) { @@ -87,7 +87,7 @@ static const char* getSddmVersion(FF_A_UNUSED FFstrbuf* version) { #endif static const char* getXfwmVersion(FFstrbuf* version) { - const char* error = ffProcessAppendStdOut(version, (char* const[]) { "xfwm4", "--version", NULL }); + const char* error = ffProcessAppendStdOut(version, (char* const[]) { "xfwm4", "--version", nullptr }); if (error) { return error; } @@ -96,11 +96,11 @@ static const char* getXfwmVersion(FFstrbuf* version) { ffStrbufSubstrAfterFirstS(version, "version "); ffStrbufSubstrBeforeFirstC(version, ' '); - return NULL; + return nullptr; } static const char* getLightdmVersion(FFstrbuf* version) { - const char* error = ffProcessAppendStdErr(version, (char* const[]) { "lightdm", "--version", NULL }); + const char* error = ffProcessAppendStdErr(version, (char* const[]) { "lightdm", "--version", nullptr }); if (error) { return error; } @@ -109,7 +109,7 @@ static const char* getLightdmVersion(FFstrbuf* version) { ffStrbufSubstrAfterFirstC(version, ' '); ffStrbufTrimRight(version, '\n'); - return NULL; + return nullptr; } const char* ffDetectLM(FFLMResult* result) { @@ -164,5 +164,5 @@ const char* ffDetectLM(FFLMResult* result) { ffStrbufSetS(&result->type, FF_WM_PROTOCOL_TTY); } - return NULL; + return nullptr; } diff --git a/src/detection/loadavg/loadavg_bsd.c b/src/detection/loadavg/loadavg_bsd.c index 83896b299..7ef95ed77 100644 --- a/src/detection/loadavg/loadavg_bsd.c +++ b/src/detection/loadavg/loadavg_bsd.c @@ -13,11 +13,11 @@ const char* ffDetectLoadavg(double result[3]) { struct loadavg load; size_t size = sizeof(load); - if (sysctl((int[]) { CTL_VM, VM_LOADAVG }, 2, &load, &size, NULL, 0) < 0) { + if (sysctl((int[]) { CTL_VM, VM_LOADAVG }, 2, &load, &size, nullptr, 0) < 0) { return "sysctl({CTL_VM, VM_LOADAVG}) failed"; } for (int i = 0; i < 3; i++) { result[i] = (double) load.ldavg[i] / (double) load.fscale; } - return NULL; + return nullptr; } diff --git a/src/detection/loadavg/loadavg_linux.c b/src/detection/loadavg/loadavg_linux.c index a1693123f..ab4c7373f 100644 --- a/src/detection/loadavg/loadavg_linux.c +++ b/src/detection/loadavg/loadavg_linux.c @@ -13,7 +13,7 @@ const char* ffDetectLoadavg(double result[3]) { buf[nRead] = '\0'; if (sscanf(buf, "%lf%lf%lf", &result[0], &result[1], &result[2]) == 3) { - return NULL; + return nullptr; } } @@ -29,5 +29,5 @@ const char* ffDetectLoadavg(double result[3]) { result[i] = (double) si.loads[i] / (1 << SI_LOAD_SHIFT); } #endif - return NULL; + return nullptr; } diff --git a/src/detection/loadavg/loadavg_sunos.c b/src/detection/loadavg/loadavg_sunos.c index 91e3edd73..7cf63eec6 100644 --- a/src/detection/loadavg/loadavg_sunos.c +++ b/src/detection/loadavg/loadavg_sunos.c @@ -3,5 +3,5 @@ #include const char* ffDetectLoadavg(double result[3]) { - return getloadavg(result, 3) == 3 ? NULL : "getloadavg() failed"; + return getloadavg(result, 3) == 3 ? nullptr : "getloadavg() failed"; } diff --git a/src/detection/locale/locale_linux.c b/src/detection/locale/locale_linux.c index 4c04f26eb..ab630a7a3 100644 --- a/src/detection/locale/locale_linux.c +++ b/src/detection/locale/locale_linux.c @@ -5,17 +5,17 @@ const char* ffDetectLocale(FFstrbuf* result) { ffStrbufAppendS(result, getenv("LC_ALL")); if (result->length > 0) { - return NULL; + return nullptr; } ffStrbufAppendS(result, getenv("LANG")); if (result->length > 0) { - return NULL; + return nullptr; } - ffStrbufAppendS(result, setlocale(LC_TIME, NULL)); + ffStrbufAppendS(result, setlocale(LC_TIME, nullptr)); if (result->length > 0) { - return NULL; + return nullptr; } return "Failed to detect locale"; diff --git a/src/detection/locale/locale_windows.c b/src/detection/locale/locale_windows.c index b24736506..0f17e8bfa 100644 --- a/src/detection/locale/locale_windows.c +++ b/src/detection/locale/locale_windows.c @@ -12,5 +12,5 @@ const char* ffDetectLocale(FFstrbuf* result) { ffStrbufSetNWS(result, (uint32_t) size - 1, name); - return NULL; + return nullptr; } diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index d07ec7696..8ae6b244d 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -181,7 +181,7 @@ static FFLocalIpIpv6Type getIpv6Type(struct ifaddrs* ifa) { return result; } - char* line = NULL; + char* line = nullptr; size_t len = 0; while (ffStrbufGetline(&line, &len, &buffer)) { struct in6_addr* entry = FF_LIST_ADD(struct in6_addr, addresses); @@ -278,7 +278,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { options->showType, options->namePrefix.chars); - struct ifaddrs* ifAddrStruct = NULL; + struct ifaddrs* ifAddrStruct = nullptr; if (getifaddrs(&ifAddrStruct) < 0) { FF_DEBUG("getifaddrs() failed"); return "getifaddrs(&ifAddrStruct) failed"; @@ -335,7 +335,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { ifa->ifa_addr->sa_family, (unsigned long) ifa->ifa_flags); - FFAdapter* adapter = NULL; + FFAdapter* adapter = nullptr; FF_LIST_FOR_EACH (FFAdapter, x, adapters) { if (ffStrEquals(x->mac->ifa_name, ifa->ifa_name)) { adapter = x; @@ -425,7 +425,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { } if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)) { - struct ifaddrs* ifa = NULL; + struct ifaddrs* ifa = nullptr; if (isDefaultRouteIf && defaultRouteV4->preferredSourceAddrV4 != 0) { FF_LIST_FOR_EACH (struct ifaddrs*, pifa, adapter->ipv4) { struct sockaddr_in* ipv4 = (struct sockaddr_in*) (*pifa)->ifa_addr; @@ -468,8 +468,8 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { if (options->ipv6Type == FF_LOCALIP_IPV6_TYPE_AUTO) { if (!(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)) { - struct ifaddrs* selected = NULL; - struct ifaddrs* secondary = NULL; + struct ifaddrs* selected = nullptr; + struct ifaddrs* secondary = nullptr; FF_LIST_FOR_EACH (struct ifaddrs*, pifa, adapter->ipv6) { FFLocalIpIpv6Type type = getIpv6Type(*pifa); @@ -542,7 +542,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { if (ifAddrStruct) { freeifaddrs(ifAddrStruct); - ifAddrStruct = NULL; + ifAddrStruct = nullptr; FF_DEBUG("Cleaned up interface address structures"); } @@ -988,7 +988,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { continue; } if (ffStrbufEqualS(&iface->name, ks->ks_name)) { - if (kstat_read(kc, ks, NULL) >= 0) { + if (kstat_read(kc, ks, nullptr) >= 0) { kstat_named_t* ifspeed = (kstat_named_t*) kstat_data_lookup(ks, "ifspeed"); if (ifspeed) { iface->speed = (int32_t) (ifspeed->value.ui64 / 1000 / 1000); @@ -1007,5 +1007,5 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { } FF_DEBUG("Local IP detection completed, found %u interfaces", results->length); - return NULL; + return nullptr; } diff --git a/src/detection/localip/localip_windows.c b/src/detection/localip/localip_windows.c index 6a7e0e79b..ecb4159a0 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -30,7 +30,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { (int) options->namePrefix.length, options->namePrefix.chars); - IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = NULL; + IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = nullptr; // Multiple attempts in case interfaces change while // we are in the middle of querying them. @@ -51,7 +51,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { DWORD error = GetAdaptersAddresses( family, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, - NULL, + nullptr, adapter_addresses, &adapter_addresses_buffer_size); @@ -266,5 +266,5 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { processedCount, results->length); - return NULL; + return nullptr; } diff --git a/src/detection/media/media.c b/src/detection/media/media.c index 7adfb991b..2dfd28a61 100644 --- a/src/detection/media/media.c +++ b/src/detection/media/media.c @@ -13,7 +13,7 @@ static void removeMediaCoverFile(void) { } const FFMediaResult* ffDetectMedia(bool saveCover) { - if (result.error.chars == NULL) { + if (result.error.chars == nullptr) { ffStrbufInit(&result.error); ffStrbufInit(&result.playerId); ffStrbufInit(&result.player); diff --git a/src/detection/media/media_apple.m b/src/detection/media/media_apple.m index 6dcc78281..931c0b940 100644 --- a/src/detection/media/media_apple.m +++ b/src/detection/media/media_apple.m @@ -16,7 +16,7 @@ extern void MRMediaRemoteGetNowPlayingApplicationDisplayName(int unknown, dispat static uint32_t getTrueElapsedTime(CFDictionaryRef info) { double elapsedTime; - if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoElapsedTime"), &elapsedTime) != NULL) { + if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoElapsedTime"), &elapsedTime) != nullptr) { return 0; } @@ -24,8 +24,8 @@ static uint32_t getTrueElapsedTime(CFDictionaryRef info) { double playbackRate; uint64_t timestampEpoch; - if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoPlaybackRate"), &playbackRate) == NULL && - ffCfDictGetDateAsEpoch(info, CFSTR("kMRMediaRemoteNowPlayingInfoTimestamp"), ×tampEpoch) == NULL) { + if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoPlaybackRate"), &playbackRate) == nullptr && + ffCfDictGetDateAsEpoch(info, CFSTR("kMRMediaRemoteNowPlayingInfoTimestamp"), ×tampEpoch) == nullptr) { uint64_t timeDiff = ffTimeGetNow() - timestampEpoch; elapsedTime += (double) timeDiff * playbackRate; } @@ -44,14 +44,14 @@ static const char* getMediaByMediaRemote(FFMediaResult* result, bool saveCover) dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); dispatch_group_enter(group); - __block const char* error = NULL; + __block const char* error = nullptr; MRMediaRemoteGetNowPlayingInfo(queue, ^(_Nullable CFDictionaryRef info) { if (info != nil) { ffCfDictGetString(info, CFSTR("kMRMediaRemoteNowPlayingInfoTitle"), &result->song); ffCfDictGetString(info, CFSTR("kMRMediaRemoteNowPlayingInfoArtist"), &result->artist); ffCfDictGetString(info, CFSTR("kMRMediaRemoteNowPlayingInfoAlbum"), &result->album); double value; - if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoDuration"), &value) == NULL) { + if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoDuration"), &value) == nullptr) { result->length = (uint32_t) (value * 1000); result->position = getTrueElapsedTime(info); } @@ -62,7 +62,7 @@ static const char* getMediaByMediaRemote(FFMediaResult* result, bool saveCover) CFStringRef mime = (CFStringRef) CFDictionaryGetValue(info, CFSTR("kMRMediaRemoteNowPlayingInfoArtworkMIMEType")); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - FF_CFTYPE_AUTO_RELEASE CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mime, NULL); + FF_CFTYPE_AUTO_RELEASE CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mime, nullptr); FF_CFTYPE_AUTO_RELEASE CFStringRef ext = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassFilenameExtension); #pragma clang diagnostic pop NSString* tmpDir = NSTemporaryDirectory(); @@ -104,7 +104,7 @@ static const char* getMediaByMediaRemote(FFMediaResult* result, bool saveCover) // Don't dispatch_release because we are using ARC if (result->song.length > 0) { - return NULL; + return nullptr; } return error; @@ -121,7 +121,7 @@ __attribute__((visibility("default"), used)) int ffPrintMediaByMediaRemote(int s .player = ffStrbufCreate(), .cover = ffStrbufCreate(), }; - if (getMediaByMediaRemote(&media, !!saveCover) != NULL) { + if (getMediaByMediaRemote(&media, !!saveCover) != nullptr) { return 1; } ffStrbufAppendC(&media.status, '\n'); @@ -180,16 +180,16 @@ exit(fn(%c))", // status\ntitle\nartist\nalbum\nbundleName\nappName\ncoverPath\nelapsedTimeMS\ndurationMS FFstrbuf* const strList[] = { &result->status, &result->song, &result->artist, &result->album, &result->playerId, &result->player, &result->cover }; - char* line = NULL; + char* line = nullptr; size_t len = 0; for (uint32_t i = 0; i < ARRAY_SIZE(strList) && ffStrbufGetline(&line, &len, &buffer); ++i) { ffStrbufSetS(strList[i], line); } uint32_t* const numList[] = { &result->position, &result->length }; for (uint32_t i = 0; i < ARRAY_SIZE(numList) && ffStrbufGetline(&line, &len, &buffer); ++i) { - *numList[i] = (uint32_t) strtoul(line, NULL, 10); + *numList[i] = (uint32_t) strtoul(line, nullptr, 10); } - return NULL; + return nullptr; } void ffDetectMediaImpl(FFMediaResult* media, bool saveCover) { diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index 724e83484..dcd4a05f5 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -81,7 +81,7 @@ static bool parseMprisMetadata(FFDBusData* data, DBusMessageIter* rootIterator, break; } char str[] = { path.chars[i + 1], path.chars[i + 2], 0 }; - char* end = NULL; + char* end = nullptr; const char decodedChar = (char) strtoul(str, &end, 16); if (end == &str[2]) { i += 2; @@ -111,7 +111,7 @@ static bool parseMprisMetadata(FFDBusData* data, DBusMessageIter* rootIterator, static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResult* result) { // Get all properties at once to reduce the number of IPCs DBusMessage* reply = ffDBusGetAllProperties(data, busName, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player"); - if (reply == NULL) { + if (reply == nullptr) { return false; } @@ -166,7 +166,7 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul break; } char str[] = { fileName[1], fileName[2], 0 }; - ffStrbufAppendC(&result->song, (char) strtoul(str, NULL, 16)); + ffStrbufAppendC(&result->song, (char) strtoul(str, nullptr, 16)); fileName += 2; } } @@ -221,8 +221,8 @@ static void getBestBus(FFDBusData* data, FFMediaResult* result) { return; } - DBusMessage* reply = ffDBusGetMethodReply(data, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames", NULL, NULL); - if (reply == NULL) { + DBusMessage* reply = ffDBusGetMethodReply(data, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames", nullptr, nullptr); + if (reply == nullptr) { return; } @@ -260,7 +260,7 @@ static void getBestBus(FFDBusData* data, FFMediaResult* result) { static const char* getMedia(FFMediaResult* result) { FF_DBUS_AUTO_DESTROY_DATA FFDBusData data = {}; const char* error = ffDBusLoadData(DBUS_BUS_SESSION, &data); - if (error != NULL) { + if (error != nullptr) { return error; } @@ -272,7 +272,7 @@ static const char* getMedia(FFMediaResult* result) { getBestBus(&data, result); } - return NULL; + return nullptr; } #endif diff --git a/src/detection/media/media_windows.cpp b/src/detection/media/media_windows.cpp index f0ebd35f8..9cb4108a2 100644 --- a/src/detection/media/media_windows.cpp +++ b/src/detection/media/media_windows.cpp @@ -51,7 +51,7 @@ static inline HRESULT ffQueryInterface(SourceAbi* source, abi_t static HRESULT ffWaitForAsyncOperation(TOperationAbi* operation, TResultAbi** result) { - IAsyncInfo* FF_AUTO_RELEASE_COM_OBJECT asyncInfo = NULL; + IAsyncInfo* FF_AUTO_RELEASE_COM_OBJECT asyncInfo = nullptr; HRESULT hr = ffQueryInterface(operation, &asyncInfo); if (FAILED(hr)) { return hr; @@ -82,7 +82,7 @@ static HRESULT ffWaitForAsyncOperation(TOperationAbi* operation, TResultAbi** re template static HRESULT ffRunAndWait(TOperation&& operation, abi_t** result) { - abi_t>* FF_AUTO_RELEASE_COM_OBJECT opResult = NULL; + abi_t>* FF_AUTO_RELEASE_COM_OBJECT opResult = nullptr; HRESULT hr = operation(reinterpret_cast(&opResult)); if (FAILED(hr) || !opResult) { return hr; @@ -93,9 +93,9 @@ static HRESULT ffRunAndWait(TOperation&& operation, abi_t** r template static HRESULT ffRunAndWait2(TOperation&& operation, abi_t** result) { - *result = NULL; + *result = nullptr; - abi_t>* FF_AUTO_RELEASE_COM_OBJECT opResult = NULL; + abi_t>* FF_AUTO_RELEASE_COM_OBJECT opResult = nullptr; HRESULT hr = operation(reinterpret_cast(&opResult)); if (FAILED(hr) || !opResult) { return hr; @@ -107,7 +107,7 @@ static HRESULT ffRunAndWait2(TOperation&& operation, abi_t** static HRESULT ffSaveThumbnailToTempPath( abi_t* thumbnail, FFstrbuf* destination) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT contentStream = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT contentStream = nullptr; HRESULT hr = ffRunAndWait([=](void** result) { return thumbnail->OpenReadAsync(result); }, @@ -116,7 +116,7 @@ static HRESULT ffSaveThumbnailToTempPath( return FAILED(hr) ? hr : E_FAIL; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT randomAccessStream = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT randomAccessStream = nullptr; hr = ffQueryInterface(contentStream, &randomAccessStream); if (FAILED(hr)) { return hr; @@ -132,25 +132,25 @@ static HRESULT ffSaveThumbnailToTempPath( return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE); } - abi_t* FF_AUTO_RELEASE_COM_OBJECT bufferFactory = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT bufferFactory = nullptr; hr = ffGetActivationFactory(L"Windows.Storage.Streams.Buffer", winrt::guid_of(), &bufferFactory); if (FAILED(hr)) { return hr; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT buffer = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT buffer = nullptr; hr = bufferFactory->Create((UINT32) size, reinterpret_cast(&buffer)); if (FAILED(hr) || !buffer) { return FAILED(hr) ? hr : E_FAIL; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT inputStream = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT inputStream = nullptr; hr = ffQueryInterface(contentStream, &inputStream); if (FAILED(hr)) { return hr; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT readBuffer = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT readBuffer = nullptr; hr = ffRunAndWait2([=](void** result) { return inputStream->ReadAsync(buffer, (uint32_t) size, (uint32_t) winrt::Windows::Storage::Streams::InputStreamOptions::None, result); }, @@ -165,13 +165,13 @@ static HRESULT ffSaveThumbnailToTempPath( return FAILED(hr) ? hr : S_FALSE; } - Windows::Storage::Streams::IBufferByteAccess* FF_AUTO_RELEASE_COM_OBJECT byteAccess = NULL; + Windows::Storage::Streams::IBufferByteAccess* FF_AUTO_RELEASE_COM_OBJECT byteAccess = nullptr; hr = readBuffer->QueryInterface(IID_PPV_ARGS(&byteAccess)); if (FAILED(hr)) { return hr; } - byte* bytes = NULL; + byte* bytes = nullptr; hr = byteAccess->Buffer(&bytes); if (FAILED(hr) || !bytes) { return FAILED(hr) ? hr : E_FAIL; @@ -188,7 +188,7 @@ static HRESULT ffSaveThumbnailToTempPath( return HRESULT_FROM_WIN32(GetLastError()); } - HANDLE file = CreateFileW(tempFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFileW(tempFilePath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (file == INVALID_HANDLE_VALUE) { DWORD writeError = GetLastError(); DeleteFileW(tempFilePath); @@ -196,9 +196,9 @@ static HRESULT ffSaveThumbnailToTempPath( } DWORD written = 0; - BOOL writtenOk = WriteFile(file, bytes, length, &written, NULL); + BOOL writtenOk = WriteFile(file, bytes, length, &written, nullptr); NtClose(file); - file = NULL; + file = nullptr; if (!writtenOk || written != length) { DWORD writeError = GetLastError(); @@ -217,14 +217,14 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } do { - abi_t* FF_AUTO_RELEASE_COM_OBJECT managerStatics = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT managerStatics = nullptr; HRESULT hr = ffGetActivationFactory(L"Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager", winrt::guid_of(), &managerStatics); if (FAILED(hr) || !managerStatics) { error = "winrt: RoGetActivationFactory(GlobalSystemMediaTransportControlsSessionManager) failed"; break; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT manager = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT manager = nullptr; hr = ffRunAndWait([=](void** result) { return managerStatics->RequestAsync(result); }, @@ -234,11 +234,11 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { break; } - FF_A_CLEANUP(deleteHstring) HSTRING playerId = NULL; + FF_A_CLEANUP(deleteHstring) HSTRING playerId = nullptr; - abi_t* FF_AUTO_RELEASE_COM_OBJECT session = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT session = nullptr; if (instance.config.general.playerName.length) { - abi_t>* FF_AUTO_RELEASE_COM_OBJECT sessions = NULL; + abi_t>* FF_AUTO_RELEASE_COM_OBJECT sessions = nullptr; hr = manager->GetSessions(reinterpret_cast(&sessions)); if (FAILED(hr) || !sessions) { error = "winrt: GetSessions() failed"; @@ -251,7 +251,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { break; } for (uint32_t i = 0; i < sessionCount; i++) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT currentSession = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT currentSession = nullptr; hr = sessions->GetAt(i, reinterpret_cast(¤tSession)); if (FAILED(hr) || !currentSession) { continue; @@ -266,7 +266,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { if (ffStrbufContainIgnCase(&result->playerId, &instance.config.general.playerName)) { session = currentSession; - currentSession = NULL; // Don't release the session object + currentSession = nullptr; // Don't release the session object break; } deleteHstring(&playerId); @@ -294,7 +294,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { ffStrbufSetHstring(&result->playerId, playerId); } - abi_t* FF_AUTO_RELEASE_COM_OBJECT mediaProps = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT mediaProps = nullptr; hr = ffRunAndWait([=](void** result) { return session->TryGetMediaPropertiesAsync(result); }, @@ -304,7 +304,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { break; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT playbackInfo = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT playbackInfo = nullptr; hr = session->GetPlaybackInfo(reinterpret_cast(&playbackInfo)); bool isPlaying = false; double playbackRate = 1.0; @@ -327,7 +327,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } } - abi_t>* FF_AUTO_RELEASE_COM_OBJECT playbackRateRef = NULL; + abi_t>* FF_AUTO_RELEASE_COM_OBJECT playbackRateRef = nullptr; if (SUCCEEDED(playbackInfo->get_PlaybackRate(reinterpret_cast(&playbackRateRef))) && playbackRateRef) { if (SUCCEEDED(playbackRateRef->get_Value(&playbackRate)) && playbackRate < 0.0) { playbackRate = 0.0; @@ -335,22 +335,22 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } } - FF_A_CLEANUP(deleteHstring) HSTRING title = NULL; + FF_A_CLEANUP(deleteHstring) HSTRING title = nullptr; if (SUCCEEDED(mediaProps->get_Title(reinterpret_cast(&title)))) { ffStrbufSetHstring(&result->song, title); } - FF_A_CLEANUP(deleteHstring) HSTRING artist = NULL; + FF_A_CLEANUP(deleteHstring) HSTRING artist = nullptr; if (SUCCEEDED(mediaProps->get_Artist(reinterpret_cast(&artist)))) { ffStrbufSetHstring(&result->artist, artist); } - FF_A_CLEANUP(deleteHstring) HSTRING album = NULL; + FF_A_CLEANUP(deleteHstring) HSTRING album = nullptr; if (SUCCEEDED(mediaProps->get_AlbumTitle(reinterpret_cast(&album)))) { ffStrbufSetHstring(&result->album, album); } - abi_t* FF_AUTO_RELEASE_COM_OBJECT timelineProps = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT timelineProps = nullptr; hr = session->GetTimelineProperties(reinterpret_cast(&timelineProps)); if (SUCCEEDED(hr) && timelineProps) { int64_t duration = 0; @@ -373,14 +373,14 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } } - abi_t* FF_AUTO_RELEASE_COM_OBJECT appInfoStatics = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT appInfoStatics = nullptr; hr = ffGetActivationFactory(L"Windows.ApplicationModel.AppInfo", winrt::guid_of(), &appInfoStatics); if (SUCCEEDED(hr) && appInfoStatics) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT appInfo = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT appInfo = nullptr; if (SUCCEEDED(appInfoStatics->GetFromAppUserModelId(reinterpret_cast(playerId), reinterpret_cast(&appInfo))) && appInfo) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT displayInfo = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT displayInfo = nullptr; if (SUCCEEDED(appInfo->get_DisplayInfo(reinterpret_cast(&displayInfo))) && displayInfo) { - FF_A_CLEANUP(deleteHstring) HSTRING displayName = NULL; + FF_A_CLEANUP(deleteHstring) HSTRING displayName = nullptr; if (SUCCEEDED(displayInfo->get_DisplayName(reinterpret_cast(&displayName)))) { ffStrbufSetHstring(&result->player, displayName); } @@ -396,7 +396,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } if (saveCover) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT thumbnail = NULL; + abi_t* FF_AUTO_RELEASE_COM_OBJECT thumbnail = nullptr; hr = mediaProps->get_Thumbnail(reinterpret_cast(&thumbnail)); if (SUCCEEDED(hr) && thumbnail) { if (SUCCEEDED(ffSaveThumbnailToTempPath(thumbnail, &result->cover)) && result->cover.length > 0) { diff --git a/src/detection/memory/memory_apple.c b/src/detection/memory/memory_apple.c index 62039493e..b4f926467 100644 --- a/src/detection/memory/memory_apple.c +++ b/src/detection/memory/memory_apple.c @@ -10,11 +10,11 @@ const char* ffDetectMemory(FFMemoryResult* ram) { size_t length = sizeof(ram->bytesTotal); #if FF_APPLE_MEMSIZE_USABLE - if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, NULL, 0) != 0) { + if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, nullptr, 0) != 0) { return "Failed to read hw.memsize_usable"; } #else - if (sysctl((int[]) { CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0) != 0) { + if (sysctl((int[]) { CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, nullptr, 0) != 0) { return "Failed to read hw.memsize"; } #endif @@ -31,5 +31,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) { uint64_t pagesFileBacked = vmstat.external_page_count; // Cached files ram->bytesUsed = ram->bytesTotal - (pagesFree + pagesFileBacked) * instance.state.platform.sysinfo.pageSize; - return NULL; + return nullptr; } diff --git a/src/detection/memory/memory_bsd.c b/src/detection/memory/memory_bsd.c index 6deadd635..48f2948c3 100644 --- a/src/detection/memory/memory_bsd.c +++ b/src/detection/memory/memory_bsd.c @@ -3,7 +3,7 @@ const char* ffDetectMemory(FFMemoryResult* ram) { size_t length = sizeof(ram->bytesTotal); - if (sysctl((int[]) { CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0)) { + if (sysctl((int[]) { CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, nullptr, 0)) { return "Failed to read hw.physmem"; } @@ -19,5 +19,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) { ram->bytesUsed -= (uint64_t) bytesArc; } - return NULL; + return nullptr; } diff --git a/src/detection/memory/memory_haiku.c b/src/detection/memory/memory_haiku.c index 7888801ce..9bec865eb 100644 --- a/src/detection/memory/memory_haiku.c +++ b/src/detection/memory/memory_haiku.c @@ -12,5 +12,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) { ram->bytesTotal = pageSize * info.max_pages; ram->bytesUsed = pageSize * info.used_pages; - return NULL; + return nullptr; } diff --git a/src/detection/memory/memory_linux.c b/src/detection/memory/memory_linux.c index cd2c8989e..0a2ebd3fb 100644 --- a/src/detection/memory/memory_linux.c +++ b/src/detection/memory/memory_linux.c @@ -17,36 +17,36 @@ const char* ffDetectMemory(FFMemoryResult* ram) { cached = 0, sReclaimable = 0; - char* token = NULL; - if ((token = memmem(buf, (size_t) nRead, "MemTotal:", strlen("MemTotal:"))) != NULL) { - memTotal = (uint64_t) strtoull(token + strlen("MemTotal:"), NULL, 10); + char* token = nullptr; + if ((token = memmem(buf, (size_t) nRead, "MemTotal:", strlen("MemTotal:"))) != nullptr) { + memTotal = (uint64_t) strtoull(token + strlen("MemTotal:"), nullptr, 10); } else { return "MemTotal not found in /proc/meminfo"; } - if ((token = memmem(buf, (size_t) nRead, "MemAvailable:", strlen("MemAvailable:"))) != NULL) { - memAvailable = (uint64_t) strtoull(token + strlen("MemAvailable:"), NULL, 10); + if ((token = memmem(buf, (size_t) nRead, "MemAvailable:", strlen("MemAvailable:"))) != nullptr) { + memAvailable = (uint64_t) strtoull(token + strlen("MemAvailable:"), nullptr, 10); } if (memAvailable == 0 || memAvailable >= memTotal) { // MemAvailable can be unreasonable. #1988 - if ((token = memmem(buf, (size_t) nRead, "MemFree:", strlen("MemFree:"))) != NULL) { - memFree = (uint64_t) strtoull(token + strlen("MemFree:"), NULL, 10); + if ((token = memmem(buf, (size_t) nRead, "MemFree:", strlen("MemFree:"))) != nullptr) { + memFree = (uint64_t) strtoull(token + strlen("MemFree:"), nullptr, 10); } - if ((token = memmem(buf, (size_t) nRead, "Buffers:", strlen("Buffers:"))) != NULL) { - buffers = (uint64_t) strtoull(token + strlen("Buffers:"), NULL, 10); + if ((token = memmem(buf, (size_t) nRead, "Buffers:", strlen("Buffers:"))) != nullptr) { + buffers = (uint64_t) strtoull(token + strlen("Buffers:"), nullptr, 10); } - if ((token = memmem(buf, (size_t) nRead, "Cached:", strlen("Cached:"))) != NULL) { - cached = (uint64_t) strtoull(token + strlen("Cached:"), NULL, 10); + if ((token = memmem(buf, (size_t) nRead, "Cached:", strlen("Cached:"))) != nullptr) { + cached = (uint64_t) strtoull(token + strlen("Cached:"), nullptr, 10); } - if ((token = memmem(buf, (size_t) nRead, "Shmem:", strlen("Shmem:"))) != NULL) { - shmem = (uint64_t) strtoull(token + strlen("Shmem:"), NULL, 10); + if ((token = memmem(buf, (size_t) nRead, "Shmem:", strlen("Shmem:"))) != nullptr) { + shmem = (uint64_t) strtoull(token + strlen("Shmem:"), nullptr, 10); } - if ((token = memmem(buf, (size_t) nRead, "SReclaimable:", strlen("SReclaimable:"))) != NULL) { - sReclaimable = (uint64_t) strtoull(token + strlen("SReclaimable:"), NULL, 10); + if ((token = memmem(buf, (size_t) nRead, "SReclaimable:", strlen("SReclaimable:"))) != nullptr) { + sReclaimable = (uint64_t) strtoull(token + strlen("SReclaimable:"), nullptr, 10); } memAvailable = memFree + buffers + cached + sReclaimable - shmem; @@ -65,25 +65,25 @@ const char* ffDetectMemory(FFMemoryResult* ram) { // Skip first line const char* p = memchr(buf, '\n', (size_t) nRead); - if (__builtin_expect(p != NULL, true)) { + if (__builtin_expect(p != nullptr, true)) { ++p; nRead -= (p - buf); assert(nRead > 0); // Find line offset of data const char* pData = memmem(p, (size_t) nRead, "data\n", strlen("data\n")); - if (__builtin_expect(pData != NULL, true)) { + if (__builtin_expect(pData != nullptr, true)) { uint32_t dataOffset = (uint32_t) (pData - p); p += dataOffset + strlen("data\n"); nRead -= (ssize_t) (dataOffset + strlen("data\n")); assert(nRead > 0); - if ((token = memmem(p, (size_t) nRead, "\nsize ", strlen("\nsize "))) != NULL) { - arcSize = (uint64_t) strtoull(token + 1 + dataOffset, NULL, 10); + if ((token = memmem(p, (size_t) nRead, "\nsize ", strlen("\nsize "))) != nullptr) { + arcSize = (uint64_t) strtoull(token + 1 + dataOffset, nullptr, 10); if (arcSize > 0) { uint64_t arcMin = 0; - if ((token = memmem(p, (size_t) nRead, "\nc_min ", strlen("\nc_min "))) != NULL) { - arcMin = (uint64_t) strtoull(token + 1 + dataOffset, NULL, 10); + if ((token = memmem(p, (size_t) nRead, "\nc_min ", strlen("\nc_min "))) != nullptr) { + arcMin = (uint64_t) strtoull(token + 1 + dataOffset, nullptr, 10); if (arcSize > arcMin) { arcSize -= arcMin; if (ram->bytesUsed > arcSize) { @@ -97,5 +97,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) { } } - return NULL; + return nullptr; } diff --git a/src/detection/memory/memory_nbsd.c b/src/detection/memory/memory_nbsd.c index f7330ea31..5aa9353cf 100644 --- a/src/detection/memory/memory_nbsd.c +++ b/src/detection/memory/memory_nbsd.c @@ -7,7 +7,7 @@ const char* ffDetectMemory(FFMemoryResult* ram) { struct uvmexp_sysctl buf; size_t length = sizeof(buf); - if (sysctl((int[]) { CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, NULL, 0) < 0) { + if (sysctl((int[]) { CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, nullptr, 0) < 0) { return "sysctl(CTL_VM, VM_UVMEXP2) failed"; } @@ -20,5 +20,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) { ram->bytesUsed -= (uint64_t) bytesArc; } - return NULL; + return nullptr; } diff --git a/src/detection/memory/memory_obsd.c b/src/detection/memory/memory_obsd.c index c6da0877e..f53aeefdc 100644 --- a/src/detection/memory/memory_obsd.c +++ b/src/detection/memory/memory_obsd.c @@ -7,12 +7,12 @@ const char* ffDetectMemory(FFMemoryResult* ram) { struct uvmexp buf; size_t length = sizeof(buf); - if (sysctl((int[]) { CTL_VM, VM_UVMEXP }, 2, &buf, &length, NULL, 0) < 0) { + if (sysctl((int[]) { CTL_VM, VM_UVMEXP }, 2, &buf, &length, nullptr, 0) < 0) { return "sysctl(CTL_VM, VM_UVMEXP) failed"; } ram->bytesTotal = (uint64_t) buf.npages * instance.state.platform.sysinfo.pageSize; ram->bytesUsed = ((uint64_t) buf.active + (uint64_t) buf.inactive + (uint64_t) buf.wired) * instance.state.platform.sysinfo.pageSize; - return NULL; + return nullptr; } diff --git a/src/detection/memory/memory_sunos.c b/src/detection/memory/memory_sunos.c index 844ce9e24..68f4cb0fe 100644 --- a/src/detection/memory/memory_sunos.c +++ b/src/detection/memory/memory_sunos.c @@ -16,13 +16,13 @@ const char* ffDetectMemory(FFMemoryResult* ram) { ram->bytesUsed = ram->bytesTotal - (uint64_t) sysconf(_SC_AVPHYS_PAGES) * pageSize; FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); - if (kc != NULL) { + if (kc != nullptr) { kstat_t* ksp = kstat_lookup(kc, "zfs", -1, "arcstats"); - if (ksp != NULL && kstat_read(kc, ksp, NULL) != -1) { + if (ksp != nullptr && kstat_read(kc, ksp, nullptr) != -1) { kstat_named_t* kn_size = (kstat_named_t*) kstat_data_lookup(ksp, "size"); kstat_named_t* kn_cmin = (kstat_named_t*) kstat_data_lookup(ksp, "c_min"); - if (kn_size != NULL && kn_cmin != NULL && + if (kn_size != nullptr && kn_cmin != nullptr && kn_size->data_type == KSTAT_DATA_UINT64 && kn_cmin->data_type == KSTAT_DATA_UINT64) { uint64_t arcSize = kn_size->value.ui64; @@ -39,5 +39,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) { } } - return NULL; + return nullptr; } diff --git a/src/detection/memory/memory_windows.c b/src/detection/memory/memory_windows.c index 779425d55..da689621d 100644 --- a/src/detection/memory/memory_windows.c +++ b/src/detection/memory/memory_windows.c @@ -15,5 +15,5 @@ const char* ffDetectMemory(FFMemoryResult* ram) { ram->bytesTotal = statex.ullTotalPhys; ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys; - return NULL; + return nullptr; } diff --git a/src/detection/mouse/mouse_apple.c b/src/detection/mouse/mouse_apple.c index 2c5b2d7e3..a2035b564 100644 --- a/src/detection/mouse/mouse_apple.c +++ b/src/detection/mouse/mouse_apple.c @@ -32,5 +32,5 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { } IOHIDManagerClose(manager, kIOHIDOptionsTypeNone); - return NULL; + return nullptr; } diff --git a/src/detection/mouse/mouse_bsd.c b/src/detection/mouse/mouse_bsd.c index da7783b0b..065fda2be 100644 --- a/src/detection/mouse/mouse_bsd.c +++ b/src/detection/mouse/mouse_bsd.c @@ -52,5 +52,5 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { hid_dispose_report_desc(repDesc); } - return NULL; + return nullptr; } diff --git a/src/detection/mouse/mouse_haiku.cpp b/src/detection/mouse/mouse_haiku.cpp index 5835c8ec2..70a4533c3 100644 --- a/src/detection/mouse/mouse_haiku.cpp +++ b/src/detection/mouse/mouse_haiku.cpp @@ -23,5 +23,5 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { ffStrbufInitS(&item->name, device->Name()); } - return NULL; + return nullptr; } diff --git a/src/detection/mouse/mouse_linux.c b/src/detection/mouse/mouse_linux.c index 939c332a1..4c66fc513 100644 --- a/src/detection/mouse/mouse_linux.c +++ b/src/detection/mouse/mouse_linux.c @@ -4,15 +4,15 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/input/"); - if (dirp == NULL) { - return "opendir(\"/sys/class/input/\") == NULL"; + if (dirp == nullptr) { + return "opendir(\"/sys/class/input/\") == nullptr"; } FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/class/input/"); uint32_t baseLen = path.length; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (!ffStrStartsWith(entry->d_name, "mouse")) { continue; } @@ -41,5 +41,5 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { ffStrbufSubstrBefore(&path, baseLen); } - return NULL; + return nullptr; } diff --git a/src/detection/mouse/mouse_windows.c b/src/detection/mouse/mouse_windows.c index 3f2370a9a..0b068cb6c 100644 --- a/src/detection/mouse/mouse_windows.c +++ b/src/detection/mouse/mouse_windows.c @@ -12,8 +12,8 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { UINT nDevices = 0; - if (GetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST))) { - return "GetRawInputDeviceList(NULL) failed"; + if (GetRawInputDeviceList(nullptr, &nDevices, sizeof(RAWINPUTDEVICELIST))) { + return "GetRawInputDeviceList(nullptr) failed"; } if (nDevices == 0) { return "No HID devices found"; @@ -48,7 +48,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { wchar_t buffer[MAX_PATH]; - HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, 0 /* must be 0 instead of GENERIC_READ */, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, 0 /* must be 0 instead of GENERIC_READ */, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (hHidFile != INVALID_HANDLE_VALUE) { if (HidD_GetProductString(hHidFile, buffer, (ULONG) sizeof(buffer))) { ffStrbufSetWS(&device->name, buffer); @@ -80,5 +80,5 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { } } - return NULL; + return nullptr; } diff --git a/src/detection/netio/netio.c b/src/detection/netio/netio.c index c6b9da61b..a6348265b 100644 --- a/src/detection/netio/netio.c +++ b/src/detection/netio/netio.c @@ -20,14 +20,14 @@ void ffPrepareNetIO(FFNetIOOptions* options) { } const char* ffDetectNetIO(FFlist* result, FFNetIOOptions* options) { - const char* error = NULL; + const char* error = nullptr; if (options->detectTotal) { error = ffNetIOGetIoCounters(result, options); if (error) { return error; } - return NULL; + return nullptr; } if (time1 == 0) { @@ -77,5 +77,5 @@ const char* ffDetectNetIO(FFlist* result, FFNetIOOptions* options) { } time1 = time2; - return NULL; + return nullptr; } diff --git a/src/detection/netio/netio_apple.c b/src/detection/netio/netio_apple.c index 125cfd90c..1ab2c5774 100644 --- a/src/detection/netio/netio_apple.c +++ b/src/detection/netio/netio_apple.c @@ -11,8 +11,8 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { int mib[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, options->defaultRouteOnly ? IFMIB_IFDATA : IFMIB_IFALLDATA, options->defaultRouteOnly ? (int) ffNetifGetDefaultRouteV4()->ifIndex : 0, IFDATA_GENERAL }; size_t bufSize = 0; - if (sysctl(mib, ARRAY_SIZE(mib), NULL, &bufSize, 0, 0) < 0) { - return "sysctl(mib, ARRAY_SIZE(mib), NULL, &bufSize, 0, 0) failed"; + if (sysctl(mib, ARRAY_SIZE(mib), nullptr, &bufSize, 0, 0) < 0) { + return "sysctl(mib, ARRAY_SIZE(mib), nullptr, &bufSize, 0, 0) failed"; } assert(bufSize % sizeof(struct ifmibdata) == 0); @@ -51,5 +51,5 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { }; } - return NULL; + return nullptr; } diff --git a/src/detection/netio/netio_bsd.c b/src/detection/netio/netio_bsd.c index 83c1b6ba0..2641dd249 100644 --- a/src/detection/netio/netio_bsd.c +++ b/src/detection/netio/netio_bsd.c @@ -14,8 +14,8 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { uint32_t defaultRouteIfIndex = ffNetifGetDefaultRouteV4()->ifIndex; size_t bufSize = 0; - if (sysctl((int[]) { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, (options->defaultRouteOnly ? (int) defaultRouteIfIndex : 0) }, 6, NULL, &bufSize, 0, 0) < 0) { - return "sysctl({ CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, ifIndex }, 6, NULL, &bufSize, 0, 0) failed"; + if (sysctl((int[]) { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, (options->defaultRouteOnly ? (int) defaultRouteIfIndex : 0) }, 6, nullptr, &bufSize, 0, 0) < 0) { + return "sysctl({ CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, ifIndex }, 6, nullptr, &bufSize, 0, 0) failed"; } FF_AUTO_FREE struct if_msghdr* buf = (struct if_msghdr*) malloc(bufSize); @@ -58,5 +58,5 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { }; } - return NULL; + return nullptr; } diff --git a/src/detection/netio/netio_haiku.cpp b/src/detection/netio/netio_haiku.cpp index 88a123d1d..6ab15e342 100644 --- a/src/detection/netio/netio_haiku.cpp +++ b/src/detection/netio/netio_haiku.cpp @@ -48,5 +48,5 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { }; } - return NULL; + return nullptr; } diff --git a/src/detection/netio/netio_linux.c b/src/detection/netio/netio_linux.c index 5870d3f43..4e5c8d61b 100644 --- a/src/detection/netio/netio_linux.c +++ b/src/detection/netio/netio_linux.c @@ -58,7 +58,7 @@ static void getData(FFstrbuf* buffer, const char* ifName, bool isDefaultRoute, i const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/net"); if (!dirp) { - return "opendir(\"/sys/class/net\") == NULL"; + return "opendir(\"/sys/class/net\") == nullptr"; } FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); @@ -67,13 +67,13 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { if (options->defaultRouteOnly) { if (options->namePrefix.length && strncmp(defaultRouteIfName, options->namePrefix.chars, options->namePrefix.length) != 0) { - return NULL; + return nullptr; } getData(&buffer, defaultRouteIfName, true, dirfd(dirp), result); } else { struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { const char* ifName = entry->d_name; if (ifName[0] == '.') { continue; @@ -87,5 +87,5 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { } } - return NULL; + return nullptr; } diff --git a/src/detection/netio/netio_sunos.c b/src/detection/netio/netio_sunos.c index 3789e4528..19562c880 100644 --- a/src/detection/netio/netio_sunos.c +++ b/src/detection/netio/netio_sunos.c @@ -33,7 +33,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { continue; } - if (kstat_read(kc, ks, NULL) < 0) { + if (kstat_read(kc, ks, nullptr) < 0) { continue; } @@ -64,5 +64,5 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { } } - return NULL; + return nullptr; } diff --git a/src/detection/netio/netio_windows.c b/src/detection/netio/netio_windows.c index 3c6433425..ebaca3e6f 100644 --- a/src/detection/netio/netio_windows.c +++ b/src/detection/netio/netio_windows.c @@ -8,7 +8,7 @@ #include const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { - IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = NULL; + IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = nullptr; // Multiple attempts in case interfaces change while // we are in the middle of querying them. @@ -22,7 +22,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { DWORD error = GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, - NULL, + nullptr, adapter_addresses, &adapter_addresses_buffer_size); @@ -67,5 +67,5 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { } } - return NULL; + return nullptr; } diff --git a/src/detection/opencl/opencl.c b/src/detection/opencl/opencl.c index 74f8f6144..5bb195ec3 100644 --- a/src/detection/opencl/opencl.c +++ b/src/detection/opencl/opencl.c @@ -53,7 +53,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { char buffer[1024]; for (cl_uint iplat = 0; iplat < numPlatforms; ++iplat) { - if (data->ffclGetPlatformInfo(platforms[iplat], CL_PLATFORM_VERSION, sizeof(buffer), buffer, NULL) != CL_SUCCESS) { + if (data->ffclGetPlatformInfo(platforms[iplat], CL_PLATFORM_VERSION, sizeof(buffer), buffer, nullptr) != CL_SUCCESS) { return "clGetPlatformInfo() failed"; } @@ -66,11 +66,11 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { ffStrbufSetS(&result->version, versionPretty); ffStrbufTrim(&result->version, ' '); - if (data->ffclGetPlatformInfo(platforms[iplat], CL_PLATFORM_NAME, sizeof(buffer), buffer, NULL) == CL_SUCCESS) { + if (data->ffclGetPlatformInfo(platforms[iplat], CL_PLATFORM_NAME, sizeof(buffer), buffer, nullptr) == CL_SUCCESS) { ffStrbufSetS(&result->name, buffer); } - if (data->ffclGetPlatformInfo(platforms[iplat], CL_PLATFORM_VENDOR, sizeof(buffer), buffer, NULL) == CL_SUCCESS) { + if (data->ffclGetPlatformInfo(platforms[iplat], CL_PLATFORM_VENDOR, sizeof(buffer), buffer, nullptr) == CL_SUCCESS) { ffStrbufSetS(&result->vendor, buffer); } } @@ -83,7 +83,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { for (cl_uint idev = 0; idev < numDevices; ++idev) { cl_device_id deviceID = deviceIDs[idev]; - if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_NAME, sizeof(buffer), buffer, NULL) != CL_SUCCESS) { + if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_NAME, sizeof(buffer), buffer, nullptr) != CL_SUCCESS) { continue; } @@ -103,7 +103,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; gpu->pcieSpeed = FF_GPU_PCIE_SPEED_UNSET; - if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VERSION, sizeof(buffer), buffer, NULL) == CL_SUCCESS) { + if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VERSION, sizeof(buffer), buffer, nullptr) == CL_SUCCESS) { ffStrbufSetS(&gpu->platformApi, buffer); ffStrbufTrimRight(&gpu->platformApi, ' '); } else { @@ -112,15 +112,15 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { { cl_uint vendorId; - if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VENDOR_ID, sizeof(vendorId), &vendorId, NULL) == CL_SUCCESS) { + if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VENDOR_ID, sizeof(vendorId), &vendorId, nullptr) == CL_SUCCESS) { ffStrbufSetStatic(&gpu->vendor, ffGPUGetVendorString(vendorId)); } - if (gpu->vendor.length == 0 && data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VENDOR, sizeof(buffer), buffer, NULL) == CL_SUCCESS) { + if (gpu->vendor.length == 0 && data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VENDOR, sizeof(buffer), buffer, nullptr) == CL_SUCCESS) { ffStrbufSetS(&gpu->vendor, buffer); } } - if (data->ffclGetDeviceInfo(deviceID, CL_DRIVER_VERSION, sizeof(buffer), buffer, NULL) == CL_SUCCESS) { + if (data->ffclGetDeviceInfo(deviceID, CL_DRIVER_VERSION, sizeof(buffer), buffer, nullptr) == CL_SUCCESS) { const char* versionPretty = strchr(buffer, ' '); if (versionPretty && *versionPretty) { ffStrbufSetS(&gpu->driver, versionPretty + 1); @@ -131,25 +131,25 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { { cl_uint value; - if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(value), &value, NULL) == CL_SUCCESS) { + if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(value), &value, nullptr) == CL_SUCCESS) { gpu->coreCount = (int32_t) value; } } { cl_uint value; - if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(value), &value, NULL) == CL_SUCCESS) { + if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(value), &value, nullptr) == CL_SUCCESS) { gpu->frequency = value; } } { cl_bool value; - if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_HOST_UNIFIED_MEMORY, sizeof(value), &value, NULL) == CL_SUCCESS) { + if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_HOST_UNIFIED_MEMORY, sizeof(value), &value, nullptr) == CL_SUCCESS) { gpu->type = value ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; cl_ulong memSize; - if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(memSize), &memSize, NULL) == CL_SUCCESS) { + if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(memSize), &memSize, nullptr) == CL_SUCCESS) { if (gpu->type == FF_GPU_TYPE_INTEGRATED) { gpu->shared.total = memSize; } else { @@ -161,7 +161,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { } } - return NULL; + return nullptr; } static const char* detectOpenCL(FFOpenCLResult* result) { diff --git a/src/detection/opengl/opengl_apple.c b/src/detection/opengl/opengl_apple.c index 91285938d..f30710638 100644 --- a/src/detection/opengl/opengl_apple.c +++ b/src/detection/opengl/opengl_apple.c @@ -19,13 +19,13 @@ static const char* cglHandleContext(FFOpenGLResult* result, CGLContextObj contex CGLGetVersion(&major, &minor); ffStrbufSetF(&result->library, "CGL %d.%d", major, minor); - return NULL; + return nullptr; } static const char* cglHandlePixelFormat(FFOpenGLResult* result, CGLPixelFormatObj pixelFormat) { CGLContextObj context; - if (CGLCreateContext(pixelFormat, NULL, &context) != kCGLNoError) { + if (CGLCreateContext(pixelFormat, nullptr, &context) != kCGLNoError) { return "CGLCreateContext() failed"; } diff --git a/src/detection/opengl/opengl_haiku.cpp b/src/detection/opengl/opengl_haiku.cpp index 64a21a0d5..79d451301 100644 --- a/src/detection/opengl/opengl_haiku.cpp +++ b/src/detection/opengl/opengl_haiku.cpp @@ -20,7 +20,7 @@ static const char* oglDetectOpenGL(FFOpenGLResult* result) { } ffOpenGLHandleResult(result, ffglGetString); ffStrbufSetStatic(&result->library, "OpenGLKit"); - return NULL; + return nullptr; } const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) { diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index 5f88b7eb3..64cda0613 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -61,13 +61,13 @@ static const char* glxHandleContext(FFOpenGLResult* result, GLXData* data) { ffStrbufSetStatic(&result->library, "GLX"); } - return NULL; + return nullptr; } static const char* glxHandleGLXPixmap(FFOpenGLResult* result, GLXData* data) { - data->context = data->ffglXCreateContext(data->display, data->visualInfo, NULL, True); - if (data->context == NULL) { - return "glXCreateContext returned NULL"; + data->context = data->ffglXCreateContext(data->display, data->visualInfo, nullptr, True); + if (data->context == nullptr) { + return "glXCreateContext returned nullptr"; } const char* error = glxHandleContext(result, data); @@ -99,8 +99,8 @@ static const char* glxHandleVisualInfo(FFOpenGLResult* result, GLXData* data) { static const char* glxHandleDisplay(FFOpenGLResult* result, GLXData* data) { data->visualInfo = data->ffglXChooseVisual(data->display, DefaultScreen(data->display), (int[]) { None }); - if (data->visualInfo == NULL) { - return "glXChooseVisual returned NULL"; + if (data->visualInfo == nullptr) { + return "glXChooseVisual returned nullptr"; } const char* error = glxHandleVisualInfo(result, data); @@ -110,13 +110,13 @@ static const char* glxHandleDisplay(FFOpenGLResult* result, GLXData* data) { static const char* glxHandleData(FFOpenGLResult* result, GLXData* data) { data->ffglGetString = (__typeof__(data->ffglGetString)) data->ffglXGetProcAddress((const GLubyte*) "glGetString"); - if (data->ffglGetString == NULL) { - return "glXGetProcAddress(glGetString) returned NULL"; + if (data->ffglGetString == nullptr) { + return "glXGetProcAddress(glGetString) returned nullptr"; } - data->display = data->ffXOpenDisplay(NULL); - if (data->display == NULL) { - return "XOpenDisplay returned NULL"; + data->display = data->ffXOpenDisplay(nullptr); + if (data->display == nullptr) { + return "XOpenDisplay returned nullptr"; } const char* error = glxHandleDisplay(result, data); @@ -176,7 +176,7 @@ const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) { #endif } - const char* error = ""; // not NULL dummy value + const char* error = ""; // not nullptr dummy value #ifdef FF_HAVE_EGL const char* ffOpenGLDetectByEGL(FFOpenGLResult * result); @@ -184,7 +184,7 @@ const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) { #endif #ifdef FF_HAVE_GLX - if (error != NULL) { + if (error != nullptr) { error = detectByGlx(result); } #endif diff --git a/src/detection/opengl/opengl_shared.c b/src/detection/opengl/opengl_shared.c index c483879cb..027349d11 100644 --- a/src/detection/opengl/opengl_shared.c +++ b/src/detection/opengl/opengl_shared.c @@ -67,7 +67,7 @@ static const char* eglHandleContext(FFOpenGLResult* result, EGLData* data) { result->vendor.chars, result->slv.chars, result->library.chars); - return NULL; + return nullptr; } static const char* eglHandleSurface(FFOpenGLResult* result, EGLData* data, bool gles) { @@ -168,8 +168,8 @@ const char* ffOpenGLDetectByEGL(FFOpenGLResult* result) { FF_DEBUG("Resolving glGetString via eglGetProcAddress()"); eglData.ffglGetString = (__typeof__(&glGetString)) ffeglGetProcAddress("glGetString"); if (!eglData.ffglGetString) { - FF_DEBUG("eglGetProcAddress('glGetString') returned NULL"); - return "eglGetProcAddress(glGetString) returned NULL"; + FF_DEBUG("eglGetProcAddress('glGetString') returned nullptr"); + return "eglGetProcAddress(glGetString) returned nullptr"; } FF_DEBUG("Loaded EGL library and required symbols"); @@ -184,7 +184,7 @@ const char* ffOpenGLDetectByEGL(FFOpenGLResult* result) { } if (ffeglGetPlatformDisplay) { FF_DEBUG("Trying eglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA)"); - display = ffeglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA, EGL_DEFAULT_DISPLAY, NULL); + display = ffeglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA, EGL_DEFAULT_DISPLAY, nullptr); FF_DEBUG("eglGetPlatformDisplay() %s", display == EGL_NO_DISPLAY ? "failed" : "succeeded"); } else { FF_DEBUG("eglGetPlatformDisplay is unavailable, falling back to eglGetDisplay"); diff --git a/src/detection/opengl/opengl_windows.c b/src/detection/opengl/opengl_windows.c index 01bd98690..8f229d210 100644 --- a/src/detection/opengl/opengl_windows.c +++ b/src/detection/opengl/opengl_windows.c @@ -21,16 +21,16 @@ static const char* wglHandleContext(WGLData* wglData, FFOpenGLResult* result, HD } ffOpenGLHandleResult(result, wglData->ffglGetString); ffStrbufSetStatic(&result->library, "WGL 1.0"); - if (wglData->ffwglMakeCurrent(NULL, NULL) == FALSE) { - return "wglMakeCurrent(NULL, NULL) failed"; + if (wglData->ffwglMakeCurrent(nullptr, nullptr) == FALSE) { + return "wglMakeCurrent(nullptr, nullptr) failed"; } - return NULL; + return nullptr; } static const char* wglHandlePixelFormat(WGLData* wglData, FFOpenGLResult* result, HWND hWnd) { HDC hdc = GetDC(hWnd); - if (hdc == NULL) { + if (hdc == nullptr) { return "GetDC() failed"; } @@ -55,7 +55,7 @@ static const char* wglHandlePixelFormat(WGLData* wglData, FFOpenGLResult* result } HGLRC context = wglData->ffwglCreateContext(hdc); - if (context == NULL) { + if (context == nullptr) { ReleaseDC(hWnd, hdc); return "wglCreateContext() failed"; } @@ -91,7 +91,7 @@ static const char* wglDetectOpenGL(FFOpenGLResult* result) { return "RegisterClassW() failed"; } - HWND hWnd = CreateWindowW(wc.lpszClassName, L"ogl_version_check", 0, 0, 0, FF_OPENGL_BUFFER_WIDTH, FF_OPENGL_BUFFER_HEIGHT, NULL, NULL, hInstance, NULL); + HWND hWnd = CreateWindowW(wc.lpszClassName, L"ogl_version_check", 0, 0, 0, FF_OPENGL_BUFFER_WIDTH, FF_OPENGL_BUFFER_HEIGHT, nullptr, nullptr, hInstance, nullptr); if (!hWnd) { return "CreateWindowW() failed"; } diff --git a/src/detection/os/os.c b/src/detection/os/os.c index 7f66733bb..0690574e4 100644 --- a/src/detection/os/os.c +++ b/src/detection/os/os.c @@ -4,7 +4,7 @@ void ffDetectOSImpl(FFOSResult* os); const FFOSResult* ffDetectOS(void) { static FFOSResult result; - if (result.name.chars == NULL) { + if (result.name.chars == nullptr) { ffStrbufInit(&result.name); ffStrbufInit(&result.prettyName); ffStrbufInit(&result.id); diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 0c5d26362..5c5327c1d 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -82,8 +82,8 @@ FF_A_UNUSED static bool getUbuntuFlavour(FFOSResult* result) { ffStrbufClear(&result->version); if (ffProcessAppendStdOut(&result->version, (char* const[]) { "/usr/bin/lliurex-version", - NULL, - }) == NULL) { // 8.2.2 + nullptr, + }) == nullptr) { // 8.2.2 ffStrbufTrimRightSpace(&result->version); } ffStrbufSetF(&result->prettyName, "LliureX %s", result->version.chars); @@ -217,8 +217,8 @@ FF_A_UNUSED static bool detectDebianDerived(FFOSResult* result) { "--showformat=${version}", "--show", "pve-manager", - NULL, - }) == NULL) { // 8.2.2 + nullptr, + }) == nullptr) { // 8.2.2 ffStrbufTrimRightSpace(&result->versionID); ffStrbufSetStatic(&result->prettyName, "Proxmox VE "); ffStrbufAppend(&result->prettyName, &result->versionID); @@ -236,8 +236,8 @@ FF_A_UNUSED static bool detectDebianDerived(FFOSResult* result) { "--showformat=${version}", "--show", "proxmox-backup-server", - NULL, - }) == NULL) { + nullptr, + }) == nullptr) { ffStrbufTrimRightSpace(&result->versionID); ffStrbufSetStatic(&result->prettyName, "Proxmox Backup Server "); ffStrbufAppend(&result->prettyName, &result->versionID); diff --git a/src/detection/os/os_windows.c b/src/detection/os/os_windows.c index 2f280c842..e904616a0 100644 --- a/src/detection/os/os_windows.c +++ b/src/detection/os/os_windows.c @@ -8,14 +8,14 @@ PWSTR WINAPI BrandingFormatString(PCWSTR format); static bool getCodeName(FFOSResult* os) { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey, nullptr)) { return false; } - if (!ffRegReadStrbuf(hKey, L"DisplayVersion", &os->codename, NULL)) { - if (!ffRegReadStrbuf(hKey, L"CSDVersion", &os->codename, NULL)) { // For Windows 7 and Windows 8 - if (!ffRegReadStrbuf(hKey, L"ReleaseId", &os->codename, NULL)) { // For old Windows 10 + if (!ffRegReadStrbuf(hKey, L"DisplayVersion", &os->codename, nullptr)) { + if (!ffRegReadStrbuf(hKey, L"CSDVersion", &os->codename, nullptr)) { // For Windows 7 and Windows 8 + if (!ffRegReadStrbuf(hKey, L"ReleaseId", &os->codename, nullptr)) { // For old Windows 10 return false; } } @@ -39,9 +39,9 @@ void ffDetectOSImpl(FFOSResult* os) { if (os->variant.length == 0) // Windows PE? { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey, NULL)) { - ffRegReadStrbuf(hKey, L"ProductName", &os->variant, NULL); + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey, nullptr)) { + ffRegReadStrbuf(hKey, L"ProductName", &os->variant, nullptr); } } diff --git a/src/detection/packages/packages.c b/src/detection/packages/packages.c index 25f59b3e7..c72ea8757 100644 --- a/src/detection/packages/packages.c +++ b/src/detection/packages/packages.c @@ -18,7 +18,7 @@ const char* ffDetectPackages(FFPackagesResult* result, FFPackagesOptions* option result->all += ((uint32_t*) result)[i]; } - return NULL; + return nullptr; } bool ffPackagesReadCache(FFstrbuf* cacheDir, FFstrbuf* cacheContent, const char* filePath, const char* packageId, uint32_t* result) { @@ -36,7 +36,7 @@ bool ffPackagesReadCache(FFstrbuf* cacheDir, FFstrbuf* cacheContent, const char* uint64_t mtime_current = (uint64_t) st.st_mtim.tv_sec * 1000ull + (uint64_t) st.st_mtim.tv_nsec / 1000000ull; #else - FF_AUTO_CLOSE_FD HANDLE handle = CreateFileA(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + FF_AUTO_CLOSE_FD HANDLE handle = CreateFileA(filePath, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle == INVALID_HANDLE_VALUE) // file doesn't exist or isn't accessible { @@ -85,14 +85,14 @@ bool ffPackagesWriteCache(FFstrbuf* cacheDir, FFstrbuf* cacheContent, uint32_t n #ifndef _WIN32 uint32_t ffPackagesGetNumElements(const char* dirname, bool isdir) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir(dirname); - if (dirp == NULL) { + if (dirp == nullptr) { return 0; } uint32_t num_elements = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { bool ok = false; if (entry->d_name[0] != '.') { diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index ee4efbe4c..6d0a71616 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -23,7 +23,7 @@ static uint32_t getNumStringsImpl(const char* filename, const char* needle) { uint32_t count = 0; char* iter = content.chars; size_t needleLength = strlen(needle); - while ((iter = memmem(iter, content.length - (size_t) (iter - content.chars), needle, needleLength)) != NULL) { + while ((iter = memmem(iter, content.length - (size_t) (iter - content.chars), needle, needleLength)) != nullptr) { ++count; iter += needleLength; } @@ -85,7 +85,7 @@ static uint32_t countFilesRecursiveImpl(FFstrbuf* baseDirPath, const char* filen } FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDirPath->chars); - if (dirp == NULL) { + if (dirp == nullptr) { return 0; } @@ -95,7 +95,7 @@ static uint32_t countFilesRecursiveImpl(FFstrbuf* baseDirPath, const char* filen uint32_t sum = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { // According to the PMS, neither category nor package name can begin with '.', so no need to check for . or .. specifically if (entry->d_type != DT_DIR || entry->d_name[0] == '.') { continue; @@ -122,13 +122,13 @@ static uint32_t getNumElementsBySuffix(FFstrbuf* baseDir, const char* dirname, c ffStrbufAppendS(baseDir, dirname); FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars); ffStrbufSubstrBefore(baseDir, baseDirLength); - if (dirp == NULL) { + if (dirp == nullptr) { return 0; } uint32_t count = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] != '.' && ffStrEndsWithIgnCase(entry->d_name, suffix)) { ++count; } @@ -138,14 +138,14 @@ static uint32_t getNumElementsBySuffix(FFstrbuf* baseDir, const char* dirname, c static uint32_t getXBPSImpl(FFstrbuf* baseDir) { FF_AUTO_CLOSE_DIR DIR* dir = opendir(baseDir->chars); - if (dir == NULL) { + if (dir == nullptr) { return 0; } uint32_t result = 0; struct dirent* entry; - while ((entry = readdir(dir)) != NULL) { + while ((entry = readdir(dir)) != nullptr) { if (entry->d_type != DT_REG || !ffStrStartsWithIgnCase(entry->d_name, "pkgdb-")) { continue; } @@ -198,17 +198,17 @@ static uint32_t getRpmFromLibrpm(void) { // Don't print any error messages ffrpmlogSetMask(RPMLOG_MASK(RPMLOG_EMERG)); - if (ffrpmReadConfigFiles(NULL, NULL) != 0) { + if (ffrpmReadConfigFiles(nullptr, nullptr) != 0) { return 0; } rpmts ts = ffrpmtsCreate(); - if (ts == NULL) { + if (ts == nullptr) { return 0; } - rpmdbMatchIterator mi = ffrpmtsInitIterator(ts, RPMDBI_LABEL, NULL, 0); - if (mi == NULL) { + rpmdbMatchIterator mi = ffrpmtsInitIterator(ts, RPMDBI_LABEL, nullptr, 0); + if (mi == nullptr) { ffrpmtsFree(ts); return 0; } @@ -232,7 +232,7 @@ static uint32_t getAMPackages(FFstrbuf* baseDir) { uint32_t result = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -330,14 +330,14 @@ static uint32_t getGuixPackages(FFstrbuf* baseDir, const char* dirname) { static inline uint32_t getFlatpakRuntimePackagesArch(FFstrbuf* baseDir) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars); - if (dirp == NULL) { + if (dirp == nullptr) { return 0; } uint32_t num_elements = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_type == DT_DIR && entry->d_name[0] != '.') { num_elements += getNumElements(baseDir, entry->d_name, true); } @@ -349,7 +349,7 @@ static inline uint32_t getFlatpakRuntimePackagesArch(FFstrbuf* baseDir) { static inline uint32_t getFlatpakRuntimePackages(FFstrbuf* baseDir) { ffStrbufAppendS(baseDir, "runtime/"); FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars); - if (dirp == NULL) { + if (dirp == nullptr) { return 0; } @@ -357,7 +357,7 @@ static inline uint32_t getFlatpakRuntimePackages(FFstrbuf* baseDir) { uint32_t num_elements = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_type == DT_DIR && entry->d_name[0] != '.') { // `flatpak list` ignores `.Locale` and `.Debug` packages, and maybe others const char* dot = strrchr(entry->d_name, '.'); @@ -383,7 +383,7 @@ static inline uint32_t getFlatpakRuntimePackages(FFstrbuf* baseDir) { static inline uint32_t getFlatpakAppPackages(FFstrbuf* baseDir) { ffStrbufAppendS(baseDir, "app/"); FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars); - if (dirp == NULL) { + if (dirp == nullptr) { return 0; } @@ -391,7 +391,7 @@ static inline uint32_t getFlatpakAppPackages(FFstrbuf* baseDir) { uint32_t num_elements = 0; struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_type == DT_DIR && entry->d_name[0] != '.') { ffStrbufAppendS(baseDir, entry->d_name); ffStrbufAppendS(baseDir, "/current"); @@ -458,13 +458,13 @@ static uint32_t getPacmanPackages(FFstrbuf* baseDir) { static uint32_t getEmergePackagesImpl(FFstrbuf* baseDir) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars); - if (dirp == NULL) + if (dirp == nullptr) return 0; uint32_t result = 0; struct dirent *entry; - while ((entry = readdir(dirp)) != NULL) + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_type != DT_DIR || entry->d_name[0] == '.') continue; @@ -589,7 +589,7 @@ static void getPackageCountsBedrock(FFstrbuf* baseDir, FFPackagesResult* package ffStrbufAppendS(baseDir, "/bedrock/strata"); FF_AUTO_CLOSE_DIR DIR* dir = opendir(baseDir->chars); - if (dir == NULL) { + if (dir == nullptr) { ffStrbufSubstrBefore(baseDir, baseDirLength); return; } @@ -598,7 +598,7 @@ static void getPackageCountsBedrock(FFstrbuf* baseDir, FFPackagesResult* package uint32_t baseDirLength2 = baseDir->length; struct dirent* entry; - while ((entry = readdir(dir)) != NULL) { + while ((entry = readdir(dir)) != nullptr) { if (entry->d_type != DT_DIR) { continue; } @@ -620,8 +620,8 @@ static uint32_t getInstallReleasePackages(FFstrbuf* baseDir) { uint32_t baseDirLength = baseDir->length; ffStrbufAppendS(baseDir, ".config/install_release/state.json"); if (ffPathExists(baseDir->chars, FF_PATHTYPE_ANY)) { - yyjson_doc* doc = yyjson_read_file(baseDir->chars, YYJSON_READ_NOFLAG, NULL, NULL); - if (doc != NULL) { + yyjson_doc* doc = yyjson_read_file(baseDir->chars, YYJSON_READ_NOFLAG, nullptr, nullptr); + if (doc != nullptr) { yyjson_val* root = yyjson_doc_get_root(doc); if (yyjson_is_obj(root)) { result = (uint32_t) yyjson_obj_size(root); diff --git a/src/detection/packages/packages_nix.c b/src/detection/packages/packages_nix.c index d1cc2647e..cd2f6db29 100644 --- a/src/detection/packages/packages_nix.c +++ b/src/detection/packages/packages_nix.c @@ -101,7 +101,7 @@ static uint32_t getNixPackagesImpl(char* path) { FF_STRBUF_AUTO_DESTROY cacheHash = ffStrbufCreateA(64); uint32_t count = 0; - ffProcessAppendStdOut(&hash, (char* const[]) { "nix-store", "--query", "--hash", path, NULL }); + ffProcessAppendStdOut(&hash, (char* const[]) { "nix-store", "--query", "--hash", path, nullptr }); if (checkNixCache(&cacheDir, &cacheHash, &count) && ffStrbufEqual(&hash, &cacheHash)) { return count; @@ -115,7 +115,7 @@ static uint32_t getNixPackagesImpl(char* path) { FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(1024); - ffProcessAppendStdOut(&output, (char* const[]) { "nix-store", "--query", "--requisites", path, NULL }); + ffProcessAppendStdOut(&output, (char* const[]) { "nix-store", "--query", "--requisites", path, nullptr }); uint32_t lineLength = 0; for (uint32_t i = 0; i < output.length; i++) { diff --git a/src/detection/packages/packages_sunos.c b/src/detection/packages/packages_sunos.c index 16b8cd7cd..1aa1c60df 100644 --- a/src/detection/packages/packages_sunos.c +++ b/src/detection/packages/packages_sunos.c @@ -3,7 +3,7 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options) { if (FF_PACKAGES_IS_ENABLED(options, PKG)) { - yyjson_doc* doc = yyjson_read_file(FASTFETCH_TARGET_DIR_ROOT "/var/pkg/state/installed/catalog.attrs", YYJSON_READ_NOFLAG, NULL, NULL); + yyjson_doc* doc = yyjson_read_file(FASTFETCH_TARGET_DIR_ROOT "/var/pkg/state/installed/catalog.attrs", YYJSON_READ_NOFLAG, nullptr, nullptr); if (doc) { yyjson_val* packageCount = yyjson_obj_get(yyjson_doc_get_root(doc), "package-count"); if (packageCount) { diff --git a/src/detection/packages/packages_windows.c b/src/detection/packages/packages_windows.c index a3faee529..a2f54fb15 100644 --- a/src/detection/packages/packages_windows.c +++ b/src/detection/packages/packages_windows.c @@ -13,12 +13,12 @@ #include static uint32_t getNumElements(const char* searchPath, DWORD type, const wchar_t* ignore) { - FF_AUTO_CLOSE_FD HANDLE dfd = CreateFileA(searchPath, FILE_LIST_DIRECTORY | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + FF_AUTO_CLOSE_FD HANDLE dfd = CreateFileA(searchPath, FILE_LIST_DIRECTORY | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (dfd == INVALID_HANDLE_VALUE) { return 0; } - bool flag = ignore == NULL; + bool flag = ignore == nullptr; uint32_t counter = 0; alignas(8) uint8_t buffer[64 * 1024]; BOOLEAN firstScan = TRUE; @@ -29,15 +29,15 @@ static uint32_t getNumElements(const char* searchPath, DWORD type, const wchar_t IO_STATUS_BLOCK ioStatus = {}; NTSTATUS status = NtQueryDirectoryFile( dfd, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, &ioStatus, buffer, ARRAY_SIZE(buffer), FileDirectoryInformation, FALSE, - NULL, + nullptr, firstScan); firstScan = FALSE; @@ -90,13 +90,13 @@ static void detectScoop(FFPackagesResult* result) { ffStrbufAppend(&scoopPath, &instance.state.platform.homeDir); ffStrbufAppendS(&scoopPath, ".config/scoop/config.json"); - yyjson_val* root = NULL; + yyjson_val* root = nullptr; - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_file(scoopPath.chars, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_file(scoopPath.chars, 0, nullptr, nullptr); if (doc) { root = yyjson_doc_get_root(doc); if (!yyjson_is_obj(root)) { - root = NULL; + root = nullptr; } } @@ -119,8 +119,8 @@ static void detectScoop(FFPackagesResult* result) { ffStrbufSetJsonVal(&scoopPath, yyjson_obj_get(root, "global_path")); } if (scoopPath.length == 0) { - PWSTR pPath = NULL; - if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_ProgramData, KF_FLAG_DEFAULT, NULL, &pPath))) { + PWSTR pPath = nullptr; + if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_ProgramData, KF_FLAG_DEFAULT, nullptr, &pPath))) { ffStrbufSetWS(&scoopPath, pPath); CoTaskMemFree(pPath); } @@ -153,7 +153,7 @@ static void detectPacman(FFPackagesResult* result) { char pacmanPath[MAX_PATH + 3]; char* pend = ffStrCopy(pacmanPath, msystemPrefix, ARRAY_SIZE(pacmanPath)); ffStrCopy(pend, "/../var/lib/pacman/local/", ARRAY_SIZE(pacmanPath) - (size_t) (pend - pacmanPath)); - result->pacman = getNumElements(pacmanPath, FILE_ATTRIBUTE_DIRECTORY, NULL); + result->pacman = getNumElements(pacmanPath, FILE_ATTRIBUTE_DIRECTORY, nullptr); } static void detectWinget(FFPackagesResult* result) { @@ -162,7 +162,7 @@ static void detectWinget(FFPackagesResult* result) { "winget.exe", "list", "--disable-interactivity", - NULL, + nullptr, })) { return; } diff --git a/src/detection/physicaldisk/physicaldisk_apple.c b/src/detection/physicaldisk/physicaldisk_apple.c index f4c5cd6ca..624d49788 100644 --- a/src/detection/physicaldisk/physicaldisk_apple.c +++ b/src/detection/physicaldisk/physicaldisk_apple.c @@ -22,19 +22,19 @@ static inline void wrapIoDestroyPlugInInterface(IOCFPlugInInterface*** pluginInf static const char* detectSsdTemp(io_service_t entryPhysical, double* temp) { #ifdef MAC_OS_X_VERSION_10_15 - FF_A_CLEANUP(wrapIoDestroyPlugInInterface) IOCFPlugInInterface** pluginInf = NULL; + FF_A_CLEANUP(wrapIoDestroyPlugInInterface) IOCFPlugInInterface** pluginInf = nullptr; int32_t score; if (IOCreatePlugInInterfaceForService(entryPhysical, kIONVMeSMARTUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInf, &score) != kIOReturnSuccess) { return "IOCreatePlugInInterfaceForService() failed"; } - IONVMeSMARTInterface** smartInf = NULL; + IONVMeSMARTInterface** smartInf = nullptr; if ((*pluginInf)->QueryInterface(pluginInf, CFUUIDGetUUIDBytes(kIONVMeSMARTInterfaceID), (LPVOID) &smartInf) != kIOReturnSuccess) { return "QueryInterface() failed"; } NVMeSMARTData smartData; - const char* error = NULL; + const char* error = nullptr; if ((*smartInf)->SMARTReadData(smartInf, &smartData) == kIOReturnSuccess) { *temp = smartData.TEMPERATURE - 273; } else { @@ -76,14 +76,14 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) } if (deviceName.length == 0) { - FF_CFTYPE_AUTO_RELEASE CFDictionaryRef deviceCharacteristics = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyDeviceCharacteristicsKey), NULL, kNilOptions); + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef deviceCharacteristics = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyDeviceCharacteristicsKey), nullptr, kNilOptions); if (deviceCharacteristics) { - if (ffCfDictGetString(deviceCharacteristics, CFSTR(kIOPropertyVendorNameKey), &deviceName) == NULL && deviceName.length > 0) { + if (ffCfDictGetString(deviceCharacteristics, CFSTR(kIOPropertyVendorNameKey), &deviceName) == nullptr && deviceName.length > 0) { ffStrbufAppendC(&deviceName, ' '); } FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); - if (ffCfDictGetString(deviceCharacteristics, CFSTR(kIOPropertyProductNameKey), &name) == NULL) { + if (ffCfDictGetString(deviceCharacteristics, CFSTR(kIOPropertyProductNameKey), &name) == nullptr) { ffStrbufAppend(&deviceName, &name); } } @@ -96,9 +96,9 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) FFPhysicalDiskType type = FF_PHYSICALDISK_TYPE_NONE; FF_STRBUF_AUTO_DESTROY interconnect = ffStrbufCreate(); - FF_CFTYPE_AUTO_RELEASE CFDictionaryRef protocolCharacteristics = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyProtocolCharacteristicsKey), NULL, kNilOptions); + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef protocolCharacteristics = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyProtocolCharacteristicsKey), nullptr, kNilOptions); if (protocolCharacteristics) { - if (ffCfDictGetString(protocolCharacteristics, CFSTR(kIOPropertyPhysicalInterconnectTypeKey), &interconnect) == NULL) { + if (ffCfDictGetString(protocolCharacteristics, CFSTR(kIOPropertyPhysicalInterconnectTypeKey), &interconnect) == nullptr) { if (ffStrbufEqualS(&interconnect, kIOPropertyPhysicalInterconnectTypeVirtual)) { if (options->hideType & FF_PHYSICALDISK_TYPE_VIRTUAL) { continue; @@ -106,7 +106,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) type |= FF_PHYSICALDISK_TYPE_VIRTUAL; FF_STRBUF_AUTO_DESTROY location = ffStrbufCreate(); - if (ffCfDictGetString(protocolCharacteristics, CFSTR(kIOPropertyPhysicalInterconnectLocationKey), &location) == NULL) { + if (ffCfDictGetString(protocolCharacteristics, CFSTR(kIOPropertyPhysicalInterconnectLocationKey), &location) == nullptr) { ffStrbufAppendS(&interconnect, " - "); ffStrbufAppend(&interconnect, &location); } @@ -116,7 +116,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) uint64_t size = 0; if (entryMedia != IO_OBJECT_NULL) { - FF_CFTYPE_AUTO_RELEASE CFNumberRef mediaSize = IORegistryEntryCreateCFProperty(entryMedia, CFSTR(kIOMediaSizeKey), NULL, kNilOptions); + FF_CFTYPE_AUTO_RELEASE CFNumberRef mediaSize = IORegistryEntryCreateCFProperty(entryMedia, CFSTR(kIOMediaSizeKey), nullptr, kNilOptions); if (mediaSize) { ffCfNumGetInt64(mediaSize, (int64_t*) &size); } @@ -141,24 +141,24 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) device->temperature = FF_PHYSICALDISK_TEMP_UNSET; if (entryMedia != IO_OBJECT_NULL) { - FF_CFTYPE_AUTO_RELEASE CFBooleanRef removable = IORegistryEntryCreateCFProperty(entryMedia, CFSTR(kIOMediaRemovableKey), NULL, kNilOptions); + FF_CFTYPE_AUTO_RELEASE CFBooleanRef removable = IORegistryEntryCreateCFProperty(entryMedia, CFSTR(kIOMediaRemovableKey), nullptr, kNilOptions); if (removable) { device->type |= CFBooleanGetValue(removable) ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED; } - FF_CFTYPE_AUTO_RELEASE CFBooleanRef writable = IORegistryEntryCreateCFProperty(entryMedia, CFSTR(kIOMediaWritableKey), NULL, kNilOptions); + FF_CFTYPE_AUTO_RELEASE CFBooleanRef writable = IORegistryEntryCreateCFProperty(entryMedia, CFSTR(kIOMediaWritableKey), nullptr, kNilOptions); if (writable) { device->type |= CFBooleanGetValue(writable) ? FF_PHYSICALDISK_TYPE_READWRITE : FF_PHYSICALDISK_TYPE_READONLY; } - FF_CFTYPE_AUTO_RELEASE CFStringRef bsdName = IORegistryEntryCreateCFProperty(entryMedia, CFSTR(kIOBSDNameKey), NULL, kNilOptions); + FF_CFTYPE_AUTO_RELEASE CFStringRef bsdName = IORegistryEntryCreateCFProperty(entryMedia, CFSTR(kIOBSDNameKey), nullptr, kNilOptions); if (bsdName) { ffCfStrGetString(bsdName, &device->devPath); ffStrbufPrependS(&device->devPath, "/dev/"); } } - FF_CFTYPE_AUTO_RELEASE CFDictionaryRef deviceCharacteristics = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyDeviceCharacteristicsKey), NULL, kNilOptions); + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef deviceCharacteristics = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyDeviceCharacteristicsKey), nullptr, kNilOptions); if (deviceCharacteristics) { ffCfDictGetString(deviceCharacteristics, CFSTR(kIOPropertyProductSerialNumberKey), &device->serial); ffStrbufTrimSpace(&device->serial); @@ -179,7 +179,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) #ifdef MAC_OS_X_VERSION_10_15 if (!(device->type & FF_PHYSICALDISK_TYPE_VIRTUAL) && options->temp) { - FF_CFTYPE_AUTO_RELEASE CFBooleanRef nvmeSMARTCapable = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyNVMeSMARTCapableKey), NULL, kNilOptions); + FF_CFTYPE_AUTO_RELEASE CFBooleanRef nvmeSMARTCapable = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyNVMeSMARTCapableKey), nullptr, kNilOptions); if (nvmeSMARTCapable && CFBooleanGetValue(nvmeSMARTCapable)) { detectSsdTemp(entryPhysical, &device->temperature); } @@ -187,5 +187,5 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) #endif } - return NULL; + return nullptr; } diff --git a/src/detection/physicaldisk/physicaldisk_bsd.c b/src/detection/physicaldisk/physicaldisk_bsd.c index 5a877681f..cda7adda5 100644 --- a/src/detection/physicaldisk/physicaldisk_bsd.c +++ b/src/detection/physicaldisk/physicaldisk_bsd.c @@ -23,12 +23,12 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) void* snap = geom_stats_snapshot_get(); struct devstat* snapIter; - while ((snapIter = geom_stats_snapshot_next(snap)) != NULL) { + while ((snapIter = geom_stats_snapshot_next(snap)) != nullptr) { if (snapIter->device_type & DEVSTAT_TYPE_PASS) { continue; } struct gident* geomId = geom_lookupid(&geomTree, snapIter->id); - if (geomId == NULL) { + if (geomId == nullptr) { continue; } if (geomId->lg_what != ISPROVIDER) { @@ -118,7 +118,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) geom_stats_snapshot_free(snap); geom_stats_close(); - return NULL; + return nullptr; } #else const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) { diff --git a/src/detection/physicaldisk/physicaldisk_haiku.c b/src/detection/physicaldisk/physicaldisk_haiku.c index e44ddced1..d2b83fed2 100644 --- a/src/detection/physicaldisk/physicaldisk_haiku.c +++ b/src/detection/physicaldisk/physicaldisk_haiku.c @@ -77,7 +77,7 @@ static const char* searchRawDeviceFile(FFstrbuf* path, const char* diskType, FFl ffStrbufSubstrBefore(path, baseLen); } - return NULL; + return nullptr; } const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) { @@ -100,5 +100,5 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) ffStrbufSubstrBefore(&path, baseLen); } - return NULL; + return nullptr; } diff --git a/src/detection/physicaldisk/physicaldisk_linux.c b/src/detection/physicaldisk/physicaldisk_linux.c index f8126b96a..b6d4c755f 100644 --- a/src/detection/physicaldisk/physicaldisk_linux.c +++ b/src/detection/physicaldisk/physicaldisk_linux.c @@ -18,7 +18,7 @@ static double detectNvmeTemp(int devfd) { ssize_t size = ffReadFileDataRelative(devfd, pathHwmon, ARRAY_SIZE(buffer), buffer); if (size > 0) { buffer[size] = '\0'; - double temp = strtod(buffer, NULL); + double temp = strtod(buffer, nullptr); return temp > 0 && temp < 10000000 /*VMware*/ ? temp / 1000 : FF_PHYSICALDISK_TEMP_UNSET; } } @@ -34,7 +34,7 @@ static void parsePhysicalDisk(int dfd, const char* devName, FFPhysicalDiskOption ssize_t fileSize = ffReadFileDataRelative(dfd, "size", ARRAY_SIZE(blkSize) - 1, blkSize); if (fileSize > 0) { blkSize[fileSize] = 0; - size = (uint64_t) strtoul(blkSize, NULL, 10) * 512; + size = (uint64_t) strtoul(blkSize, nullptr, 10) * 512; } } @@ -118,15 +118,15 @@ static void parsePhysicalDisk(int dfd, const char* devName, FFPhysicalDiskOption snprintf(pathSysDeviceLink, ARRAY_SIZE(pathSysDeviceLink), "/sys/block/%s/device", devName); char pathSysDeviceReal[PATH_MAX]; if (realpath(pathSysDeviceLink, pathSysDeviceReal)) { - if (strstr(pathSysDeviceReal, "/usb") != NULL) { + if (strstr(pathSysDeviceReal, "/usb") != nullptr) { ffStrbufSetStatic(&device->interconnect, "USB"); - } else if (strstr(pathSysDeviceReal, "/ata") != NULL) { + } else if (strstr(pathSysDeviceReal, "/ata") != nullptr) { ffStrbufSetStatic(&device->interconnect, "ATA"); - } else if (strstr(pathSysDeviceReal, "/scsi") != NULL) { + } else if (strstr(pathSysDeviceReal, "/scsi") != nullptr) { ffStrbufSetStatic(&device->interconnect, "SCSI"); - } else if (strstr(pathSysDeviceReal, "/nvme") != NULL) { + } else if (strstr(pathSysDeviceReal, "/nvme") != nullptr) { ffStrbufSetStatic(&device->interconnect, "NVMe"); - } else if (strstr(pathSysDeviceReal, "/virtio") != NULL) { + } else if (strstr(pathSysDeviceReal, "/virtio") != nullptr) { ffStrbufSetStatic(&device->interconnect, "VirtIO"); isVirtio = true; // VirtIO devices are virtual, but we still want to report it } else { @@ -177,12 +177,12 @@ static void parsePhysicalDisk(int dfd, const char* devName, FFPhysicalDiskOption const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) { FF_AUTO_CLOSE_DIR DIR* sysBlockDirp = opendir("/sys/block/"); - if (sysBlockDirp == NULL) { - return "opendir(\"/sys/block/\") == NULL"; + if (sysBlockDirp == nullptr) { + return "opendir(\"/sys/block/\") == nullptr"; } struct dirent* sysBlockEntry; - while ((sysBlockEntry = readdir(sysBlockDirp)) != NULL) { + while ((sysBlockEntry = readdir(sysBlockDirp)) != nullptr) { const char* const devName = sysBlockEntry->d_name; if (devName[0] == '.') { @@ -198,5 +198,5 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) } } - return NULL; + return nullptr; } diff --git a/src/detection/physicaldisk/physicaldisk_nbsd.c b/src/detection/physicaldisk/physicaldisk_nbsd.c index 0733f3b5b..bf9bd3adb 100644 --- a/src/detection/physicaldisk/physicaldisk_nbsd.c +++ b/src/detection/physicaldisk/physicaldisk_nbsd.c @@ -122,7 +122,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) FF_DEBUG("Disk names: %s", diskNames.chars); - char* diskName = NULL; + char* diskName = nullptr; size_t len = 0; while (ffStrbufGetdelim(&diskName, &len, ' ', &diskNames)) { FF_DEBUG("Probing disk: %s", diskName); @@ -158,9 +158,9 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) unsigned long sectorsPerUnit, sectorSize; - const char* devType = NULL; + const char* devType = nullptr; - prop_dictionary_t dict = NULL; + prop_dictionary_t dict = nullptr; if (prop_dictionary_recv_ioctl(f, DIOCGDISKINFO, &dict) == 0) { FF_DEBUG("DIOCGDISKINFO succeeded for %s", diskName); prop_dictionary_get_string(dict, "type", &devType); @@ -228,7 +228,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) if (dict) { prop_object_release(dict); - dict = NULL; + dict = nullptr; } struct scsipi_inquiry_data inquiry = {}; @@ -320,5 +320,5 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) FF_DEBUG("Detected disk '%s' (%s), type=%u", device->name.chars, diskName, (unsigned) device->type); } - return NULL; + return nullptr; } diff --git a/src/detection/physicaldisk/physicaldisk_obsd.c b/src/detection/physicaldisk/physicaldisk_obsd.c index 6e89a9975..7b8680675 100644 --- a/src/detection/physicaldisk/physicaldisk_obsd.c +++ b/src/detection/physicaldisk/physicaldisk_obsd.c @@ -119,7 +119,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) FF_DEBUG("Disk names: %s", diskNames.chars); - char* diskName = NULL; + char* diskName = nullptr; size_t len = 0; while (ffStrbufGetdelim(&diskName, &len, ',', &diskNames)) { char* colon = strchr(diskName, ':'); @@ -138,7 +138,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) continue; } - char* devPath = NULL; + char* devPath = nullptr; FF_AUTO_CLOSE_FD int f = opendev(diskName, O_RDONLY, OPENDEV_PART, &devPath); if (f < 0) { if (errno == EACCES) { @@ -275,5 +275,5 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) FF_DEBUG("Detected disk '%s' (%s), type=%u", device->name.chars, diskName, (unsigned) device->type); } - return NULL; + return nullptr; } diff --git a/src/detection/physicaldisk/physicaldisk_sunos.c b/src/detection/physicaldisk/physicaldisk_sunos.c index d929d5a23..b65fba000 100644 --- a/src/detection/physicaldisk/physicaldisk_sunos.c +++ b/src/detection/physicaldisk/physicaldisk_sunos.c @@ -103,5 +103,5 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) di_walk_minor(rootNode, DDI_NT_BLOCK, DI_WALK_CLDFIRST, &(struct FFWalkTreeBundle) { options, result }, (void*) walkDevTree); di_fini(rootNode); - return NULL; + return nullptr; } diff --git a/src/detection/physicaldisk/physicaldisk_windows.c b/src/detection/physicaldisk/physicaldisk_windows.c index 5d4f7f743..c2c1979d8 100644 --- a/src/detection/physicaldisk/physicaldisk_windows.c +++ b/src/detection/physicaldisk/physicaldisk_windows.c @@ -10,7 +10,7 @@ #include static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* szDevice, FFlist* result, FFPhysicalDiskOptions* options) { - FF_AUTO_CLOSE_FD HANDLE hDevice = CreateFileW(szDevice, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + FF_AUTO_CLOSE_FD HANDLE hDevice = CreateFileW(szDevice, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (hDevice == INVALID_HANDLE_VALUE) { return "CreateFileW() failed"; } @@ -19,30 +19,30 @@ static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* s FFPhysicalDiskType type = FF_PHYSICALDISK_TYPE_NONE; FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); - const char* interconnect = NULL; + const char* interconnect = nullptr; uint64_t size = 0; { alignas(DISK_GEOMETRY_EX) uint8_t dgeBuffer[4096]; if (DeviceIoControl( hDevice, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, - NULL, + nullptr, 0, dgeBuffer, sizeof(dgeBuffer), &retSize, - NULL)) { + nullptr)) { const DISK_GEOMETRY_EX* dge = (const DISK_GEOMETRY_EX*) dgeBuffer; size = (uint64_t) dge->DiskSize.QuadPart; } else if (DeviceIoControl( hDevice, IOCTL_DISK_GET_DRIVE_GEOMETRY, - NULL, + nullptr, 0, dgeBuffer, sizeof(dgeBuffer), &retSize, - NULL) && + nullptr) && retSize >= sizeof(DISK_GEOMETRY)) { const DISK_GEOMETRY* dg = (const DISK_GEOMETRY*) dgeBuffer; size = (uint64_t) dg->BytesPerSector * dg->SectorsPerTrack * dg->TracksPerCylinder * (uint64_t) dg->Cylinders.QuadPart; @@ -91,7 +91,7 @@ static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* s type |= FF_PHYSICALDISK_TYPE_UNUSED; } - const STORAGE_DEVICE_DESCRIPTOR* sdd = NULL; + const STORAGE_DEVICE_DESCRIPTOR* sdd = nullptr; alignas(STORAGE_DEVICE_DESCRIPTOR) uint8_t sddBuffer[4096]; if (!interconnect) { if (DeviceIoControl( @@ -105,7 +105,7 @@ static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* s &sddBuffer, sizeof(sddBuffer), &retSize, - NULL) || + nullptr) || retSize == 0) { sdd = (const STORAGE_DEVICE_DESCRIPTOR*) sddBuffer; @@ -236,12 +236,12 @@ static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* s if (DeviceIoControl( hDevice, IOCTL_STORAGE_GET_MEDIA_TYPES_EX, - NULL, + nullptr, 0, gmt, sizeof(buffer), &retSize, - NULL) && + nullptr) && gmt->MediaInfoCount > 0) { // DiskInfo and RemovableDiskInfo have the same structures. TapeInfo doesn't. if (gmt->DeviceType != FILE_DEVICE_TAPE) { @@ -275,7 +275,7 @@ static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* s &dspd, sizeof(dspd), &retSize, - NULL) && + nullptr) && retSize == sizeof(dspd)) { device->type |= dspd.IncursSeekPenalty ? FF_PHYSICALDISK_TYPE_HDD : FF_PHYSICALDISK_TYPE_SSD; } @@ -293,14 +293,14 @@ static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* s &stdd, sizeof(stdd), &retSize, - NULL) && + nullptr) && retSize == sizeof(stdd)) { device->temperature = stdd.TemperatureInfo[0].Temperature; } } } - return NULL; + return nullptr; } static void detectPhysicalDisksByInterfaceClass(const char* type, const GUID* interfaceClassGuid, FFlist* result, FFPhysicalDiskOptions* options) { @@ -308,7 +308,7 @@ static void detectPhysicalDisksByInterfaceClass(const char* type, const GUID* in if (CM_Get_Device_Interface_List_SizeW( &cchDeviceInterfaces, (LPGUID) interfaceClassGuid, - NULL, + nullptr, CM_GET_DEVICE_INTERFACE_LIST_PRESENT) != CR_SUCCESS || cchDeviceInterfaces <= 1) { return; @@ -321,7 +321,7 @@ static void detectPhysicalDisksByInterfaceClass(const char* type, const GUID* in if (CM_Get_Device_Interface_ListW( (LPGUID) interfaceClassGuid, - NULL, + nullptr, mszDeviceInterfaces, cchDeviceInterfaces, CM_GET_DEVICE_INTERFACE_LIST_PRESENT) != CR_SUCCESS) { @@ -332,7 +332,7 @@ static void detectPhysicalDisksByInterfaceClass(const char* type, const GUID* in for (const wchar_t* p = mszDeviceInterfaces; *p; p += wcslen(p) + 1) { FF_DEBUG("Probing %s: %ls", type, p); FF_A_UNUSED const char* error = detectPhysicalDisk(type, p, result, options); - if (error == NULL) { + if (error == nullptr) { FF_DEBUG("Detected device \"%s\"", FF_LIST_LAST(FFPhysicalDiskResult, *result)->name.chars); } else { FF_DEBUG("Failed to detect device %s: %s", type, error); @@ -345,5 +345,5 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) detectPhysicalDisksByInterfaceClass("Disk", &GUID_DEVINTERFACE_DISK, result, options); detectPhysicalDisksByInterfaceClass("CD-ROM", &GUID_DEVINTERFACE_CDROM, result, options); detectPhysicalDisksByInterfaceClass("Tape", &GUID_DEVINTERFACE_TAPE, result, options); - return NULL; + return nullptr; } diff --git a/src/detection/physicalmemory/physicalmemory.c b/src/detection/physicalmemory/physicalmemory.c index 0188e0544..ca1114141 100644 --- a/src/detection/physicalmemory/physicalmemory.c +++ b/src/detection/physicalmemory/physicalmemory.c @@ -35,7 +35,7 @@ static inline const char* getVendorString(unsigned vendorId) { case 0x0467: return "Ramaxel"; default: - return NULL; + return nullptr; } } @@ -61,7 +61,7 @@ void FFPhysicalMemoryUpdateVendorString(FFPhysicalMemoryResult* device) { memcpy(vendorIdStr, device->vendor.chars, 4); } vendorIdStr[4] = '\0'; - char* pEnd = NULL; + char* pEnd = nullptr; uint32_t vendorId = (uint32_t) strtoul(vendorIdStr, &pEnd, 16); if (*pEnd != '\0') { return; diff --git a/src/detection/physicalmemory/physicalmemory_apple.m b/src/detection/physicalmemory/physicalmemory_apple.m index e35f53863..d39b4ecbe 100644 --- a/src/detection/physicalmemory/physicalmemory_apple.m +++ b/src/detection/physicalmemory/physicalmemory_apple.m @@ -37,7 +37,7 @@ static void appendDevice( if (size) { - char* unit = NULL; + char* unit = nullptr; device->size = strtoul(size.UTF8String, &unit, 10); if (*unit == ' ') ++unit; @@ -52,7 +52,7 @@ static void appendDevice( if (speed) { - char* unit = NULL; + char* unit = nullptr; device->maxSpeed = (uint32_t) strtoul(speed.UTF8String, &unit, 10); if (*unit == ' ') ++unit; @@ -74,8 +74,8 @@ static const char* detectFromSystemProfiler(FFlist* result) "-xml", "-detailLevel", "full", - NULL - }) != NULL) + nullptr + }) != nullptr) return "Starting `system_profiler SPMemoryDataType -xml -detailLevel full` failed"; NSArray* arr = [NSPropertyListSerialization propertyListWithData:[NSData dataWithBytes:buffer.chars length:buffer.length] @@ -118,7 +118,7 @@ static const char* detectFromSystemProfiler(FFlist* result) } } - return NULL; + return nullptr; } FF_A_UNUSED static const char* detectFromIokit(FFlist* result) @@ -149,14 +149,14 @@ FF_A_UNUSED static const char* detectFromIokit(FFlist* result) ffCfStrGetString(dramType, &device->type); ffCfStrGetString(dramVendor, &device->vendor); ffCfNumGetInt64(dramSize, (int64_t*) &device->size); - return NULL; + return nullptr; } const char* ffDetectPhysicalMemory(FF_A_UNUSED FFPhysicalMemoryOptions* options, FFlist* result) { #if __aarch64__ - if (detectFromIokit(result) == NULL) - return NULL; + if (detectFromIokit(result) == nullptr) + return nullptr; #endif return detectFromSystemProfiler(result); diff --git a/src/detection/physicalmemory/physicalmemory_linux.c b/src/detection/physicalmemory/physicalmemory_linux.c index 02df7897a..12956e197 100644 --- a/src/detection/physicalmemory/physicalmemory_linux.c +++ b/src/detection/physicalmemory/physicalmemory_linux.c @@ -129,7 +129,7 @@ const char* ffDetectPhysicalMemory(FFPhysicalMemoryOptions* options, FFlist* res } const char* formFactorNames[] = { - NULL, // 0x00 (Placeholder for indexing) + nullptr, // 0x00 (Placeholder for indexing) "Other", // 0x01 "Unknown", // 0x02 "SIMM", // 0x03 @@ -157,7 +157,7 @@ const char* ffDetectPhysicalMemory(FFPhysicalMemoryOptions* options, FFlist* res } const char* memoryTypeNames[] = { - NULL, // 0x00 (Placeholder for indexing) + nullptr, // 0x00 (Placeholder for indexing) "Other", // 0x01 "Unknown", // 0x02 "DRAM", // 0x03 @@ -231,5 +231,5 @@ const char* ffDetectPhysicalMemory(FFPhysicalMemoryOptions* options, FFlist* res } } - return NULL; + return nullptr; } diff --git a/src/detection/poweradapter/poweradapter_apple.c b/src/detection/poweradapter/poweradapter_apple.c index 9a5008abd..444a7ae51 100644 --- a/src/detection/poweradapter/poweradapter_apple.c +++ b/src/detection/poweradapter/poweradapter_apple.c @@ -18,7 +18,7 @@ const char* ffDetectPowerAdapter(FFlist* results) { adapter->watts = 0; ffCfDictGetString(details, CFSTR(kIOPSNameKey), &adapter->name); - if (ffCfDictGetString(details, CFSTR("Model"), &adapter->modelName) != NULL) { + if (ffCfDictGetString(details, CFSTR("Model"), &adapter->modelName) != nullptr) { int adapterId; if (ffCfDictGetInt(details, CFSTR(kIOPSPowerAdapterIDKey), &adapterId) == 0) { ffStrbufSetF(&adapter->modelName, "%d", adapterId); @@ -26,7 +26,7 @@ const char* ffDetectPowerAdapter(FFlist* results) { } ffCfDictGetString(details, CFSTR("Manufacturer"), &adapter->manufacturer); ffCfDictGetString(details, CFSTR("Description"), &adapter->description); - if (ffCfDictGetString(details, CFSTR("SerialString"), &adapter->serial) != NULL) { + if (ffCfDictGetString(details, CFSTR("SerialString"), &adapter->serial) != nullptr) { int serialNumber; if (ffCfDictGetInt(details, CFSTR(kIOPSPowerAdapterSerialNumberKey), &serialNumber) == 0) { ffStrbufSetF(&adapter->serial, "%X", serialNumber); @@ -35,5 +35,5 @@ const char* ffDetectPowerAdapter(FFlist* results) { ffCfDictGetInt(details, CFSTR(kIOPSPowerAdapterWattsKey), &adapter->watts); } - return NULL; + return nullptr; } diff --git a/src/detection/poweradapter/poweradapter_linux.c b/src/detection/poweradapter/poweradapter_linux.c index fb555d538..fd0abcc1d 100644 --- a/src/detection/poweradapter/poweradapter_linux.c +++ b/src/detection/poweradapter/poweradapter_linux.c @@ -71,12 +71,12 @@ static void parsePowerAdapter(int dfd, const char* id, FFlist* results) { const char* ffDetectPowerAdapter(FFlist* results) { FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/power_supply/"); - if (dirp == NULL) { - return "opendir(\"/sys/class/power_supply/\") == NULL"; + if (dirp == nullptr) { + return "opendir(\"/sys/class/power_supply/\") == nullptr"; } struct dirent* entry; - while ((entry = readdir(dirp)) != NULL) { + while ((entry = readdir(dirp)) != nullptr) { if (entry->d_name[0] == '.') { continue; } @@ -87,5 +87,5 @@ const char* ffDetectPowerAdapter(FFlist* results) { } } - return NULL; + return nullptr; } diff --git a/src/detection/processes/processes_bsd.c b/src/detection/processes/processes_bsd.c index e3f02b8db..4d16bc3af 100644 --- a/src/detection/processes/processes_bsd.c +++ b/src/detection/processes/processes_bsd.c @@ -14,10 +14,10 @@ const char* ffDetectProcesses(uint32_t* result) { int request[] = { CTL_KERN, KERN_PROC, KERN_PROC_PROC }; size_t length; - if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) { + if (sysctl(request, ARRAY_SIZE(request), nullptr, &length, nullptr, 0) != 0) { return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PROC}) failed"; } *result = (uint32_t) (length / sizeof(struct kinfo_proc)); - return NULL; + return nullptr; } diff --git a/src/detection/processes/processes_haiku.c b/src/detection/processes/processes_haiku.c index c50e62d53..0d960ab39 100644 --- a/src/detection/processes/processes_haiku.c +++ b/src/detection/processes/processes_haiku.c @@ -10,5 +10,5 @@ const char* ffDetectProcesses(uint32_t* result) { *result = info.used_teams; - return NULL; + return nullptr; } diff --git a/src/detection/processes/processes_linux.c b/src/detection/processes/processes_linux.c index dee8c0951..78790c2eb 100644 --- a/src/detection/processes/processes_linux.c +++ b/src/detection/processes/processes_linux.c @@ -5,14 +5,14 @@ const char* ffDetectProcesses(uint32_t* result) { FF_AUTO_CLOSE_DIR DIR* dir = opendir("/proc"); - if (dir == NULL) { + if (dir == nullptr) { return "opendir(\"/proc\") failed"; } uint32_t num = 0; struct dirent* entry; - while ((entry = readdir(dir)) != NULL) { + while ((entry = readdir(dir)) != nullptr) { if ( #ifdef _DIRENT_HAVE_D_TYPE (entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) && @@ -23,5 +23,5 @@ const char* ffDetectProcesses(uint32_t* result) { *result = num; - return NULL; + return nullptr; } diff --git a/src/detection/processes/processes_nbsd.c b/src/detection/processes/processes_nbsd.c index efd3d6feb..c3e7d047f 100644 --- a/src/detection/processes/processes_nbsd.c +++ b/src/detection/processes/processes_nbsd.c @@ -6,10 +6,10 @@ const char* ffDetectProcesses(uint32_t* result) { int request[] = { CTL_KERN, KERN_PROC2, KERN_PROC_ALL, -1, sizeof(struct kinfo_proc2), 0 }; size_t length = 0; - if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) { + if (sysctl(request, ARRAY_SIZE(request), nullptr, &length, nullptr, 0) != 0) { return "sysctl({CTL_KERN, KERN_PROC2, KERN_PROC_ALL}) failed"; } *result = (uint32_t) (length / sizeof(struct kinfo_proc2)); - return NULL; + return nullptr; } diff --git a/src/detection/processes/processes_obsd.c b/src/detection/processes/processes_obsd.c index 6246d8f8a..5a5ba31f4 100644 --- a/src/detection/processes/processes_obsd.c +++ b/src/detection/processes/processes_obsd.c @@ -5,11 +5,11 @@ #include const char* ffDetectProcesses(uint32_t* result) { - kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); + kvm_t* kd = kvm_open(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr); const void* ret = kvm_getprocs(kd, KERN_PROC_ALL, 0, 1, result); kvm_close(kd); if (!ret) { return "kvm_getprocs() failed"; } - return NULL; + return nullptr; } diff --git a/src/detection/processes/processes_windows.c b/src/detection/processes/processes_windows.c index 03b34db98..82888de1c 100644 --- a/src/detection/processes/processes_windows.c +++ b/src/detection/processes/processes_windows.c @@ -5,7 +5,7 @@ #include const char* ffDetectProcesses(uint32_t* result) { - 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. @@ -30,5 +30,5 @@ const char* ffDetectProcesses(uint32_t* result) { ++*result; } - return NULL; + return nullptr; } diff --git a/src/detection/publicip/publicip.c b/src/detection/publicip/publicip.c index abca57c3e..bb4ae434f 100644 --- a/src/detection/publicip/publicip.c +++ b/src/detection/publicip/publicip.c @@ -19,7 +19,7 @@ void ffPreparePublicIp(FFPublicIPOptions* options) { if (options->url.length == 0) { state->compression = true; state->tfo = true; - *status = ffNetworkingSendHttpRequest(state, options->ipv6 ? "v6.ipinfo.io" : "ipinfo.io", "/json", NULL); + *status = ffNetworkingSendHttpRequest(state, options->ipv6 ? "v6.ipinfo.io" : "ipinfo.io", "/json", nullptr); } else { FF_STRBUF_AUTO_DESTROY host = ffStrbufCreateCopy(&options->url); uint32_t hostStartIndex = ffStrbufFirstIndexS(&host, "://"); @@ -39,7 +39,7 @@ void ffPreparePublicIp(FFPublicIPOptions* options) { host.chars[pathStartIndex] = '\0'; } - *status = ffNetworkingSendHttpRequest(state, host.chars, path.length == 0 ? "/" : path.chars, NULL); + *status = ffNetworkingSendHttpRequest(state, host.chars, path.length == 0 ? "/" : path.chars, nullptr); } } @@ -57,7 +57,7 @@ const char* ffDetectPublicIp(FFPublicIPOptions* options, FFPublicIpResult* resul ffPreparePublicIp(options); } - if (*status != NULL) { + if (*status != nullptr) { return *status; } @@ -67,7 +67,7 @@ const char* ffDetectPublicIp(FFPublicIPOptions* options, FFPublicIpResult* resul *state = (FFNetworkingState) {}; *status = FF_UNINITIALIZED; - if (error == NULL) { + if (error == nullptr) { ffStrbufSubstrAfterFirstS(&response, "\r\n\r\n"); } else { return error; @@ -78,18 +78,18 @@ const char* ffDetectPublicIp(FFPublicIPOptions* options, FFPublicIpResult* resul } if (options->url.length == 0) { - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(response.chars, response.length, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(response.chars, response.length, 0, nullptr, nullptr); if (doc) { yyjson_val* root = yyjson_doc_get_root(doc); ffStrbufAppendJsonVal(&result->ip, yyjson_obj_get(root, "ip")); ffStrbufDestroy(&result->location); ffStrbufInitF(&result->location, "%s, %s", yyjson_get_str(yyjson_obj_get(root, "city")), yyjson_get_str(yyjson_obj_get(root, "country"))); - return NULL; + return nullptr; } } ffStrbufDestroy(&result->ip); ffStrbufInitMove(&result->ip, &response); ffStrbufTrimRightSpace(&result->ip); - return NULL; + return nullptr; } diff --git a/src/detection/sound/sound_apple.c b/src/detection/sound/sound_apple.c index aaacf78eb..36ebb2a8b 100644 --- a/src/detection/sound/sound_apple.c +++ b/src/detection/sound/sound_apple.c @@ -11,7 +11,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FFSoundDevice */) { AudioDeviceID mainDeviceId; UInt32 dataSize = sizeof(mainDeviceId); - if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &mainDeviceId) != kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &mainDeviceId) != kAudioHardwareNoError) { return "AudioObjectGetPropertyData(kAudioHardwarePropertyDefaultOutputDevice) failed"; } @@ -21,7 +21,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF dataSize = sizeof(mainDeviceId); } else { dataSize = sizeof(deviceIds); - if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &deviceIds) != kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &deviceIds) != kAudioHardwareNoError) { return "AudioObjectGetPropertyData(kAudioHardwarePropertyDevices) failed"; } } @@ -30,16 +30,16 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF AudioDeviceID deviceId = deviceIds[index]; // Ignore input devices - if (AudioObjectGetPropertyDataSize(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyStreams, kAudioObjectPropertyScopeInput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize) == kAudioHardwareNoError && dataSize > 0) { + if (AudioObjectGetPropertyDataSize(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyStreams, kAudioObjectPropertyScopeInput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize) == kAudioHardwareNoError && dataSize > 0) { continue; } uint32_t dataSource; dataSize = sizeof(dataSource); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDataSource, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &dataSource) == kAudioHardwareNoError && dataSource == 'hdpn') { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDataSource, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &dataSource) == kAudioHardwareNoError && dataSource == 'hdpn') { uint32_t connected; dataSize = sizeof(connected); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyJackIsConnected, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &connected) == kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyJackIsConnected, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &connected) == kAudioHardwareNoError) { if (!connected) { continue; } @@ -48,7 +48,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF uint32_t active = true; dataSize = sizeof(active); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &active) == kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &active) == kAudioHardwareNoError) { if ((options->soundType & FF_SOUND_TYPE_ACTIVE) && !active) { continue; } @@ -62,17 +62,17 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF ffStrbufInit(&device->name); ffStrbufInitStatic(&device->platformApi, "Core Audio"); - FF_CFTYPE_AUTO_RELEASE CFStringRef uid = NULL; + FF_CFTYPE_AUTO_RELEASE CFStringRef uid = nullptr; dataSize = sizeof(uid); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceUID, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &uid) == kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceUID, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &uid) == kAudioHardwareNoError) { ffCfStrGetString(uid, &device->identifier); } else { ffStrbufAppendF(&device->identifier, "ID-%u", (unsigned) deviceId); } - FF_CFTYPE_AUTO_RELEASE CFStringRef name = NULL; + FF_CFTYPE_AUTO_RELEASE CFStringRef name = nullptr; dataSize = sizeof(name); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioObjectPropertyName, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &name) == kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioObjectPropertyName, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &name) == kAudioHardwareNoError) { ffCfStrGetString(name, &device->name); } else { ffStrbufSet(&device->name, &device->identifier); @@ -80,7 +80,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF uint32_t muted; dataSize = sizeof(muted); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyMute, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &muted) != kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyMute, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &muted) != kAudioHardwareNoError) { muted = false; // Device may not support volume control } @@ -89,17 +89,17 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF } else { float volume; dataSize = sizeof(volume); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &volume) == kAudioHardwareNoError) { device->volume = (uint8_t) (volume * 100 + 0.5); } else { // Try detecting volume from channels uint32_t channels[2]; dataSize = sizeof(channels); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyPreferredChannelsForStereo, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, channels) == kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyPreferredChannelsForStereo, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, channels) == kAudioHardwareNoError) { dataSize = sizeof(volume); - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[0] }, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[0] }, 0, nullptr, &dataSize, &volume) == kAudioHardwareNoError) { float temp; - if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[1] }, 0, NULL, &dataSize, &temp) == kAudioHardwareNoError) { + if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[1] }, 0, nullptr, &dataSize, &temp) == kAudioHardwareNoError) { device->volume = (uint8_t) ((volume + temp) / 2 * 100 + 0.5); } } @@ -108,5 +108,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF } } - return NULL; + return nullptr; } diff --git a/src/detection/sound/sound_bsd.c b/src/detection/sound/sound_bsd.c index cbac86848..118b33b09 100644 --- a/src/detection/sound/sound_bsd.c +++ b/src/detection/sound/sound_bsd.c @@ -86,5 +86,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) { device->type = FF_SOUND_TYPE_ACTIVE | (isMain ? FF_SOUND_TYPE_MAIN : FF_SOUND_TYPE_NONE); } - return NULL; + return nullptr; } diff --git a/src/detection/sound/sound_haiku.cpp b/src/detection/sound/sound_haiku.cpp index d69602e02..e7a16e2ed 100644 --- a/src/detection/sound/sound_haiku.cpp +++ b/src/detection/sound/sound_haiku.cpp @@ -14,7 +14,7 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices / dormant_node_info dormantInfo; if (roster->GetAudioOutput(&mediaNode) != B_OK) { - return NULL; + return nullptr; } FFSoundDevice* device = FF_LIST_ADD(FFSoundDevice, *devices); @@ -36,20 +36,20 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices / media_node mixer; if (roster->GetAudioMixer(&mixer) != B_OK) { - return NULL; + return nullptr; } BParameterWeb* web; status_t status = roster->GetParameterWebFor(mixer, &web); roster->ReleaseNode(mixer); // the web is all we need :-) if (status != B_OK) { - return NULL; + return nullptr; } - BContinuousParameter* gain = NULL; - BParameter* mute = NULL; + BContinuousParameter* gain = nullptr; + BParameter* mute = nullptr; BParameter* parameter; - for (int32 index = 0; (parameter = web->ParameterAt(index)) != NULL; index++) { + for (int32 index = 0; (parameter = web->ParameterAt(index)) != nullptr; index++) { // assume the mute preceding master gain control if (ffStrEquals(parameter->Kind(), B_MUTE)) { mute = parameter; @@ -63,8 +63,8 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices / } } - if (gain == NULL) { - return NULL; + if (gain == nullptr) { + return nullptr; } bigtime_t when; @@ -74,7 +74,7 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices / int32 isMute = false; size = sizeof(isMute); if (mute->GetValue(&isMute, &size, &when) == B_OK && isMute) { - return NULL; + return nullptr; } } @@ -84,5 +84,5 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices / device->volume = (uint8_t) (100 * (volume - gain->MinValue()) / (gain->MaxValue() - gain->MinValue())); } - return NULL; + return nullptr; } diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index 8af7e93c8..923d65218 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -96,9 +96,9 @@ static const char* detectSound(FFSoundOptions* options, FFlist* devices) { .result = devices, .options = options, }; - const char* error = NULL; + const char* error = nullptr; - if (ffpa_context_connect(context, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0) { + if (ffpa_context_connect(context, nullptr, PA_CONTEXT_NOFLAGS, nullptr) < 0) { error = "Failed to connect to pulseaudio context"; goto exit; } @@ -110,7 +110,7 @@ static const char* detectSound(FFSoundOptions* options, FFlist* devices) { goto exit; } - ffpa_mainloop_iterate(mainloop, 1, NULL); + ffpa_mainloop_iterate(mainloop, 1, nullptr); } { @@ -120,7 +120,7 @@ static const char* detectSound(FFSoundOptions* options, FFlist* devices) { goto exit; } while (ffpa_operation_get_state(operation) == PA_OPERATION_RUNNING) { - ffpa_mainloop_iterate(mainloop, 1, NULL); + ffpa_mainloop_iterate(mainloop, 1, nullptr); } ffpa_operation_unref(operation); @@ -138,7 +138,7 @@ static const char* detectSound(FFSoundOptions* options, FFlist* devices) { ffpa_operation_cancel(operation); } - ffpa_mainloop_iterate(mainloop, 1, NULL); + ffpa_mainloop_iterate(mainloop, 1, nullptr); } ffpa_operation_unref(operation); diff --git a/src/detection/sound/sound_nbsd.c b/src/detection/sound/sound_nbsd.c index efd276eac..f52ba2cfe 100644 --- a/src/detection/sound/sound_nbsd.c +++ b/src/detection/sound/sound_nbsd.c @@ -54,5 +54,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) { device->type = FF_SOUND_TYPE_ACTIVE | (isMain ? FF_SOUND_TYPE_MAIN : FF_SOUND_TYPE_NONE); } - return NULL; + return nullptr; } diff --git a/src/detection/sound/sound_obsd.c b/src/detection/sound/sound_obsd.c index a6dd6df40..790bde41a 100644 --- a/src/detection/sound/sound_obsd.c +++ b/src/detection/sound/sound_obsd.c @@ -86,5 +86,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) { } device->volume = (uint8_t) ((totalLevel * 100 + bundle.iLevel / 2) / bundle.iLevel); - return NULL; + return nullptr; } diff --git a/src/detection/sound/sound_sunos.c b/src/detection/sound/sound_sunos.c index 7c84e55cb..3f5e2219e 100644 --- a/src/detection/sound/sound_sunos.c +++ b/src/detection/sound/sound_sunos.c @@ -105,5 +105,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) { (isMain ? FF_SOUND_TYPE_MAIN : FF_SOUND_TYPE_NONE); } - return NULL; + return nullptr; } diff --git a/src/detection/sound/sound_windows.cpp b/src/detection/sound/sound_windows.cpp index 6d6307a5d..2ec923d1d 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -11,7 +11,7 @@ extern "C" { #include static void ffCoTaskMemFreeWrapper(void* pptr) { - assert(pptr != NULL); + assert(pptr != nullptr); void* ptr = *(void**) pptr; if (ptr) { CoTaskMemFree(ptr); @@ -20,12 +20,12 @@ static void ffCoTaskMemFreeWrapper(void* pptr) { #define FF_COTASK_AUTO_FREE FF_A_CLEANUP(ffCoTaskMemFreeWrapper) static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */, IMMDevice* immDevice, LPWSTR mainDeviceId) { - LPWSTR FF_COTASK_AUTO_FREE immDeviceId = NULL; + LPWSTR FF_COTASK_AUTO_FREE immDeviceId = nullptr; if (FAILED(immDevice->GetId(&immDeviceId))) { return "immDevice->GetId() failed"; } - IPropertyStore* FF_AUTO_RELEASE_COM_OBJECT immPropStore = NULL; + IPropertyStore* FF_AUTO_RELEASE_COM_OBJECT immPropStore = nullptr; if (FAILED(immDevice->OpenPropertyStore(STGM_READ, &immPropStore))) { return "immDevice->OpenPropertyStore() failed"; } @@ -54,8 +54,8 @@ static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */ } } - IAudioEndpointVolume* FF_AUTO_RELEASE_COM_OBJECT immEndpointVolume = NULL; - if (SUCCEEDED(immDevice->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**) &immEndpointVolume))) { + IAudioEndpointVolume* FF_AUTO_RELEASE_COM_OBJECT immEndpointVolume = nullptr; + if (SUCCEEDED(immDevice->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, nullptr, (void**) &immEndpointVolume))) { BOOL muted; if (FAILED(immEndpointVolume->GetMute(&muted)) || !muted) { FLOAT volume; @@ -65,7 +65,7 @@ static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */ } } - return NULL; + return nullptr; } const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FFSoundDevice */) { @@ -74,23 +74,23 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF return error; } - IMMDeviceEnumerator* FF_AUTO_RELEASE_COM_OBJECT pEnum = NULL; + IMMDeviceEnumerator* FF_AUTO_RELEASE_COM_OBJECT pEnum = nullptr; - if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pEnum)))) { + if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pEnum)))) { return "CoCreateInstance(CLSID_MMDeviceEnumerator) failed"; } - LPWSTR FF_COTASK_AUTO_FREE mainDeviceId = NULL; + LPWSTR FF_COTASK_AUTO_FREE mainDeviceId = nullptr; { - IMMDevice* FF_AUTO_RELEASE_COM_OBJECT pDefaultDevice = NULL; + IMMDevice* FF_AUTO_RELEASE_COM_OBJECT pDefaultDevice = nullptr; if (FAILED(pEnum->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDefaultDevice))) { return "GetDefaultAudioEndpoint() failed"; } if (options->soundType & FF_SOUND_TYPE_MAIN) { - return detectSoundDevice(devices, pDefaultDevice, NULL); + return detectSoundDevice(devices, pDefaultDevice, nullptr); } if (FAILED(pDefaultDevice->GetId(&mainDeviceId))) { @@ -98,7 +98,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF } } - IMMDeviceCollection* FF_AUTO_RELEASE_COM_OBJECT pDevices = NULL; + IMMDeviceCollection* FF_AUTO_RELEASE_COM_OBJECT pDevices = nullptr; if (FAILED(pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE | (options->soundType & FF_SOUND_TYPE_ACTIVE ? 0 : DEVICE_STATE_DISABLED), &pDevices))) { return "EnumAudioEndpoints() failed"; @@ -110,7 +110,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF } for (uint32_t deviceIdx = 0; deviceIdx < deviceCount; ++deviceIdx) { - IMMDevice* FF_AUTO_RELEASE_COM_OBJECT immDevice = NULL; + IMMDevice* FF_AUTO_RELEASE_COM_OBJECT immDevice = nullptr; if (FAILED(pDevices->Item(deviceIdx, &immDevice))) { continue; } @@ -118,5 +118,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF detectSoundDevice(devices, immDevice, mainDeviceId); } - return NULL; + return nullptr; } diff --git a/src/detection/swap/swap_apple.c b/src/detection/swap/swap_apple.c index 40dda4900..3c457c0ec 100644 --- a/src/detection/swap/swap_apple.c +++ b/src/detection/swap/swap_apple.c @@ -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; } diff --git a/src/detection/swap/swap_bsd.c b/src/detection/swap/swap_bsd.c index a54cd5252..0172d3c03 100644 --- a/src/detection/swap/swap_bsd.c +++ b/src/detection/swap/swap_bsd.c @@ -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 diff --git a/src/detection/swap/swap_haiku.c b/src/detection/swap/swap_haiku.c index 8a3b08cbe..cc8f855c6 100644 --- a/src/detection/swap/swap_haiku.c +++ b/src/detection/swap/swap_haiku.c @@ -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; } diff --git a/src/detection/swap/swap_linux.c b/src/detection/swap/swap_linux.c index b31f268bf..d72125d78 100644 --- a/src/detection/swap/swap_linux.c +++ b/src/detection/swap/swap_linux.c @@ -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); } diff --git a/src/detection/swap/swap_obsd.c b/src/detection/swap/swap_obsd.c index 1296aeb27..9c2c98c9e 100644 --- a/src/detection/swap/swap_obsd.c +++ b/src/detection/swap/swap_obsd.c @@ -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; } diff --git a/src/detection/swap/swap_sunos.c b/src/detection/swap/swap_sunos.c index fa3260d50..b08d489ef 100644 --- a/src/detection/swap/swap_sunos.c +++ b/src/detection/swap/swap_sunos.c @@ -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; } diff --git a/src/detection/swap/swap_windows.c b/src/detection/swap/swap_windows.c index e96298bdc..2caadaddb 100644 --- a/src/detection/swap/swap_windows.c +++ b/src/detection/swap/swap_windows.c @@ -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; } diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 7ef71206a..a365752ea 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -77,7 +77,7 @@ static bool parseGhosttyConfig(FFstrbuf* path, FFstrbuf* fontName, FFstrbuf* fon return false; } - char* line = NULL; + char* line = nullptr; size_t len = 0; while (ffStrbufGetline(&line, &len, &buffer)) { if (ffParsePropLine(line, "font-family =", &temp)) { @@ -124,10 +124,10 @@ static void detectGhostty(const FFstrbuf* exe, FFTerminalFontResult* terminalFon const char* error = ffProcessAppendStdOut(&buffer, (char* const[]){ exe->chars, "+show-config", - NULL, + nullptr, }); - if (error == NULL) { - char* line = NULL; + if (error == nullptr) { + char* line = nullptr; size_t len = 0; while (ffStrbufGetline(&line, &len, &buffer)) { if (ffStrStartsWith(line, "font-family = ")) { @@ -167,7 +167,7 @@ static void detectGhostty(const FFstrbuf* exe, FFTerminalFontResult* terminalFon ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); if (fontNameFallback.length > 0) { FF_DEBUG("applying fallback family='%s'", fontNameFallback.chars); - ffFontInitValues(&terminalFont->fallback, fontNameFallback.chars, NULL); + ffFontInitValues(&terminalFont->fallback, fontNameFallback.chars, nullptr); } FF_DEBUG("result family='%s' size='%s'%s", fontName.chars, fontSize.chars, fontNameFallback.length ? " (with fallback)" : ""); FF_DEBUG("detectGhostty: end"); @@ -180,7 +180,7 @@ FF_A_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) { if (fontName.length == 0) { ffStrbufAppendS(&fontName, "VGA default kernel font "); - ffProcessAppendStdOut(&fontName, (char* const[]){ "showconsolefont", "--info", NULL }); + ffProcessAppendStdOut(&fontName, (char* const[]){ "showconsolefont", "--info", nullptr }); ffStrbufTrimRight(&fontName, ' '); } @@ -203,7 +203,7 @@ FF_A_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* r 2, "\eP1+r%*[^=]=%511[^\e]\e\\\eP1+r%*[^=]=%511[^\e]\e\\", fontHex, - sizeHex) == NULL && + sizeHex) == nullptr && *fontHex && *sizeHex) { // decode hex string for (const char* p = fontHex; p[0] && p[1]; p += 2) { @@ -224,7 +224,7 @@ FF_A_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* r exe->chars, "+kitten", "query-terminal", - NULL, + nullptr, })) { ffParsePropLines(buf.chars, "font_family: ", &fontName); ffParsePropLines(buf.chars, "font_size: ", &fontSize); @@ -260,7 +260,7 @@ static bool detectWezterm(const FFstrbuf* exe, FFTerminalFontResult* result) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); - ffStrbufSetS(&result->error, ffProcessAppendStdOut(&fontName, (char* const[]){ cli.chars, "ls-fonts", "--text", "a", NULL })); + ffStrbufSetS(&result->error, ffProcessAppendStdOut(&fontName, (char* const[]){ cli.chars, "ls-fonts", "--text", "a", nullptr })); if (result->error.length) { return false; } @@ -306,7 +306,7 @@ static bool detectTabby(FFTerminalFontResult* result) { static bool detectContour(const FFstrbuf* exe, FFTerminalFontResult* result) { FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); - if (ffProcessAppendStdOut(&buf, (char* const[]){ exe->chars, "font-locator", NULL })) { + if (ffProcessAppendStdOut(&buf, (char* const[]){ exe->chars, "font-locator", nullptr })) { ffStrbufAppendS(&result->error, "`contour font-locator` failed"); return false; } @@ -365,7 +365,7 @@ static bool detectTerminalFontCommon(const FFTerminalResult* terminal, FFTermina } else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "contour")) { detectContour(&terminal->exe, terminalFont); } else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "ghostty")) { - detectGhostty(&terminal->exe, terminalFont, NULL, NULL); + detectGhostty(&terminal->exe, terminalFont, nullptr, nullptr); } else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "Muxy")) { detectGhostty(&terminal->exe, terminalFont, "Muxy/ghostty.conf", "muxy/ghostty.conf"); } else if (ffStrbufStartsWithIgnCaseS(&terminal->processName, "rio")) { diff --git a/src/detection/terminalfont/terminalfont_android.c b/src/detection/terminalfont/terminalfont_android.c index a7210783e..666cf3e2b 100644 --- a/src/detection/terminalfont/terminalfont_android.c +++ b/src/detection/terminalfont/terminalfont_android.c @@ -14,7 +14,7 @@ const char* detectTermux(FFTerminalFontResult* terminalFont) { if (!ffPathExists(FF_TERMUX_FONT_PATH, FF_PATHTYPE_FILE)) { ffFontInitCopy(&terminalFont->font, "monospace"); - return NULL; + return nullptr; } #ifdef FF_HAVE_FREETYPE @@ -25,9 +25,9 @@ const char* detectTermux(FFTerminalFontResult* terminalFont) { FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_Face); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_FreeType); - FT_Library library = NULL; - FT_Face face = NULL; - const char* error = NULL; + FT_Library library = nullptr; + FT_Face face = nullptr; + const char* error = nullptr; if (ffFT_Init_FreeType(&library)) { error = "FT_Init_FreeType() failed"; diff --git a/src/detection/terminalfont/terminalfont_apple.m b/src/detection/terminalfont/terminalfont_apple.m index 126235f41..c3011846f 100644 --- a/src/detection/terminalfont/terminalfont_apple.m +++ b/src/detection/terminalfont/terminalfont_apple.m @@ -10,7 +10,7 @@ static void detectIterm2(FFTerminalFontResult* terminalFont) { const char* profile = getenv("ITERM_PROFILE"); - if (profile == NULL) + if (profile == nullptr) { ffStrbufAppendS(&terminalFont->error, "environment variable ITERM_PROFILE not set"); return; diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 9ae16a430..70afc34a6 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -15,24 +15,24 @@ static const char* getSystemMonospaceFont(void) { const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, "Cinnamon")) { - const char* systemMonospaceFont = ffSettingsGetGnome("/org/cinnamon/desktop/interface/monospace-font-name", "org.cinnamon.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; + const char* systemMonospaceFont = ffSettingsGetGnome("/org/cinnamon/desktop/interface/monospace-font-name", "org.cinnamon.desktop.interface", nullptr, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; if (ffStrSet(systemMonospaceFont)) { return systemMonospaceFont; } } else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, "Mate")) { - const char* systemMonospaceFont = ffSettingsGetGnome("/org/mate/interface/monospace-font-name", "org.mate.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; + const char* systemMonospaceFont = ffSettingsGetGnome("/org/mate/interface/monospace-font-name", "org.mate.interface", nullptr, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; if (ffStrSet(systemMonospaceFont)) { return systemMonospaceFont; } } - return ffSettingsGetGnome("/org/gnome/desktop/interface/monospace-font-name", "org.gnome.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; + return ffSettingsGetGnome("/org/gnome/desktop/interface/monospace-font-name", "org.gnome.desktop.interface", nullptr, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; } static void detectKgx(FFTerminalFontResult* terminalFont) { // kgx (gnome console) doesn't support profiles - if (!ffSettingsGetGnome("/org/gnome/Console/use-system-font", "org.gnome.Console", NULL, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) { - FF_AUTO_FREE const char* fontName = ffSettingsGetGnome("/org/gnome/Console/custom-font", "org.gnome.Console", NULL, "custom-font", FF_VARIANT_TYPE_STRING).strValue; + if (!ffSettingsGetGnome("/org/gnome/Console/use-system-font", "org.gnome.Console", nullptr, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) { + FF_AUTO_FREE const char* fontName = ffSettingsGetGnome("/org/gnome/Console/custom-font", "org.gnome.Console", nullptr, "custom-font", FF_VARIANT_TYPE_STRING).strValue; if (ffStrSet(fontName)) { ffFontInitPango(&terminalFont->font, fontName); } else { @@ -49,8 +49,8 @@ static void detectKgx(FFTerminalFontResult* terminalFont) { } static void detectPtyxis(FFTerminalFontResult* terminalFont) { - if (!ffSettingsGetGnome("/org/gnome/Ptyxis/use-system-font", "org.gnome.Ptyxis", NULL, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) { - FF_AUTO_FREE const char* fontName = ffSettingsGetGnome("/org/gnome/Ptyxis/font-name", "org.gnome.Ptyxis", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; + if (!ffSettingsGetGnome("/org/gnome/Ptyxis/use-system-font", "org.gnome.Ptyxis", nullptr, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) { + FF_AUTO_FREE const char* fontName = ffSettingsGetGnome("/org/gnome/Ptyxis/font-name", "org.gnome.Ptyxis", nullptr, "font-name", FF_VARIANT_TYPE_STRING).strValue; if (ffStrSet(fontName)) { ffFontInitPango(&terminalFont->font, fontName); } else { @@ -67,7 +67,7 @@ static void detectPtyxis(FFTerminalFontResult* terminalFont) { } static void detectFromGSettings(const char* profilePath, const char* profileList, const char* profile, const char* defaultProfileKey, FFTerminalFontResult* terminalFont) { - FF_AUTO_FREE const char* defaultProfile = ffSettingsGetGSettings(profileList, NULL, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue; + FF_AUTO_FREE const char* defaultProfile = ffSettingsGetGSettings(profileList, nullptr, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue; if (!ffStrSet(defaultProfile)) { ffStrbufAppendF(&terminalFont->error, "Could not get default profile from gsettings: %s", profileList); return; @@ -172,7 +172,7 @@ static void detectDeepinTerminal(FFTerminalFontResult* terminalFont) { FILE* file = fopen(profile.chars, "r"); if (file) { - char* line = NULL; + char* line = nullptr; size_t len = 0; for (int count = 0; getline(&line, &len, file) != -1 && count < 2;) { @@ -230,7 +230,7 @@ static void detectFootTerminal(FFTerminalFontResult* terminalFont) { } ffFontInitValues(&terminalFont->font, font.chars, &font.chars[size]); if (comma < font.length) { - ffFontInitValues(&terminalFont->fallback, &font.chars[comma + 1], NULL); + ffFontInitValues(&terminalFont->fallback, &font.chars[comma + 1], nullptr); } } @@ -337,7 +337,7 @@ static void detectWarp(FFTerminalFontResult* terminalFont) { ffStrbufSet(&baseDir, dirPrefix); ffStrbufAppendS(&baseDir, "warp-terminal/user_preferences.json"); - yyjson_doc* doc = yyjson_read_file(baseDir.chars, YYJSON_READ_INSITU | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_COMMENTS, NULL, NULL); + yyjson_doc* doc = yyjson_read_file(baseDir.chars, YYJSON_READ_INSITU | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_COMMENTS, nullptr, nullptr); if (!doc) { continue; } @@ -434,7 +434,7 @@ static void detectUrxvt(FFTerminalFontResult* terminalFont) { uint32_t index = 0; - char* line = NULL; + char* line = nullptr; size_t len = 0; while (ffStrbufGetdelim(&line, &len, ',', &buffer)) { FFfont* font = index == 0 ? &terminalFont->font : &terminalFont->fallback; diff --git a/src/detection/terminalfont/terminalfont_windows.c b/src/detection/terminalfont/terminalfont_windows.c index 87566af8d..baf1d5fd3 100644 --- a/src/detection/terminalfont/terminalfont_windows.c +++ b/src/detection/terminalfont/terminalfont_windows.c @@ -33,7 +33,7 @@ static const char* detectWTProfile(yyjson_val* profile, FFstrbuf* name, double* *size = unsafe_yyjson_get_num(psize); } } - return NULL; + return nullptr; } static inline void wrapYyjsonFree(yyjson_doc** doc) { @@ -44,7 +44,7 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) { } static const char* detectFromWTImpl(FFstrbuf* content, FFstrbuf* name, double* size) { - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, nullptr, nullptr); if (!doc) { return "Failed to parse WT JSON config file"; } @@ -86,13 +86,13 @@ static const char* detectFromWTImpl(FFstrbuf* content, FFstrbuf* name, double* s if (*size < 0) { *size = 12; } - return NULL; + return nullptr; } static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont) { // https://learn.microsoft.com/en-us/windows/terminal/install#settings-json-file FF_STRBUF_AUTO_DESTROY json = ffStrbufCreate(); - const char* error = NULL; + const char* error = nullptr; if (terminalExe && ffIsAbsolutePath(terminalExe->chars)) { FF_STRBUF_AUTO_DESTROY jsonPath = ffStrbufCreateA(MAX_PATH); @@ -106,8 +106,8 @@ static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFon error = "Error reading Windows Terminal portable settings JSON file"; } } else { - PWSTR localAppDataW = NULL; - if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_LocalAppData, KF_FLAG_DEFAULT, NULL, &localAppDataW))) { + PWSTR localAppDataW = nullptr; + if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr, &localAppDataW))) { ffStrbufSetWS(&jsonPath, localAppDataW); CoTaskMemFree(localAppDataW); @@ -146,7 +146,7 @@ static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFon "else if exist \"%LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json\" " "( type %LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json ) " "else ( call )", - NULL }); + nullptr }); } if (error) { @@ -242,7 +242,7 @@ static void detectConEmu(FFTerminalFontResult* terminalFont) { } static void detectWarp(FFTerminalFontResult* terminalFont) { - FF_AUTO_CLOSE_FD HANDLE key = NULL; + FF_AUTO_CLOSE_FD HANDLE key = nullptr; if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Warp.dev\\Warp", &key, &terminalFont->error)) { return; } @@ -261,7 +261,7 @@ static void detectWarp(FFTerminalFontResult* terminalFont) { FFstrbuf* fontWeight = FF_LIST_ADD(FFstrbuf, terminalFont->font.styles); ffStrbufInit(fontWeight); - if (ffRegReadStrbuf(key, L"FontWeight", fontWeight, NULL)) { + if (ffRegReadStrbuf(key, L"FontWeight", fontWeight, nullptr)) { ffStrbufTrim(fontWeight, '"'); } else { ffStrbufSetStatic(fontWeight, "Normal"); diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 1d22083b6..035853650 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -25,7 +25,7 @@ static bool getFileVersion(const FFstrbuf* exePath, const wchar_t* stringName, FFstrbuf* version) { wchar_t exePathW[PATH_MAX + 1]; - if (!NT_SUCCESS(RtlUTF8ToUnicodeN(exePathW, (ULONG) sizeof(exePathW), NULL, exePath->chars, (ULONG) exePath->length + 1))) { + if (!NT_SUCCESS(RtlUTF8ToUnicodeN(exePathW, (ULONG) sizeof(exePathW), nullptr, exePath->chars, (ULONG) exePath->length + 1))) { return false; } return ffGetFileVersion(exePathW, stringName, version); @@ -38,7 +38,7 @@ static bool getFileVersion(const FFstrbuf* exePath, const wchar_t* stringName, F #endif static bool getExeVersionRaw(FFstrbuf* exe, FFstrbuf* version) { - return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) == NULL; + return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) == nullptr; } static bool getExeVersionGeneral(FFstrbuf* exe, FFstrbuf* version) { @@ -105,7 +105,7 @@ static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) { } #ifdef _WIN32 - if (getFileVersion(exe, NULL, version)) { + if (getFileVersion(exe, nullptr, version)) { ffStrbufSubstrBeforeLastC(version, '.'); return true; } @@ -120,14 +120,14 @@ static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) { } static bool getShellVersionKsh(FFstrbuf* exe, FFstrbuf* version) { - if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", NULL }) == NULL && ffStrbufSubstrAfterFirstS(version, " (AT&T Research) ")) { + if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", nullptr }) == nullptr && ffStrbufSubstrAfterFirstS(version, " (AT&T Research) ")) { // version sh (AT&T Research) 93u+ 2012-08-01 ffStrbufSubstrBeforeFirstC(version, ' '); return true; } ffStrbufClear(version); - if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", "echo $KSH_VERSION", NULL }) == NULL && ffStrbufSubstrAfterFirstS(version, " KSH ")) { + if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", "echo $KSH_VERSION", nullptr }) == nullptr && ffStrbufSubstrAfterFirstS(version, " KSH ")) { // OKSH: @(#)PD KSH v5.2.14 99/07/13.2 // MKSH: @(#)MIRBSD KSH R59 2025/04/26 +Debian // $OKSH_VERSION doesn't exist on OpenBSD @@ -141,7 +141,7 @@ static bool getShellVersionKsh(FFstrbuf* exe, FFstrbuf* version) { static bool getShellVersionOksh(FFstrbuf* exe, FFstrbuf* version) { // Homebrew version - if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", "echo $OKSH_VERSION", NULL }) != NULL) { + if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", "echo $OKSH_VERSION", nullptr }) != nullptr) { return false; } @@ -151,7 +151,7 @@ static bool getShellVersionOksh(FFstrbuf* exe, FFstrbuf* version) { } static bool getShellVersionOils(FFstrbuf* exe, FFstrbuf* version) { - if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) { + if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) { return false; } @@ -189,9 +189,9 @@ static bool getShellVersionAsh(FFstrbuf* exe, FFstrbuf* version) { ffBinaryExtractStrings(exe->chars, extractBusyboxVersion, version, (uint32_t) strlen("BusyBox v0.0.0")); const char* error = ffStrbufEndsWithS(exe, "busybox") - ? ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "ash", "--help", NULL }) - : ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--help", NULL }); - if (error != NULL) { + ? ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "ash", "--help", nullptr }) + : ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--help", nullptr }); + if (error != nullptr) { return false; } @@ -209,7 +209,7 @@ static bool getShellVersionXonsh(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { } // exe is python here - if (ffProcessAppendStdErr(version, (char* const[]) { "xonsh", "--version", NULL }) != NULL) { + if (ffProcessAppendStdErr(version, (char* const[]) { "xonsh", "--version", nullptr }) != nullptr) { return false; } @@ -249,13 +249,13 @@ static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version) { return true; } - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (ffRegOpenSubkeyForRead(ffRegGetRootKeyHandle(HKEY_LOCAL_MACHINE), L"SOFTWARE\\Microsoft\\PowerShell\\3\\PowerShellEngine", &hKey, NULL) && ffRegReadStrbuf(hKey, L"PowerShellVersion", version, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (ffRegOpenSubkeyForRead(ffRegGetRootKeyHandle(HKEY_LOCAL_MACHINE), L"SOFTWARE\\Microsoft\\PowerShell\\3\\PowerShellEngine", &hKey, nullptr) && ffRegReadStrbuf(hKey, L"PowerShellVersion", version, nullptr)) { return true; } // Extremely slow - return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-NoLogo", "-NoProfile", "-Command", "$PSVersionTable.PSVersion.ToString()", NULL }) == NULL; + return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-NoLogo", "-NoProfile", "-Command", "$PSVersionTable.PSVersion.ToString()", nullptr }) == nullptr; } #endif @@ -309,7 +309,7 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) return getShellVersionWinPowerShell(exe, version); } - return getFileVersion(exe, NULL, version); + return getFileVersion(exe, nullptr, version); #endif return false; @@ -341,7 +341,7 @@ FF_A_UNUSED static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* version } } - if (ffProcessAppendStdOut(version, (char* const[]) { "gnome-terminal", "--version", NULL })) { + if (ffProcessAppendStdOut(version, (char* const[]) { "gnome-terminal", "--version", nullptr })) { return false; } @@ -363,7 +363,7 @@ FF_A_UNUSED static bool getTerminalVersionXfce4Terminal(FFstrbuf* exe, FFstrbuf* } FF_A_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version) { - if (ffProcessAppendStdOut(version, (char* const[]) { "kgx", "--version", NULL })) { + if (ffProcessAppendStdOut(version, (char* const[]) { "kgx", "--version", nullptr })) { return false; } @@ -377,7 +377,7 @@ FF_A_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* versi const char* konsoleVersion = getenv("KONSOLE_VERSION"); if (konsoleVersion) { // 221201 - long major = strtol(konsoleVersion, NULL, 10); + long major = strtol(konsoleVersion, nullptr, 10); if (major >= 0) { long patch = major % 100; major /= 100; @@ -397,7 +397,7 @@ FF_A_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* versi FF_A_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* version) { uint32_t major = 0, minor = 0, patch = 0; - if (ffGetTerminalResponse("\e[>c", 3, "\e[>1;%2u%2u%2u;0c", &major, &minor, &patch) == NULL) { + if (ffGetTerminalResponse("\e[>c", 3, "\e[>1;%2u%2u%2u;0c", &major, &minor, &patch) == nullptr) { ffStrbufSetF(version, "%u.%u.%u", major, minor, patch); return true; } @@ -441,7 +441,7 @@ FF_A_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* versi FF_A_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version) { ffStrbufSetS(version, getenv("XTERM_VERSION")); if (!version->length) { - if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-v", NULL })) { + if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-v", nullptr })) { return false; } } @@ -453,7 +453,7 @@ FF_A_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version } FF_A_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* version) { - if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL })) { + if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr })) { return false; } @@ -466,7 +466,7 @@ FF_A_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* vers FF_A_UNUSED static bool getTerminalVersionUrxvt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdErr(version, (char* const[]) { "urxvt", // Don't use exe because of urxvtd "-invalid", - NULL })) { + nullptr })) { return false; } @@ -479,7 +479,7 @@ FF_A_UNUSED static bool getTerminalVersionUrxvt(FF_A_UNUSED FFstrbuf* exe, FFstr } FF_A_UNUSED static bool getTerminalVersionSt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { - if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "-v", NULL })) { + if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "-v", nullptr })) { return false; } @@ -500,7 +500,7 @@ FF_A_UNUSED static bool getTerminalVersionLxterminal(FFstrbuf* exe, FFstrbuf* ve FF_A_UNUSED static bool getTerminalVersionWeston(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { // weston-terminal doesn't report a version, use weston version instead - if (ffProcessAppendStdOut(version, (char* const[]) { "weston", "--version", NULL })) { + if (ffProcessAppendStdOut(version, (char* const[]) { "weston", "--version", nullptr })) { return false; } @@ -565,7 +565,7 @@ static bool getTerminalVersionScreen(FFstrbuf* exe, FFstrbuf* version) { } static bool getTerminalVersionTmux(FFstrbuf* exe, FFstrbuf* version) { - if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-V", NULL }) != NULL) { + if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-V", nullptr }) != nullptr) { return false; } @@ -593,7 +593,7 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version) { #endif ); - if (ffProcessAppendStdOut(version, (char* const[]) { cli.chars, "--version", NULL }) != NULL) { + if (ffProcessAppendStdOut(version, (char* const[]) { cli.chars, "--version", nullptr }) != nullptr) { return false; } @@ -621,7 +621,7 @@ static bool getTerminalVersionSshd(FFstrbuf* exe, FFstrbuf* version) { FF_STRBUF_AUTO_DESTROY exePath = ffStrbufCreate(); if (ffIsAbsolutePath(exe->chars)) { ffStrbufSet(&exePath, exe); - } else if (ffFindExecutableInPath("sshd", &exePath) != NULL) { + } else if (ffFindExecutableInPath("sshd", &exePath) != nullptr) { return false; } @@ -630,7 +630,7 @@ static bool getTerminalVersionSshd(FFstrbuf* exe, FFstrbuf* version) { return true; } - if (ffProcessAppendStdOut(version, (char* const[]) { exePath.chars, "-V", NULL }) != NULL) { + if (ffProcessAppendStdOut(version, (char* const[]) { exePath.chars, "-V", nullptr }) != nullptr) { return false; } @@ -669,7 +669,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { } } #elif __APPLE__ - if (ffGetAppNameAndVersion(exe->chars, NULL, version)) { + if (ffGetAppNameAndVersion(exe->chars, nullptr, version)) { return true; } #endif @@ -680,7 +680,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { "\eP+q6b697474792d71756572792d76657273696f6e\e\\", // kitty-query-version 1, "\eP1+r%*[^=]=%63[^\e]\e\\\\", - versionHex) == NULL) { + versionHex) == nullptr) { // decode hex string for (const char* p = versionHex; p[0] && p[1]; p += 2) { unsigned value; @@ -696,7 +696,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { } FF_A_UNUSED static bool getTerminalVersionPtyxis(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { - if (ffProcessAppendStdOut(version, (char* const[]) { "ptyxis", "--version", NULL }) != NULL) { + if (ffProcessAppendStdOut(version, (char* const[]) { "ptyxis", "--version", nullptr }) != nullptr) { return false; } @@ -713,7 +713,7 @@ FF_A_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version } } - if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) { + if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) { return false; } @@ -731,7 +731,7 @@ FF_A_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version } FF_A_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* version) { - if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) { // sakura version is 3.8.8 + if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) { // sakura version is 3.8.8 return false; } @@ -740,7 +740,7 @@ FF_A_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* versio } FF_A_UNUSED static bool getTerminalVersionTermite(FFstrbuf* exe, FFstrbuf* version) { - if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) { // termite v16.9\nvte 0.78.1 +BIDI +GNUTLS +ICU +SYSTEMD + if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) { // termite v16.9\nvte 0.78.1 +BIDI +GNUTLS +ICU +SYSTEMD return false; } @@ -762,7 +762,7 @@ static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version) return true; } - return getFileVersion(exe, NULL, version); + return getFileVersion(exe, nullptr, version); } static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version) { @@ -772,7 +772,7 @@ static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version) { return true; } - return getFileVersion(exe, NULL, version); + return getFileVersion(exe, nullptr, version); } #endif @@ -980,11 +980,11 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_A_UNUSED FFstrbuf* exe, FF #ifdef _WIN32 - return getFileVersion(exe, NULL, version); + return getFileVersion(exe, nullptr, version); #elif __APPLE__ - return ffGetAppNameAndVersion(exe->chars, NULL, version); + return ffGetAppNameAndVersion(exe->chars, nullptr, version); #else diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 1eccf26eb..ae7e07b9c 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -21,7 +21,7 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid) { pid_t ppid = 0; int32_t tty = -1; - const char* userShellName = NULL; + const char* userShellName = nullptr; { uint32_t index = ffStrbufLastIndexC(&instance.state.platform.userShell, '/'); if (index == instance.state.platform.userShell.length) { @@ -31,7 +31,7 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid) { } } - while (pid > 1 && ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, &tty) == NULL) { + while (pid > 1 && ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, &tty) == nullptr) { if (!ffStrbufEqualS(&result->processName, userShellName)) { // Common programs that are between terminal and own process, but are not the shell if ( @@ -79,7 +79,7 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid) { static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid) { pid_t ppid = 0; - while (pid > 1 && ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, NULL) == NULL) { + while (pid > 1 && ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, nullptr) == nullptr) { // Known shells if ( pid == 1 || // init/systemd @@ -130,7 +130,7 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid) { break; } } - if (pLeft == pRight && ffProcessGetBasicInfoLinux(ppid, &result->processName, &ppid, NULL) != NULL) { + if (pLeft == pRight && ffProcessGetBasicInfoLinux(ppid, &result->processName, &ppid, nullptr) != nullptr) { return 0; } } @@ -147,13 +147,13 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid) { static bool getTerminalInfoByPidEnv(FFTerminalResult* result, const char* pidEnv) { const char* envStr = getenv(pidEnv); - if (envStr == NULL) { + if (envStr == nullptr) { return false; } - pid_t pid = (pid_t) strtol(envStr, NULL, 10); + pid_t pid = (pid_t) strtol(envStr, nullptr, 10); result->pid = (uint32_t) pid; - if (ffProcessGetBasicInfoLinux(pid, &result->processName, (pid_t*) &result->ppid, NULL) == NULL) { + if (ffProcessGetBasicInfoLinux(pid, &result->processName, (pid_t*) &result->ppid, nullptr) == nullptr) { ffProcessGetInfoLinux(pid, &result->processName, &result->exe, &result->exeName, &result->exePath); return true; } @@ -185,15 +185,15 @@ static void getTerminalFromEnv(FFTerminalResult* result) { result->pid = result->ppid = 0; } - const char* term = NULL; + const char* term = nullptr; // SSH if ( - getenv("SSH_TTY") != NULL) { + getenv("SSH_TTY") != nullptr) { term = getenv("SSH_TTY"); } else if ( - getenv("KITTY_PID") != NULL || - getenv("KITTY_INSTALLATION_DIR") != NULL) { + getenv("KITTY_PID") != nullptr || + getenv("KITTY_INSTALLATION_DIR") != nullptr) { if (getTerminalInfoByPidEnv(result, "KITTY_PID")) { return; } @@ -203,29 +203,29 @@ static void getTerminalFromEnv(FFTerminalResult* result) { #ifdef __linux__ // WSL // Windows Terminal else if ( - getenv("WT_SESSION") != NULL || - getenv("WT_PROFILE_ID") != NULL) + getenv("WT_SESSION") != nullptr || + getenv("WT_PROFILE_ID") != nullptr) term = "Windows Terminal"; // ConEmu else if ( - getenv("ConEmuPID") != NULL) { + getenv("ConEmuPID") != nullptr) { term = "ConEmu"; } #endif // Alacritty else if ( - getenv("ALACRITTY_SOCKET") != NULL || - getenv("ALACRITTY_LOG") != NULL || - getenv("ALACRITTY_WINDOW_ID") != NULL) { + getenv("ALACRITTY_SOCKET") != nullptr || + getenv("ALACRITTY_LOG") != nullptr || + getenv("ALACRITTY_WINDOW_ID") != nullptr) { term = "Alacritty"; } #ifdef __ANDROID__ // Termux else if ( - getenv("TERMUX_VERSION") != NULL || - getenv("TERMUX_MAIN_PACKAGE_FORMAT") != NULL) { + getenv("TERMUX_VERSION") != nullptr || + getenv("TERMUX_MAIN_PACKAGE_FORMAT") != nullptr) { if (getTerminalInfoByPidEnv(result, "TERMUX_APP__PID")) { return; } @@ -236,22 +236,22 @@ static void getTerminalFromEnv(FFTerminalResult* result) { #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__GNU__) // Konsole else if ( - getenv("KONSOLE_VERSION") != NULL) + getenv("KONSOLE_VERSION") != nullptr) term = "konsole"; else if ( - getenv("GNOME_TERMINAL_SCREEN") != NULL || - getenv("GNOME_TERMINAL_SERVICE") != NULL) { + getenv("GNOME_TERMINAL_SCREEN") != nullptr || + getenv("GNOME_TERMINAL_SERVICE") != nullptr) { term = "gnome-terminal"; } #endif // MacOS, mintty - else if (getenv("TERM_PROGRAM") != NULL) { + else if (getenv("TERM_PROGRAM") != nullptr) { term = getenv("TERM_PROGRAM"); } - else if (getenv("LC_TERMINAL") != NULL) { + else if (getenv("LC_TERMINAL") != nullptr) { term = getenv("LC_TERMINAL"); } @@ -398,7 +398,7 @@ const FFShellResult* ffDetectShell() { const char* ignoreParent = getenv("FFTS_IGNORE_PARENT"); if (ignoreParent && ffStrEquals(ignoreParent, "1")) { FF_STRBUF_AUTO_DESTROY _ = ffStrbufCreate(); - ffProcessGetBasicInfoLinux(ppid, &_, &ppid, NULL); + ffProcessGetBasicInfoLinux(ppid, &_, &ppid, nullptr); } ppid = getShellInfo(&result, ppid); diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index d037663c8..08cdb17ba 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -36,7 +36,7 @@ static uint32_t getShellInfo(FFShellResult* result, uint32_t pid) { ffStrbufClear(&result->processName); ffStrbufClear(&result->prettyName); ffStrbufClear(&result->exe); - result->exeName = NULL; + result->exeName = nullptr; pid = ppid; continue; } @@ -70,7 +70,7 @@ static void setShellInfoDetails(FFShellResult* result) { ffStrbufSetS(&result->prettyName, "CMD"); if (instance.config.general.detectVersion) { - FF_AUTO_CLOSE_FD HANDLE snapshot = NULL; + FF_AUTO_CLOSE_FD HANDLE snapshot = nullptr; while (!(snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, result->pid)) && GetLastError() == ERROR_BAD_LENGTH) {} if (snapshot) { @@ -79,7 +79,7 @@ static void setShellInfoDetails(FFShellResult* result) { for (BOOL success = Module32FirstW(snapshot, &module); success; success = Module32NextW(snapshot, &module)) { if (wcsncmp(module.szModule, L"clink_dll_", strlen("clink_dll_")) == 0) { FF_STRBUF_AUTO_DESTROY clinkVersion = ffStrbufCreate(); - if (ffGetFileVersion(module.szExePath, NULL, &clinkVersion)) { + if (ffGetFileVersion(module.szExePath, nullptr, &clinkVersion)) { ffStrbufAppendF(&result->prettyName, " (with Clink %s)", clinkVersion.chars); } else { ffStrbufAppendS(&result->prettyName, " (with Clink)"); @@ -109,9 +109,9 @@ static bool getTerminalFromEnv(FFTerminalResult* result) { if (term) { // ConEmu - uint32_t pid = (uint32_t) strtoul(term, NULL, 10); + uint32_t pid = (uint32_t) strtoul(term, nullptr, 10); result->pid = pid; - if (ffProcessGetInfoWindows(pid, NULL, &result->processName, &result->exe, &result->exeName, &result->exePath, NULL)) { + if (ffProcessGetInfoWindows(pid, nullptr, &result->processName, &result->exe, &result->exeName, &result->exePath, nullptr)) { ffStrbufSet(&result->prettyName, &result->processName); if (ffStrbufEndsWithIgnCaseS(&result->prettyName, ".exe")) { ffStrbufSubstrBefore(&result->prettyName, result->prettyName.length - 4); @@ -123,17 +123,17 @@ static bool getTerminalFromEnv(FFTerminalResult* result) { } // SSH - if (getenv("SSH_TTY") != NULL) { + if (getenv("SSH_TTY") != nullptr) { term = getenv("SSH_TTY"); } // Windows Terminal - if (!term && (getenv("WT_SESSION") != NULL || getenv("WT_PROFILE_ID") != NULL)) { + if (!term && (getenv("WT_SESSION") != nullptr || getenv("WT_PROFILE_ID") != nullptr)) { term = "WindowsTerminal"; } // Alacritty - if (!term && (getenv("ALACRITTY_SOCKET") != NULL || getenv("ALACRITTY_LOG") != NULL || getenv("ALACRITTY_WINDOW_ID") != NULL)) { + if (!term && (getenv("ALACRITTY_SOCKET") != nullptr || getenv("ALACRITTY_LOG") != nullptr || getenv("ALACRITTY_WINDOW_ID") != nullptr)) { term = "Alacritty"; } @@ -160,32 +160,32 @@ static bool getTerminalFromEnv(FFTerminalResult* result) { static bool detectDefaultTerminal(FFTerminalResult* result) { wchar_t regPath[128] = L"SOFTWARE\\Classes\\PackagedCom\\ClassIndex\\"; wchar_t* uuid = regPath + strlen("SOFTWARE\\Classes\\PackagedCom\\ClassIndex\\"); - FF_AUTO_CLOSE_FD HANDLE hkcu = NULL; - if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Console\\%%Startup", &hkcu, NULL) && + FF_AUTO_CLOSE_FD HANDLE hkcu = nullptr; + if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Console\\%%Startup", &hkcu, nullptr) && ffRegReadData(hkcu, L"DelegationTerminal", &(FFArgBuffer) { .data = uuid, .length = (uint32_t) (sizeof(regPath) - (size_t) (uuid - regPath) * sizeof(wchar_t)), }, - NULL)) { + nullptr)) { if (wcscmp(uuid, L"{00000000-0000-0000-0000-000000000000}") == 0 || // Let Windows decide wcscmp(uuid, L"{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}") == 0) // Conhost { goto conhost; } - FF_AUTO_CLOSE_FD HANDLE hklm = NULL; - if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regPath, &hklm, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hklm = nullptr; + if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regPath, &hklm, nullptr)) { FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); - if (ffRegGetSubKey(hklm, 0, &path, NULL)) { + if (ffRegGetSubKey(hklm, 0, &path, nullptr)) { if (ffStrbufStartsWithS(&path, "Microsoft.WindowsTerminal")) { ffStrbufSetS(&result->processName, "WindowsTerminal.exe"); ffStrbufSetS(&result->prettyName, "WindowsTerminal"); - PWSTR programFiles = NULL; - if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, NULL, &programFiles))) { + PWSTR programFiles = nullptr; + if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, nullptr, &programFiles))) { ffStrbufSetWS(&result->exe, programFiles); CoTaskMemFree(programFiles); - programFiles = NULL; + programFiles = nullptr; ffStrbufAppendS(&result->exe, "\\WindowsApps\\"); ffStrbufAppend(&result->exe, &path); @@ -211,7 +211,7 @@ conhost:; ULONG size; if (NT_SUCCESS(NtQueryInformationProcess(NtCurrentProcess(), ProcessConsoleHostProcess, &conhostPid, sizeof(conhostPid), &size)) && conhostPid != 0) { // For Windows Terminal, it reports the PID of OpenConsole - if (ffProcessGetInfoWindows((uint32_t) conhostPid, NULL, &result->processName, &result->exe, &result->exeName, &result->exePath, NULL)) { + if (ffProcessGetInfoWindows((uint32_t) conhostPid, nullptr, &result->processName, &result->exe, &result->exeName, &result->exePath, nullptr)) { ffStrbufSet(&result->prettyName, &result->processName); if (ffStrbufEndsWithIgnCaseS(&result->prettyName, ".exe")) { ffStrbufSubstrBefore(&result->prettyName, result->prettyName.length - 4); @@ -311,13 +311,13 @@ const FFShellResult* ffDetectShell(void) { result.tty = -1; uint32_t ppid; - if (!ffProcessGetInfoWindows(0, &ppid, NULL, NULL, NULL, NULL, NULL)) { + if (!ffProcessGetInfoWindows(0, &ppid, nullptr, nullptr, nullptr, nullptr, nullptr)) { return &result; } const char* ignoreParent = getenv("FFTS_IGNORE_PARENT"); if (ignoreParent && ffStrEquals(ignoreParent, "1")) { - ffProcessGetInfoWindows(ppid, &ppid, NULL, NULL, NULL, NULL, NULL); + ffProcessGetInfoWindows(ppid, &ppid, nullptr, nullptr, nullptr, nullptr, nullptr); } ppid = getShellInfo(&result, ppid); diff --git a/src/detection/terminalsize/terminalsize_windows.c b/src/detection/terminalsize/terminalsize_windows.c index 05888e78b..8e8af789a 100644 --- a/src/detection/terminalsize/terminalsize_windows.c +++ b/src/detection/terminalsize/terminalsize_windows.c @@ -9,7 +9,7 @@ bool ffDetectTerminalSize(FFTerminalSizeResult* result) { { DWORD outputMode; if (!GetConsoleMode(hOutput, &outputMode)) { - hConout = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, NULL); + hConout = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, nullptr); hOutput = hConout; } } diff --git a/src/detection/terminaltheme/terminaltheme.c b/src/detection/terminaltheme/terminaltheme.c index e609754d7..41b67f88a 100644 --- a/src/detection/terminaltheme/terminaltheme.c +++ b/src/detection/terminaltheme/terminaltheme.c @@ -14,7 +14,7 @@ static bool detectByEscapeCode(FFTerminalThemeResult* result) { &result->fg.b, &result->bg.r, &result->bg.g, - &result->bg.b) == NULL) { + &result->bg.b) == nullptr) { if (result->fg.r > 0x0100 || result->fg.g > 0x0100 || result->fg.b > 0x0100) { result->fg.r /= 0x0100, result->fg.g /= 0x0100, result->fg.b /= 0x0100; } diff --git a/src/detection/theme/theme_apple.c b/src/detection/theme/theme_apple.c index a60d39cdb..99ee1d38a 100644 --- a/src/detection/theme/theme_apple.c +++ b/src/detection/theme/theme_apple.c @@ -18,5 +18,5 @@ const char* ffDetectTheme(FFThemeResult* result) { } } - return NULL; + return nullptr; } diff --git a/src/detection/theme/theme_linux.c b/src/detection/theme/theme_linux.c index 1de7db819..6f2bc2117 100644 --- a/src/detection/theme/theme_linux.c +++ b/src/detection/theme/theme_linux.c @@ -56,5 +56,5 @@ const char* ffDetectTheme(FFThemeResult* result) { ffStrbufAppendS(&result->theme1, " [Qt]"); } - return NULL; + return nullptr; } diff --git a/src/detection/theme/theme_windows.c b/src/detection/theme/theme_windows.c index 339b79be9..68372eb0c 100644 --- a/src/detection/theme/theme_windows.c +++ b/src/detection/theme/theme_windows.c @@ -23,5 +23,5 @@ const char* ffDetectTheme(FFThemeResult* result) { ffStrbufSetStatic(&result->theme1, "Aero"); } } - return NULL; + return nullptr; } diff --git a/src/detection/tpm/tpm_apple.c b/src/detection/tpm/tpm_apple.c index 250dd014e..b97ecf05b 100644 --- a/src/detection/tpm/tpm_apple.c +++ b/src/detection/tpm/tpm_apple.c @@ -10,7 +10,7 @@ const char* ffDetectTPM(FFTPMResult* result) { ffStrbufSetStatic(&result->version, "2.0"); ffStrbufSetStatic(&result->description, "Apple Silicon Security"); - return NULL; + return nullptr; #else @@ -21,7 +21,7 @@ const char* ffDetectTPM(FFTPMResult* result) { if (t2Service) { ffStrbufSetStatic(&result->version, "2.0"); ffStrbufSetStatic(&result->description, "Apple T2 Security Chip"); - return NULL; + return nullptr; } #endif diff --git a/src/detection/tpm/tpm_bsd.c b/src/detection/tpm/tpm_bsd.c index 4b7341306..1df25fb47 100644 --- a/src/detection/tpm/tpm_bsd.c +++ b/src/detection/tpm/tpm_bsd.c @@ -3,7 +3,7 @@ #include "common/kmod.h" const char* ffDetectTPM(FFTPMResult* result) { - if (ffSysctlGetString("dev.tpmcrb.0.%desc", &result->description) != NULL) { + if (ffSysctlGetString("dev.tpmcrb.0.%desc", &result->description) != nullptr) { if (!ffKmodLoaded("tpm")) { return "`tpm` kernel module is not loaded"; } @@ -18,5 +18,5 @@ const char* ffDetectTPM(FFTPMResult* result) { ffStrbufSetStatic(&result->version, "unknown"); } - return NULL; + return nullptr; } diff --git a/src/detection/tpm/tpm_linux.c b/src/detection/tpm/tpm_linux.c index 040da38cc..7a54f27f8 100644 --- a/src/detection/tpm/tpm_linux.c +++ b/src/detection/tpm/tpm_linux.c @@ -20,5 +20,5 @@ const char* ffDetectTPM(FFTPMResult* result) { ffStrbufTrimRightSpace(&result->description); } - return NULL; + return nullptr; } diff --git a/src/detection/tpm/tpm_windows.c b/src/detection/tpm/tpm_windows.c index 14f6e8a4e..bf3746a62 100644 --- a/src/detection/tpm/tpm_windows.c +++ b/src/detection/tpm/tpm_windows.c @@ -47,5 +47,5 @@ const char* ffDetectTPM(FFTPMResult* result) { break; } - return NULL; + return nullptr; } diff --git a/src/detection/uptime/uptime_bsd.c b/src/detection/uptime/uptime_bsd.c index 46943b029..00d052b37 100644 --- a/src/detection/uptime/uptime_bsd.c +++ b/src/detection/uptime/uptime_bsd.c @@ -12,7 +12,7 @@ const char* ffDetectUptime(FFUptimeResult* result) { #endif size_t bootTimeSize = sizeof(bootTime); if (sysctl( - (int[]) { CTL_KERN, KERN_BOOTTIME }, 2, &bootTime, &bootTimeSize, NULL, 0) != 0) { + (int[]) { CTL_KERN, KERN_BOOTTIME }, 2, &bootTime, &bootTimeSize, nullptr, 0) != 0) { return "sysctl({CTL_KERN, KERN_BOOTTIME}) failed"; } @@ -23,5 +23,5 @@ const char* ffDetectUptime(FFUptimeResult* result) { #endif result->uptime = ffTimeGetNow() - result->bootTime; - return NULL; + return nullptr; } diff --git a/src/detection/uptime/uptime_haiku.c b/src/detection/uptime/uptime_haiku.c index bf5dd25c7..58434f0b1 100644 --- a/src/detection/uptime/uptime_haiku.c +++ b/src/detection/uptime/uptime_haiku.c @@ -4,5 +4,5 @@ const char* ffDetectUptime(FFUptimeResult* result) { result->uptime = (uint64_t) system_time() / 1000; result->bootTime = ffTimeGetNow() - result->uptime; - return NULL; + return nullptr; } diff --git a/src/detection/uptime/uptime_linux.c b/src/detection/uptime/uptime_linux.c index 75c7768a8..9ac709416 100644 --- a/src/detection/uptime/uptime_linux.c +++ b/src/detection/uptime/uptime_linux.c @@ -13,12 +13,12 @@ const char* ffDetectUptime(FFUptimeResult* result) { if (nRead > 0) { buf[nRead] = '\0'; - char* err = NULL; + char* err = nullptr; double sec = strtod(buf, &err); if (err != buf) { result->uptime = (uint64_t) (sec * 1000); result->bootTime = ffTimeGetNow() - result->uptime; - return NULL; + return nullptr; } } @@ -31,7 +31,7 @@ const char* ffDetectUptime(FFUptimeResult* result) { result->uptime = (uint64_t) uptime.tv_sec * 1000 + (uint64_t) uptime.tv_nsec / 1000000; result->bootTime = ffTimeGetNow() - result->uptime; - return NULL; + return nullptr; #else return "read(/proc/uptime) failed"; #endif diff --git a/src/detection/uptime/uptime_sunos.c b/src/detection/uptime/uptime_sunos.c index 2a372999e..1e6aa4fd2 100644 --- a/src/detection/uptime/uptime_sunos.c +++ b/src/detection/uptime/uptime_sunos.c @@ -7,7 +7,7 @@ const char* ffDetectUptime(FFUptimeResult* result) { struct utmpx* ut; setutxent(); - while (NULL != (ut = getutxent())) { + while (nullptr != (ut = getutxent())) { if (ut->ut_type == BOOT_TIME) { result->bootTime = (uint64_t) ut->ut_tv.tv_sec * 1000 + (uint64_t) ut->ut_tv.tv_usec / 1000000; result->uptime = ffTimeGetNow() - result->bootTime; @@ -15,5 +15,5 @@ const char* ffDetectUptime(FFUptimeResult* result) { } } endutxent(); - return NULL; + return nullptr; } diff --git a/src/detection/uptime/uptime_windows.c b/src/detection/uptime/uptime_windows.c index 695edadea..5abf68ae0 100644 --- a/src/detection/uptime/uptime_windows.c +++ b/src/detection/uptime/uptime_windows.c @@ -13,5 +13,5 @@ const char* ffDetectUptime(FFUptimeResult* result) { // whose result exactly equals what WMI `Win32_OperatingSystem` reports // with much lower accuracy (0.5 seconds) - return NULL; + return nullptr; } diff --git a/src/detection/users/users_linux.c b/src/detection/users/users_linux.c index bc84eedbf..8135cb6d6 100644 --- a/src/detection/users/users_linux.c +++ b/src/detection/users/users_linux.c @@ -52,7 +52,7 @@ bool detectUserBySystemd(const FFstrbuf* pathUsers, FFlist* users) { FF_STRBUF_AUTO_DESTROY remoteHost = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY service = ffStrbufCreate(); - char* token = NULL; + char* token = nullptr; size_t n = 0; while (ffStrbufGetdelim(&token, &n, ' ', &sessions)) { ffStrbufSubstrBefore(&pathSessions, pathSessionsBaseLen); @@ -116,7 +116,7 @@ const char* detectBySystemd(FFUsersOptions* options, FFlist* users) { ffStrbufSubstrBefore(&pathUsers, pathUsersBaseLen); } } - return NULL; + return nullptr; } #endif @@ -132,12 +132,12 @@ static void fillUtmpIpAddr(FFUserResult* user, struct utmpx* n) { if (isIpv6) { char ipv6_str[INET6_ADDRSTRLEN]; - if (inet_ntop(AF_INET6, n->ut_addr_v6, ipv6_str, INET6_ADDRSTRLEN) != NULL) { + if (inet_ntop(AF_INET6, n->ut_addr_v6, ipv6_str, INET6_ADDRSTRLEN) != nullptr) { ffStrbufSetS(&user->clientIp, ipv6_str); } } else if (n->ut_addr_v6[0] != 0) { char ipv4_str[INET_ADDRSTRLEN]; - if (inet_ntop(AF_INET, n->ut_addr_v6, ipv4_str, INET_ADDRSTRLEN) != NULL) { + if (inet_ntop(AF_INET, n->ut_addr_v6, ipv4_str, INET_ADDRSTRLEN) != nullptr) { ffStrbufSetS(&user->clientIp, ipv4_str); } } @@ -148,7 +148,7 @@ static void fillUtmpIpAddr(FF_A_UNUSED FFUserResult* user, FF_A_UNUSED struct ut #endif const char* detectByUtmp(FFUsersOptions* options, FFlist* users) { - struct utmpx* n = NULL; + struct utmpx* n = nullptr; setutxent(); next: @@ -185,7 +185,7 @@ next: endutxent(); - return NULL; + return nullptr; } const char* ffDetectUsers(FFUsersOptions* options, FFlist* users) { @@ -200,5 +200,5 @@ const char* ffDetectUsers(FFUsersOptions* options, FFlist* users) { } #endif - return NULL; + return nullptr; } diff --git a/src/detection/users/users_obsd.c b/src/detection/users/users_obsd.c index 97a22f039..fa10112cc 100644 --- a/src/detection/users/users_obsd.c +++ b/src/detection/users/users_obsd.c @@ -35,5 +35,5 @@ next: user->loginTime = (uint64_t) n.ut_time * 1000; } - return NULL; + return nullptr; } diff --git a/src/detection/users/users_windows.c b/src/detection/users/users_windows.c index 4cde44e31..837159a74 100644 --- a/src/detection/users/users_windows.c +++ b/src/detection/users/users_windows.c @@ -35,7 +35,7 @@ const char* ffDetectUsers(FFUsersOptions* options, FFlist* users) { user->loginTime = 0; DWORD bytes = 0; - PWTS_CLIENT_ADDRESS address = NULL; + PWTS_CLIENT_ADDRESS address = nullptr; if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, session->SessionId, WTSClientAddress, (LPWSTR*) &address, &bytes)) { if (address->AddressFamily == AF_INET) { ffStrbufSetF(&user->clientIp, "%u.%u.%u.%u", address->Address[2], address->Address[3], address->Address[4], address->Address[5]); @@ -48,7 +48,7 @@ const char* ffDetectUsers(FFUsersOptions* options, FFlist* users) { } bytes = 0; - PWTSINFOW wtsInfo = NULL; + PWTSINFOW wtsInfo = nullptr; if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, session->SessionId, WTSSessionInfo, (LPWSTR*) &wtsInfo, &bytes)) { user->loginTime = ffFileTimeToUnixMs((uint64_t) wtsInfo->LogonTime.QuadPart); WTSFreeMemory(wtsInfo); @@ -57,5 +57,5 @@ const char* ffDetectUsers(FFUsersOptions* options, FFlist* users) { WTSFreeMemoryExW(WTSTypeSessionInfoLevel1, sessionInfo, 1); - return NULL; + return nullptr; } diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index a6b6fefc0..635df6ff6 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -29,7 +29,7 @@ static void applyDriverName(VkPhysicalDeviceDriverPropertiesKHR* properties, FFs * Some drivers (android for example) expose a multiline string as driver info. * It contains too much info anyways, so we just don't append it. */ - if (!ffStrSet(properties->driverInfo) || strchr(properties->driverInfo, '\n') != NULL) { + if (!ffStrSet(properties->driverInfo) || strchr(properties->driverInfo, '\n') != nullptr) { return; } @@ -67,8 +67,8 @@ static const char* detectVulkan(FFVulkanResult* result) { // We need to get the function pointer this way, because it is only provided by vulkan 1.1 and higher. // a dlsym would fail on 1.0 implementations - PFN_vkEnumerateInstanceVersion ffvkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) ffvkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion"); - if (ffvkEnumerateInstanceVersion != NULL) { + PFN_vkEnumerateInstanceVersion ffvkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) ffvkGetInstanceProcAddr(nullptr, "vkEnumerateInstanceVersion"); + if (ffvkEnumerateInstanceVersion != nullptr) { uint32_t version; if (ffvkEnumerateInstanceVersion(&version) == VK_SUCCESS) { applyVulkanVersion(version, &instanceVersion); @@ -89,10 +89,10 @@ static const char* detectVulkan(FFVulkanResult* result) { FF_DEBUG("Creating Vulkan instance with requested API version %s", instanceVersion.minor >= 1 ? "1.1" : "1.0"); VkResult res = ffvkCreateInstance(&(VkInstanceCreateInfo) { .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, - .pNext = NULL, + .pNext = nullptr, .pApplicationInfo = &(VkApplicationInfo) { .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, - .pNext = NULL, + .pNext = nullptr, .pApplicationName = FASTFETCH_PROJECT_NAME, .applicationVersion = projectVersion, .pEngineName = "vulkanPrintGPUs", @@ -101,11 +101,11 @@ static const char* detectVulkan(FFVulkanResult* result) { // We need to request 1.1 to get physicalDeviceDriverProperties .apiVersion = instanceVersion.minor >= 1 ? VK_API_VERSION_1_1 : VK_API_VERSION_1_0 }, .enabledLayerCount = 0, - .ppEnabledLayerNames = NULL, + .ppEnabledLayerNames = nullptr, .enabledExtensionCount = 0, - .ppEnabledExtensionNames = NULL, + .ppEnabledExtensionNames = nullptr, .flags = 0 }, - NULL, + nullptr, &vkInstance); if (res != VK_SUCCESS) { FF_DEBUG("ffvkCreateInstance() failed with VkResult=%d", res); @@ -140,7 +140,7 @@ static const char* detectVulkan(FFVulkanResult* result) { res = ffvkEnumeratePhysicalDevices(vkInstance, &physicalDeviceCount, physicalDevices); if (res != VK_SUCCESS) { FF_DEBUG("ffvkEnumeratePhysicalDevices() failed with VkResult=%d", res); - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); switch (res) { case VK_ERROR_OUT_OF_HOST_MEMORY: return "ffvkEnumeratePhysicalDevices() failed: VK_ERROR_OUT_OF_HOST_MEMORY"; @@ -156,7 +156,7 @@ static const char* detectVulkan(FFVulkanResult* result) { } FF_DEBUG("Enumerated %u Vulkan physical device(s)", physicalDeviceCount); - PFN_vkGetPhysicalDeviceProperties ffvkGetPhysicalDeviceProperties = NULL; + PFN_vkGetPhysicalDeviceProperties ffvkGetPhysicalDeviceProperties = nullptr; PFN_vkGetPhysicalDeviceProperties2 ffvkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceProperties2"); // 1.1 if (!ffvkGetPhysicalDeviceProperties2) { ffvkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceProperties"); @@ -167,7 +167,7 @@ static const char* detectVulkan(FFVulkanResult* result) { PFN_vkGetPhysicalDeviceMemoryProperties ffvkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceMemoryProperties"); if (!ffvkGetPhysicalDeviceMemoryProperties) { FF_DEBUG("vkGetPhysicalDeviceMemoryProperties is unavailable"); - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); return "vkGetPhysicalDeviceMemoryProperties is not available"; } @@ -187,7 +187,7 @@ static const char* detectVulkan(FFVulkanResult* result) { .pNext = &driverProperties, }; - if (ffvkGetPhysicalDeviceProperties2 != NULL) { + if (ffvkGetPhysicalDeviceProperties2 != nullptr) { ffvkGetPhysicalDeviceProperties2(physicalDevices[i], &physicalDeviceProperties); } else { ffvkGetPhysicalDeviceProperties(physicalDevices[i], &physicalDeviceProperties.properties); @@ -296,9 +296,9 @@ static const char* detectVulkan(FFVulkanResult* result) { result->conformanceVersion.chars, result->gpus.length); - ffvkDestroyInstance(vkInstance, NULL); + ffvkDestroyInstance(vkInstance, nullptr); FF_DEBUG("Destroyed Vulkan instance"); - return NULL; + return nullptr; } #endif diff --git a/src/detection/wallpaper/wallpaper_apple.m b/src/detection/wallpaper/wallpaper_apple.m index 800aee9ce..f4ba8a682 100644 --- a/src/detection/wallpaper/wallpaper_apple.m +++ b/src/detection/wallpaper/wallpaper_apple.m @@ -40,7 +40,7 @@ const char* ffDetectWallpaper(FFstrbuf* result) } } if (result->length > 0) - return NULL; + return nullptr; } } @@ -60,13 +60,13 @@ const char* ffDetectWallpaper(FFstrbuf* result) "JOIN spaces ON pictures.space_id=spaces.ROWID\n" "WHERE display_id=1 AND space_id=1 AND key=1", result) ) - return NULL; + return nullptr; } #endif if (ffOsascript("tell application \"Finder\" to get POSIX path of (get desktop picture as alias)", result)) - return NULL; + return nullptr; return "All detection methods failed"; } diff --git a/src/detection/wallpaper/wallpaper_haiku.cpp b/src/detection/wallpaper/wallpaper_haiku.cpp index 0bfad62bb..ee17f16a0 100644 --- a/src/detection/wallpaper/wallpaper_haiku.cpp +++ b/src/detection/wallpaper/wallpaper_haiku.cpp @@ -50,5 +50,5 @@ const char* ffDetectWallpaper(FFstrbuf* result) { } ffStrbufAppendS(result, path.String()); - return NULL; + return nullptr; } diff --git a/src/detection/wallpaper/wallpaper_linux.c b/src/detection/wallpaper/wallpaper_linux.c index f5ad4eca7..cde966254 100644 --- a/src/detection/wallpaper/wallpaper_linux.c +++ b/src/detection/wallpaper/wallpaper_linux.c @@ -19,9 +19,9 @@ static const char* detectCosmicComp(FFstrbuf* result) { if (!ffStrbufEqualS(&cleaned, "[]")) { const char* firstQuote = strchr(backgrounds.chars, '"'); - if (firstQuote != NULL) { + if (firstQuote != nullptr) { const char* secondQuote = strchr(firstQuote + 1, '"'); - if (secondQuote != NULL && secondQuote > firstQuote + 1) { + if (secondQuote != nullptr && secondQuote > firstQuote + 1) { ffStrbufAppendNS(&monitorName, (uint32_t) (secondQuote - firstQuote - 1), firstQuote + 1); sharedWallpaper = false; } @@ -43,12 +43,12 @@ static const char* detectCosmicComp(FFstrbuf* result) { } const char* sourceStart = strstr(output.chars, "source:"); - if (sourceStart == NULL) { + if (sourceStart == nullptr) { return "COSMIC wallpaper config doesn't contain source"; } const char* pathStart = strstr(sourceStart, "Path("); - if (pathStart == NULL) { + if (pathStart == nullptr) { return "COSMIC wallpaper source is not a Path value"; } @@ -64,12 +64,12 @@ static const char* detectCosmicComp(FFstrbuf* result) { char quote = *pathStart; ++pathStart; const char* pathEnd = strchr(pathStart, quote); - if (pathEnd == NULL || pathEnd == pathStart) { + if (pathEnd == nullptr || pathEnd == pathStart) { return "COSMIC wallpaper path is empty"; } ffStrbufAppendNS(result, (uint32_t) (pathEnd - pathStart), pathStart); - return NULL; + return nullptr; } const char* ffDetectWallpaper(FFstrbuf* result) { @@ -78,7 +78,7 @@ const char* ffDetectWallpaper(FFstrbuf* result) { return detectCosmicComp(result); } - const FFstrbuf* wallpaper = NULL; + const FFstrbuf* wallpaper = nullptr; const FFGTKResult* gtk = ffDetectGTK4(); if (gtk->wallpaper.length) { wallpaper = >k->wallpaper; @@ -98,5 +98,5 @@ const char* ffDetectWallpaper(FFstrbuf* result) { } else { ffStrbufAppend(result, wallpaper); } - return NULL; + return nullptr; } diff --git a/src/detection/wallpaper/wallpaper_windows.c b/src/detection/wallpaper/wallpaper_windows.c index 2adf08394..7357d39fd 100644 --- a/src/detection/wallpaper/wallpaper_windows.c +++ b/src/detection/wallpaper/wallpaper_windows.c @@ -2,14 +2,14 @@ #include "common/windows/registry.h" const char* ffDetectWallpaper(FFstrbuf* result) { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop", &hKey, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop", &hKey, nullptr)) { return "ffRegOpenKeyForRead(Control Panel\\Desktop) failed"; } - if (!ffRegReadStrbuf(hKey, L"WallPaper", result, NULL)) { + if (!ffRegReadStrbuf(hKey, L"WallPaper", result, nullptr)) { return "ffRegReadStrbuf(WallPaper) failed"; } - return NULL; + return nullptr; } diff --git a/src/detection/weather/weather.c b/src/detection/weather/weather.c index 69df64290..8a70a966a 100644 --- a/src/detection/weather/weather.c +++ b/src/detection/weather/weather.c @@ -37,7 +37,7 @@ const char* ffDetectWeather(FFWeatherOptions* options, FFstrbuf* result) { ffPrepareWeather(options); } - if (status != NULL) { + if (status != nullptr) { return status; } @@ -47,7 +47,7 @@ const char* ffDetectWeather(FFWeatherOptions* options, FFstrbuf* result) { state = (FFNetworkingState) {}; status = FF_UNITIALIZED; - if (error == NULL) { + if (error == nullptr) { ffStrbufSubstrAfterFirstS(result, "\r\n\r\n"); ffStrbufTrimRightSpace(result); } else { @@ -58,5 +58,5 @@ const char* ffDetectWeather(FFWeatherOptions* options, FFstrbuf* result) { return "Empty server response received"; } - return NULL; + return nullptr; } diff --git a/src/detection/wifi/wifi_android.c b/src/detection/wifi/wifi_android.c index c4537da07..bf1ceab48 100644 --- a/src/detection/wifi/wifi_android.c +++ b/src/detection/wifi/wifi_android.c @@ -16,11 +16,11 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) { const char* ffDetectWifi(FFlist* result) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); - if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL })) { + if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, nullptr })) { return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; } - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); if (!doc) { return "Failed to parse wifi connection info"; } @@ -47,11 +47,11 @@ const char* ffDetectWifi(FFlist* result) { ffStrbufAppendJsonVal(&item->inf.status, yyjson_obj_get(root, "supplicant_state")); if (!item->inf.status.length) { ffStrbufAppendS(&item->inf.status, "Unknown"); - return NULL; + return nullptr; } if (!ffStrbufEqualS(&item->inf.status, "COMPLETED")) { - return NULL; + return nullptr; } double rssi = yyjson_get_num(yyjson_obj_get(root, "rssi")); @@ -65,5 +65,5 @@ const char* ffDetectWifi(FFlist* result) { item->conn.txRate = yyjson_get_num(yyjson_obj_get(root, "link_speed_mbps")); item->conn.channel = ffWifiFreqToChannel(item->conn.frequency); - return NULL; + return nullptr; } diff --git a/src/detection/wifi/wifi_apple.m b/src/detection/wifi/wifi_apple.m index 21808e03d..f718179bd 100644 --- a/src/detection/wifi/wifi_apple.m +++ b/src/detection/wifi/wifi_apple.m @@ -161,5 +161,5 @@ const char* ffDetectWifi(FFlist* result) } } - return NULL; + return nullptr; } diff --git a/src/detection/wifi/wifi_bsd.c b/src/detection/wifi/wifi_bsd.c index 4b49b4e56..7ef816ad5 100644 --- a/src/detection/wifi/wifi_bsd.c +++ b/src/detection/wifi/wifi_bsd.c @@ -20,7 +20,7 @@ const char* ffDetectWifi(FFlist* result) { return "socket() failed"; } - for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) { + for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == nullptr); ++i) { if (!ffStrStartsWith(i->if_name, "wlan")) { continue; } @@ -119,7 +119,7 @@ const char* ffDetectWifi(FFlist* result) { } ireq.i_type = IEEE80211_IOC_AUTHMODE; - ireq.i_data = NULL; + ireq.i_data = nullptr; ireq.i_len = 0; if (ioctl(sock, SIOCG80211, &ireq) >= 0) { switch (ireq.i_val) { @@ -159,5 +159,5 @@ const char* ffDetectWifi(FFlist* result) { } if_freenameindex(infs); - return NULL; + return nullptr; } diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 6f761590d..c609c25c4 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -61,7 +61,7 @@ static const struct nlattr* ffWifiNlAttrNext(const struct nlattr* attr, size_t* size_t alignedLen = NLA_ALIGN(attr->nla_len); if (alignedLen > *remaining) { *remaining = 0; - return NULL; + return nullptr; } *remaining -= alignedLen; @@ -131,7 +131,7 @@ static bool ffWifiNlGetFamilyId(FFWifiNlContext* ctx) { uint8_t buffer[8192]; while (true) { - ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, NULL, NULL); + ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, nullptr, nullptr); if (received < 0) { FF_DEBUG("Failed to receive nl80211 family reply: %s", strerror(errno)); return false; @@ -502,7 +502,7 @@ static bool ffWifiFetchScanInfo(FFWifiNlContext* ctx, FFWifiResult* item, uint32 uint8_t buffer[1024 * 16]; while (true) { - ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, NULL, NULL); + ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, nullptr, nullptr); if (received < 0) { FF_DEBUG("Failed to receive nl80211 scan reply: %s", strerror(errno)); return false; @@ -617,7 +617,7 @@ static bool ffWifiFetchStationInfo(FFWifiNlContext* ctx, FFWifiResult* item, uin uint8_t buffer[8192]; bool gotStation = false; while (true) { - ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, NULL, NULL); + ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, nullptr, nullptr); if (received < 0) { FF_DEBUG("Failed to receive nl80211 station reply: %s", strerror(errno)); return gotStation; @@ -690,7 +690,7 @@ static const char* detectWithNetlink(FFWifiNlContext* ctx, FFWifiResult* item, u } FF_DEBUG("Netlink wifi detection completed"); - return NULL; + return nullptr; } #endif @@ -884,7 +884,7 @@ static const char* detectWithIoctl(FFWifiIcContext* ctx, FFWifiResult* item, cha } FF_DEBUG("Ioctl wifi detection completed"); - return NULL; + return nullptr; } const char* ffDetectWifi(FFlist* result) { @@ -903,7 +903,7 @@ const char* ffDetectWifi(FFlist* result) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); - for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) { + for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == nullptr); ++i) { FF_DEBUG("Checking interface: %s (index: %u)", i->if_name, i->if_index); ffStrbufSetF(&buffer, "/sys/class/net/%s/phy80211/", i->if_name); if (!ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY)) { @@ -952,7 +952,7 @@ const char* ffDetectWifi(FFlist* result) { } flags[len] = '\0'; - unsigned flagsVal = (unsigned) strtoul(flags, NULL, 16); // parse /sys flags as hexadecimal + unsigned flagsVal = (unsigned) strtoul(flags, nullptr, 16); // parse /sys flags as hexadecimal if (flagsVal & IFF_UP) { ffStrbufSetStatic(&item->inf.status, "up"); } else { @@ -972,5 +972,5 @@ const char* ffDetectWifi(FFlist* result) { } FF_DEBUG("Wifi detection completed, found %u wifi interfaces", result->length); - return NULL; + return nullptr; } diff --git a/src/detection/wifi/wifi_nbsd.c b/src/detection/wifi/wifi_nbsd.c index 52897c487..ea8c2ace7 100644 --- a/src/detection/wifi/wifi_nbsd.c +++ b/src/detection/wifi/wifi_nbsd.c @@ -30,7 +30,7 @@ const char* ffDetectWifi(FFlist* result) { return "socket() failed"; } - for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) { + for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == nullptr); ++i) { if (!ffStrStartsWith(i->if_name, "iwm")) { continue; } @@ -134,7 +134,7 @@ const char* ffDetectWifi(FFlist* result) { } ireq.i_type = IEEE80211_IOC_AUTHMODE; - ireq.i_data = NULL; + ireq.i_data = nullptr; ireq.i_len = 0; if (ioctl(sock, SIOCG80211, &ireq) >= 0) { switch (ireq.i_val) { @@ -164,5 +164,5 @@ const char* ffDetectWifi(FFlist* result) { } if_freenameindex(infs); - return NULL; + return nullptr; } diff --git a/src/detection/wifi/wifi_obsd.c b/src/detection/wifi/wifi_obsd.c index f686231b3..bcaec97fd 100644 --- a/src/detection/wifi/wifi_obsd.c +++ b/src/detection/wifi/wifi_obsd.c @@ -20,7 +20,7 @@ const char* ffDetectWifi(FFlist* result) { return "socket() failed"; } - for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) { + for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == nullptr); ++i) { if (!ffStrStartsWith(i->if_name, "iwm")) { continue; } @@ -105,5 +105,5 @@ const char* ffDetectWifi(FFlist* result) { } if_freenameindex(infs); - return NULL; + return nullptr; } diff --git a/src/detection/wifi/wifi_windows.c b/src/detection/wifi/wifi_windows.c index 125c314cc..8e900ad42 100644 --- a/src/detection/wifi/wifi_windows.c +++ b/src/detection/wifi/wifi_windows.c @@ -50,16 +50,16 @@ const char* ffDetectWifi(FFlist* result) { FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanGetNetworkBssList) DWORD curVersion; - HANDLE hClient = NULL; - WLAN_INTERFACE_INFO_LIST* ifList = NULL; - const char* error = NULL; + HANDLE hClient = nullptr; + WLAN_INTERFACE_INFO_LIST* ifList = nullptr; + const char* error = nullptr; - if (ffWlanOpenHandle(2, NULL, &curVersion, &hClient) != ERROR_SUCCESS) { + if (ffWlanOpenHandle(2, nullptr, &curVersion, &hClient) != ERROR_SUCCESS) { error = "WlanOpenHandle() failed"; goto exit; } - if (ffWlanEnumInterfaces(hClient, NULL, &ifList) != ERROR_SUCCESS) { + if (ffWlanEnumInterfaces(hClient, nullptr, &ifList) != ERROR_SUCCESS) { error = "WlanEnumInterfaces() failed"; goto exit; } @@ -87,14 +87,14 @@ const char* ffDetectWifi(FFlist* result) { continue; } - WLAN_CONNECTION_ATTRIBUTES* connInfo = NULL; + WLAN_CONNECTION_ATTRIBUTES* connInfo = nullptr; DWORD bufSize = sizeof(*connInfo); WLAN_OPCODE_VALUE_TYPE opCode = wlan_opcode_value_type_query_only; if (ffWlanQueryInterface(hClient, &ifInfo->InterfaceGuid, wlan_intf_opcode_current_connection, - NULL, + nullptr, &bufSize, (PVOID*) &connInfo, &opCode) != ERROR_SUCCESS) { @@ -200,13 +200,13 @@ const char* ffDetectWifi(FFlist* result) { ffStrbufAppendS(&item->conn.security, "Insecure"); } - WLAN_BSS_LIST* bssList = NULL; + WLAN_BSS_LIST* bssList = nullptr; if (ffWlanGetNetworkBssList(hClient, &ifInfo->InterfaceGuid, &connInfo->wlanAssociationAttributes.dot11Ssid, connInfo->wlanAssociationAttributes.dot11BssType, connInfo->wlanSecurityAttributes.bSecurityEnabled, - NULL, + nullptr, &bssList) == ERROR_SUCCESS && bssList->dwNumberOfItems > 0) { item->conn.frequency = (uint16_t) (bssList->wlanBssEntries[0].ulChCenterFrequency / 1000); @@ -220,7 +220,7 @@ const char* ffDetectWifi(FFlist* result) { if (ffWlanQueryInterface(hClient, &ifInfo->InterfaceGuid, wlan_intf_opcode_channel_number, - NULL, + nullptr, &bufSize, (PVOID*) &channelNumber, &opCode) == ERROR_SUCCESS) { @@ -234,7 +234,7 @@ exit: ffWlanFreeMemory(ifList); } if (hClient) { - ffWlanCloseHandle(hClient, NULL); + ffWlanCloseHandle(hClient, nullptr); } return error; } diff --git a/src/detection/wm/wm_apple.m b/src/detection/wm/wm_apple.m index 89273e939..d414c20c1 100644 --- a/src/detection/wm/wm_apple.m +++ b/src/detection/wm/wm_apple.m @@ -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; } diff --git a/src/detection/wm/wm_linux.c b/src/detection/wm/wm_linux.c index c890de4aa..c7c700938 100644 --- a/src/detection/wm/wm_linux.c +++ b/src/detection/wm/wm_linux.c @@ -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`"; diff --git a/src/detection/wm/wm_windows.c b/src/detection/wm/wm_windows.c index ee363995b..0a3fc9adf 100644 --- a/src/detection/wm/wm_windows.c +++ b/src/detection/wm/wm_windows.c @@ -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"; } diff --git a/src/detection/wmtheme/wmtheme_haiku.cpp b/src/detection/wmtheme/wmtheme_haiku.cpp index 243eaa43e..267e4e486 100644 --- a/src/detection/wmtheme/wmtheme_haiku.cpp +++ b/src/detection/wmtheme/wmtheme_haiku.cpp @@ -12,7 +12,7 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) BApplication app("application/x-vnd.fastfetch-cli-fastfetch"); DecorInfoUtility *util = new DecorInfoUtility(); - DecorInfo* decor = NULL; + DecorInfo* decor = nullptr; if (util) { decor = util->CurrentDecorator(); diff --git a/src/detection/wmtheme/wmtheme_linux.c b/src/detection/wmtheme/wmtheme_linux.c index e9123025d..1c46e7822 100644 --- a/src/detection/wmtheme/wmtheme_linux.c +++ b/src/detection/wmtheme/wmtheme_linux.c @@ -15,7 +15,7 @@ static bool detectWMThemeFromConfigFile(const char* configFile, const char* them } if (themeOrError->length == 0) { - if (defaultValue == NULL) { + if (defaultValue == nullptr) { ffStrbufAppendF(themeOrError, "Couldn't find WM theme in %s", configFile); return false; } @@ -77,7 +77,7 @@ ok: } static bool detectMutter(FFstrbuf* themeOrError) { - const char* theme = ffSettingsGetGnome("/org/gnome/shell/extensions/user-theme/name", "org.gnome.shell.extensions.user-theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue; + const char* theme = ffSettingsGetGnome("/org/gnome/shell/extensions/user-theme/name", "org.gnome.shell.extensions.user-theme", nullptr, "name", FF_VARIANT_TYPE_STRING).strValue; if (ffStrSet(theme)) { ffStrbufAppendS(themeOrError, theme); return true; @@ -87,20 +87,20 @@ static bool detectMutter(FFstrbuf* themeOrError) { } static bool detectMuffin(FFstrbuf* themeOrError) { - FF_AUTO_FREE const char* name = ffSettingsGetGnome("/org/cinnamon/theme/name", "org.cinnamon.theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue; - FF_AUTO_FREE const char* theme = ffSettingsGetGnome("/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", NULL, "theme", FF_VARIANT_TYPE_STRING).strValue; + FF_AUTO_FREE const char* name = ffSettingsGetGnome("/org/cinnamon/theme/name", "org.cinnamon.theme", nullptr, "name", FF_VARIANT_TYPE_STRING).strValue; + FF_AUTO_FREE const char* theme = ffSettingsGetGnome("/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", nullptr, "theme", FF_VARIANT_TYPE_STRING).strValue; - if (name == NULL && theme == NULL) { + if (name == nullptr && theme == nullptr) { ffStrbufAppendS(themeOrError, "Couldn't find muffin theme in GSettings / DConf"); return false; } - if (name == NULL) { + if (name == nullptr) { ffStrbufAppendS(themeOrError, theme); return true; } - if (theme == NULL) { + if (theme == nullptr) { ffStrbufAppendS(themeOrError, name); return true; } @@ -112,7 +112,7 @@ static bool detectMuffin(FFstrbuf* themeOrError) { static bool detectXFWM4(FFstrbuf* themeOrError) { const char* theme = ffSettingsGetXFConf("xfwm4", "/general/theme", FF_VARIANT_TYPE_STRING).strValue; - if (theme == NULL) { + if (theme == nullptr) { ffStrbufAppendS(themeOrError, "Couldn't find xfwm4::/general/theme in XFConf"); return false; } @@ -142,22 +142,22 @@ static bool detectOpenbox(const FFstrbuf* dePrettyName, FFstrbuf* themeOrError) } const char* themeStart = strstr(content.chars, ""); - if (themeStart == NULL) { + if (themeStart == nullptr) { goto theme_not_found; } const char* themeEnd = strstr(themeStart, ""); - if (__builtin_expect(themeEnd == NULL, false)) { // very rare case + if (__builtin_expect(themeEnd == nullptr, false)) { // very rare case goto theme_not_found; } const char* nameStart = strstr(themeStart, ""); - if (nameStart == NULL) { + if (nameStart == nullptr) { goto name_not_found; } const char* nameEnd = strstr(nameStart, ""); - if (nameEnd == NULL || nameEnd > themeEnd) { // (nameEnd > themeEnd) means name is not a theme's child + if (nameEnd == nullptr || nameEnd > themeEnd) { // (nameEnd > themeEnd) means name is not a theme's child goto name_not_found; } @@ -216,9 +216,9 @@ static bool detectCosmicComp(FFstrbuf* themeOrError) { ffStrbufAppendF(&path, "com.system76.CosmicTheme.%s/v1/accent", variant); if (ffReadFileBuffer(path.chars, &accent)) { const char* baseStart = strstr(accent.chars, "base:"); - if (baseStart != NULL) { + if (baseStart != nullptr) { const char* contentStart = strchr(baseStart, '('); - if (contentStart != NULL) { + if (contentStart != nullptr) { int depth = 1; const char* contentEnd = contentStart + 1; while (*contentEnd != '\0' && depth > 0) { @@ -237,13 +237,13 @@ static bool detectCosmicComp(FFstrbuf* themeOrError) { const char* key = i == 0 ? "red:" : (i == 1 ? "green:" : (i == 2 ? "blue:" : "alpha:")); const char* componentStart = strstr(contentStart, key); - if (componentStart == NULL || componentStart >= contentEnd) { + if (componentStart == nullptr || componentStart >= contentEnd) { ok = false; break; } componentStart += strlen(key); - char* componentEnd = NULL; + char* componentEnd = nullptr; double value = strtod(componentStart, &componentEnd); if (componentEnd == componentStart) { ok = false; @@ -323,7 +323,7 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) { } if (ffStrbufIgnCaseEqualS(&wm->wmPrettyName, FF_WM_PRETTY_MARCO)) { - return detectWMThemeFromSettings("/org/mate/Marco/general/theme", "org.mate.Marco.general", NULL, "theme", themeOrError); + return detectWMThemeFromSettings("/org/mate/Marco/general/theme", "org.mate.Marco.general", nullptr, "theme", themeOrError); } if (ffStrbufIgnCaseEqualS(&wm->wmPrettyName, FF_WM_PRETTY_OPENBOX)) { diff --git a/src/detection/wmtheme/wmtheme_windows.c b/src/detection/wmtheme/wmtheme_windows.c index 5d16a84bb..adaece574 100644 --- a/src/detection/wmtheme/wmtheme_windows.c +++ b/src/detection/wmtheme/wmtheme_windows.c @@ -105,16 +105,16 @@ const char* colorHexToString(DWORD hex) { case 0xFFFFFF: return "White"; default: - return NULL; + return nullptr; } } bool ffDetectWmTheme(FFstrbuf* themeOrError) { { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes", &hKey, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes", &hKey, nullptr)) { FF_STRBUF_AUTO_DESTROY theme = ffStrbufCreate(); - if (ffRegReadStrbuf(hKey, L"CurrentTheme", &theme, NULL)) { + if (ffRegReadStrbuf(hKey, L"CurrentTheme", &theme, nullptr)) { ffStrbufSubstrBeforeLastC(&theme, '.'); ffStrbufSubstrAfterLastC(&theme, '\\'); if (isalpha(theme.chars[0])) { @@ -129,11 +129,11 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) { do { uint32_t rgbColor; uint32_t bgrColor; - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\DWM", &hKey, NULL)) { - if (ffRegReadUint(hKey, L"AccentColor", &bgrColor, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\DWM", &hKey, nullptr)) { + if (ffRegReadUint(hKey, L"AccentColor", &bgrColor, nullptr)) { rgbColor = ((bgrColor & 0xFF) << 16) | (bgrColor & 0xFF00) | ((bgrColor >> 16) & 0xFF); - } else if (ffRegReadUint(hKey, L"ColorizationColor", &rgbColor, NULL)) { + } else if (ffRegReadUint(hKey, L"ColorizationColor", &rgbColor, nullptr)) { rgbColor &= 0xFFFFFF; } else { break; @@ -154,14 +154,14 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) { } while (false); { - FF_AUTO_CLOSE_FD HANDLE hKey = NULL; - if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", &hKey, NULL)) { + FF_AUTO_CLOSE_FD HANDLE hKey = nullptr; + if (ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", &hKey, nullptr)) { uint32_t system = 1, apps = 1; if (ffRegReadValues(hKey, 2, (FFRegValueArg[]) { FF_ARG(system, L"SystemUsesLightTheme"), FF_ARG(apps, L"AppsUseLightTheme"), }, - NULL)) { + nullptr)) { bool paren = themeOrError->length > 0; if (paren) { ffStrbufAppendS(themeOrError, " ("); diff --git a/src/detection/zpool/zpool.c b/src/detection/zpool/zpool.c index ce7abb37f..ee648b725 100644 --- a/src/detection/zpool/zpool.c +++ b/src/detection/zpool/zpool.c @@ -43,7 +43,7 @@ typedef struct FFZfsData { static inline void cleanLibzfs(FFZfsData* data) { if (data->fflibzfs_fini && data->handle) { data->fflibzfs_fini(data->handle); - data->handle = NULL; + data->handle = nullptr; } } @@ -118,7 +118,7 @@ const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */) { return "zpool_iter() failed"; } - return NULL; + return nullptr; } #else diff --git a/src/fastfetch.c b/src/fastfetch.c index e64440925..38070a5dc 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -17,7 +17,7 @@ FF_A_COLD static void printCommandFormatHelpJson(void) { - yyjson_mut_doc* doc = yyjson_mut_doc_new(NULL); + yyjson_mut_doc* doc = yyjson_mut_doc_new(nullptr); yyjson_mut_val* root = yyjson_mut_obj(doc); yyjson_mut_doc_set_root(doc, root); @@ -45,7 +45,7 @@ static void printCommandFormatHelpJson(void) { } } } - yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_PRETTY, NULL, NULL); + yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_PRETTY, nullptr, nullptr); putchar('\n'); yyjson_mut_doc_free(doc); } @@ -307,7 +307,7 @@ static bool printSpecificCommandHelp(const char* command) { FF_A_COLD static void printCommandHelp(const char* command) { - if (command == NULL) { + if (command == nullptr) { printFullHelp(); } else if (ffStrEqualsIgnCase(command, "format-json")) { printCommandFormatHelpJson(); @@ -382,15 +382,15 @@ static bool parseJsoncFile(FFdata* data, const char* path, yyjson_read_flag flg) { yyjson_read_err error; data->configDoc = path - ? yyjson_read_file(path, flg, NULL, &error) - : yyjson_read_fp(stdin, flg, NULL, &error); + ? yyjson_read_file(path, flg, nullptr, &error) + : yyjson_read_fp(stdin, flg, nullptr, &error); if (!data->configDoc) { if (error.code != YYJSON_READ_ERROR_FILE_OPEN) { if (path) { size_t row = 0, col = error.pos; FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); if (ffAppendFileBuffer(path, &content)) { - yyjson_locate_pos(content.chars, content.length, error.pos, &row, &col, NULL); + yyjson_locate_pos(content.chars, content.length, error.pos, &row, &col, nullptr); } fprintf(stderr, "Error: failed to parse JSON config file `%s` at (%zu, %zu): %s\n", path, row, col, error.msg); } else { @@ -410,9 +410,9 @@ static bool parseJsoncFile(FFdata* data, const char* path, yyjson_read_flag flg) exit(477); } - yyjson_val* problematicKey = NULL; - const char* error = NULL; - const char* problematicModule = NULL; + yyjson_val* problematicKey = nullptr; + const char* error = nullptr; + const char* problematicModule = nullptr; if ( error || ((error = ffOptionsParseLogoJsonConfig(&instance.config.logo, root, &problematicKey)) && (problematicModule = "logo")) || @@ -458,7 +458,7 @@ static void generateConfigFile(FFdata* data, bool force, const char* filePath, b } data->docType = fullConfig ? FF_RESULT_DOC_TYPE_CONFIG_FULL : FF_RESULT_DOC_TYPE_CONFIG; - data->resultDoc = yyjson_mut_doc_new(NULL); + data->resultDoc = yyjson_mut_doc_new(nullptr); } static void optionParseConfigFile(FFdata* data, const char* key, const char* value) { @@ -469,7 +469,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val data->configLoaded = true; - if (value == NULL) { + if (value == nullptr) { fprintf(stderr, "Error: usage: %s \n", key); exit(413); } @@ -479,7 +479,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val } if (value[0] == '-' && value[1] == '\0') { - parseJsoncFile(data, NULL, false); + parseJsoncFile(data, nullptr, false); return; } @@ -581,7 +581,7 @@ static void enableJsonOutput(FFdata* data) { exit(477); } - data->resultDoc = yyjson_mut_doc_new(NULL); + data->resultDoc = yyjson_mut_doc_new(nullptr); data->docType = FF_RESULT_DOC_TYPE_JSON; yyjson_mut_doc_set_root(data->resultDoc, yyjson_mut_arr(data->resultDoc)); } @@ -741,7 +741,7 @@ static void parseArguments(FFdata* data, int argc, char** argv, void (*parser)(F if (i == argc - 1 || (argv[i + 1][0] == '-' && argv[i + 1][1] != '\0' && // `-` is used as an alias for `/dev/stdin` !ffStrEqualsIgnCase(argv[i], "--separator-string") // Separator string can start with a - )) { - parser(data, argv[i], NULL); + parser(data, argv[i], nullptr); } else { parser(data, argv[i], argv[i + 1]); ++i; @@ -800,7 +800,7 @@ static void run(FFdata* data) { } if (data->resultDoc) { - yyjson_mut_write_fp(stdout, data->resultDoc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES | YYJSON_WRITE_NEWLINE_AT_END, NULL, NULL); + yyjson_mut_write_fp(stdout, data->resultDoc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES | YYJSON_WRITE_NEWLINE_AT_END, nullptr, nullptr); } else { if (instance.config.logo.printRemaining) { ffLogoPrintRemaining(); @@ -826,7 +826,7 @@ static void writeConfigFile(FFdata* data) { ffMigrateCommandOptionToJsonc(data); if (ffStrbufEqualS(filename, "-")) { - yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES | YYJSON_WRITE_NEWLINE_AT_END, NULL, NULL); + yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES | YYJSON_WRITE_NEWLINE_AT_END, nullptr, nullptr); } else { size_t len; FF_AUTO_FREE const char* str = yyjson_mut_write(doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES | YYJSON_WRITE_NEWLINE_AT_END, &len); diff --git a/src/logo/image/im6.c b/src/logo/image/im6.c index 824e25a55..9fb4338c5 100644 --- a/src/logo/image/im6.c +++ b/src/logo/image/im6.c @@ -25,7 +25,7 @@ FFLogoImageResult ffLogoPrintImageIM6(FFLogoRequestData* requestData) { .library = imageMagick, }); - imageMagick = NULL; // leak imageMagick to prevent fastfetch from crashing #552 + imageMagick = nullptr; // leak imageMagick to prevent fastfetch from crashing #552 return result; } diff --git a/src/logo/image/im7.c b/src/logo/image/im7.c index 796a2caee..967e79ea0 100644 --- a/src/logo/image/im7.c +++ b/src/logo/image/im7.c @@ -31,7 +31,7 @@ FFLogoImageResult ffLogoPrintImageIM7(FFLogoRequestData* requestData) { .library = imageMagick, }); - imageMagick = NULL; // leak imageMagick to prevent fastfetch from crashing #552 + imageMagick = nullptr; // leak imageMagick to prevent fastfetch from crashing #552 return result; } diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 673582fe1..bc33e67f7 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -156,7 +156,7 @@ static bool printImageKittyIcat(bool printError) { uint32_t prevLength = buf.length; - const char* error = NULL; + const char* error = nullptr; if (options->width) { char place[64]; @@ -176,7 +176,7 @@ static bool printImageKittyIcat(bool printError) { place, "--scale-up", options->source.chars, - NULL, + nullptr, }); } else { error = ffProcessAppendStdOut(&buf, (char*[]) { @@ -185,7 +185,7 @@ static bool printImageKittyIcat(bool printError) { "-n", "--align=left", options->source.chars, - NULL, + nullptr, }); } if (error) { @@ -374,7 +374,7 @@ static bool compressBlob(void** blob, size_t* length) { uLong compressedLength = ffcompressBound(*length); void* compressed = malloc(compressedLength); - if (compressed == NULL) { + if (compressed == nullptr) { return false; } @@ -410,7 +410,7 @@ typedef struct ImageData { } ImageData; static inline bool checkAllocationResult(void* data, size_t length) { - if (data == NULL) { + if (data == nullptr) { return false; } @@ -578,7 +578,7 @@ static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* ima } ChafaSymbolMap* symbolMap = ffchafa_symbol_map_new(); - GError* error = NULL; + GError* error = nullptr; if (!ffchafa_symbol_map_apply_selectors(symbolMap, instance.config.logo.chafaSymbols.chars, &error)) { fputs(error->message, stderr); } @@ -621,7 +621,7 @@ static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* ima (gint) imageData->image->rows, (gint) imageData->image->columns * 4); - GString* str = ffchafa_canvas_print(canvas, NULL); + GString* str = ffchafa_canvas_print(canvas, nullptr); FFstrbuf result; result.allocated = (uint32_t) str->allocated_len; result.length = (uint32_t) str->len; @@ -666,16 +666,16 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI FF_LIBRARY_LOAD_SYMBOL_VAR(imData->library, imageData, ImageToBlob, FF_LOGO_IMAGE_RESULT_INIT_ERROR) FF_LIBRARY_LOAD_SYMBOL_VAR(imData->library, imageData, Base64Encode, FF_LOGO_IMAGE_RESULT_INIT_ERROR) - ffMagickCoreGenesis(NULL, MagickFalse); + ffMagickCoreGenesis(nullptr, MagickFalse); imageData.exceptionInfo = ffAcquireExceptionInfo(); - if (imageData.exceptionInfo == NULL) { + if (imageData.exceptionInfo == nullptr) { ffMagickCoreTerminus(); return FF_LOGO_IMAGE_RESULT_RUN_ERROR; } ImageInfo* imageInfoIn = ffAcquireImageInfo(); - if (imageInfoIn == NULL) { + if (imageInfoIn == nullptr) { ffDestroyExceptionInfo(imageData.exceptionInfo); ffMagickCoreTerminus(); return FF_LOGO_IMAGE_RESULT_RUN_ERROR; @@ -686,7 +686,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI imageData.image = ffReadImage(imageInfoIn, imageData.exceptionInfo); ffDestroyImageInfo(imageInfoIn); - if (imageData.image == NULL) { + if (imageData.image == nullptr) { ffDestroyExceptionInfo(imageData.exceptionInfo); ffMagickCoreTerminus(); return FF_LOGO_IMAGE_RESULT_RUN_ERROR; @@ -713,7 +713,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI Image* resized = imData->resizeFunc(imageData.image, requestData->logoPixelWidth, requestData->logoPixelHeight, imageData.exceptionInfo); ffDestroyImage(imageData.image); - if (resized == NULL) { + if (resized == nullptr) { ffDestroyExceptionInfo(imageData.exceptionInfo); ffMagickCoreTerminus(); return FF_LOGO_IMAGE_RESULT_RUN_ERROR; @@ -721,7 +721,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI imageData.image = resized; imageData.imageInfo = ffAcquireImageInfo(); - if (imageData.imageInfo == NULL) { + if (imageData.imageInfo == nullptr) { ffDestroyImage(imageData.image); ffDestroyExceptionInfo(imageData.exceptionInfo); ffMagickCoreTerminus(); @@ -757,7 +757,7 @@ static FFNativeFD getCacheFD(FFLogoRequestData* requestData, const char* fileNam #endif ); #else - HANDLE fd = CreateFileA(requestData->cacheDir.chars, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE fd = CreateFileA(requestData->cacheDir.chars, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif ffStrbufSubstrBefore(&requestData->cacheDir, cacheDirLength); return fd; @@ -843,7 +843,7 @@ static bool printCachedPixel(FFLogoRequestData* requestData) { struct stat st; if (fstat(fd, &st) >= 0) { while (st.st_size > 0) { - ssize_t bytes = sendfile(STDOUT_FILENO, fd, NULL, (size_t) st.st_size); + ssize_t bytes = sendfile(STDOUT_FILENO, fd, nullptr, (size_t) st.st_size); if (bytes > 0) { sent = true; st.st_size -= bytes; @@ -921,7 +921,7 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError) { ffStrbufEnsureFree(&requestData.cacheDir, PATH_MAX); char* filePath = requestData.cacheDir.chars + requestData.cacheDir.length; - if (realpath(instance.config.logo.source.chars, filePath) == NULL) { + if (realpath(instance.config.logo.source.chars, filePath) == nullptr) { // We can safely return here, because if realpath failed, we surely won't be able to read the file ffStrbufDestroy(&requestData.cacheDir); if (printError) { diff --git a/src/logo/logo.c b/src/logo/logo.c index 571f1aac9..1cc3211dc 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -56,7 +56,7 @@ static void logoLineCacheBuild(FFLogoLineCacheState* cache, const char* data, bo } for (uint32_t i = 0; i < options->paddingTop; ++i) { - logoLineCachePush(NULL, 0, cache); + logoLineCachePush(nullptr, 0, cache); } if (*data != '\0') { @@ -184,7 +184,7 @@ static void logoLineCacheBuild(FFLogoLineCacheState* cache, const char* data, bo uint32_t totalLines = instance.state.logoHeight + 1; while (cache->lines.length < totalLines) { - logoLineCachePush(NULL, 0, cache); + logoLineCachePush(nullptr, 0, cache); } cache->nextLine = 0; @@ -298,7 +298,7 @@ static void logoApplyColors(const FFlogo* logo, bool replacement) { FFOptionsLogo* options = &instance.config.logo; const char* const* colors = logo->colors; - for (int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++) { + for (int i = 0; *colors != nullptr && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++) { if (options->colors[i].length == 0) { ffStrbufAppendS(&options->colors[i], *colors); } @@ -309,7 +309,7 @@ static void logoApplyColors(const FFlogo* logo, bool replacement) { static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) { for ( const char* const* logoName = logo->names; - *logoName != NULL && logoName <= &logo->names[FASTFETCH_LOGO_MAX_NAMES]; + *logoName != nullptr && logoName <= &logo->names[FASTFETCH_LOGO_MAX_NAMES]; ++logoName) { if (small) { uint32_t logoNameLength = (uint32_t) (strlen(*logoName) - strlen("_small")); @@ -327,7 +327,7 @@ static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) { static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) { if (name->length == 0 || !isalpha(name->chars[0])) { - return NULL; + return nullptr; } for (const FFlogo* logo = ffLogoBuiltins[toupper(name->chars[0]) - 'A']; *logo->names; ++logo) { @@ -352,19 +352,19 @@ static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) { } } - return NULL; + return nullptr; } static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) { const FFOSResult* os = ffDetectOS(); const FFlogo* logo = logoGetBuiltin(&os->id, size); - if (logo != NULL) { + if (logo != nullptr) { return logo; } logo = logoGetBuiltin(&os->name, size); - if (logo != NULL) { + if (logo != nullptr) { return logo; } @@ -376,7 +376,7 @@ static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) { start = end + 1, end = ffStrbufNextIndexC(&os->idLike, start, ' ')) { ffStrbufSetNS(&buf, end - start, os->idLike.chars + start); logo = logoGetBuiltin(&buf, size); - if (logo != NULL) { + if (logo != nullptr) { return logo; } @@ -386,13 +386,13 @@ static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) { } } else { logo = logoGetBuiltin(&os->idLike, size); - if (logo != NULL) { + if (logo != nullptr) { return logo; } } logo = logoGetBuiltin(&instance.state.platform.sysinfo.name, size); - if (logo != NULL) { + if (logo != nullptr) { return logo; } @@ -427,7 +427,7 @@ static bool logoPrintBuiltinIfExists(const FFstrbuf* name, FFLogoSize size) { } const FFlogo* logo = ffLogoGetBuiltinForName(name, size); - if (logo == NULL) { + if (logo == nullptr) { return false; } @@ -561,7 +561,7 @@ static bool logoTryKnownType(void) { "/bin/sh", "-c", #endif options->source.chars, - NULL }); + nullptr }); if (error) { if (instance.config.display.showErrors) { @@ -786,7 +786,7 @@ void ffLogoBuiltinList(void) { for ( const char* const* names = logo->names; - *names != NULL && names <= &logo->names[FASTFETCH_LOGO_MAX_NAMES]; + *names != nullptr && names <= &logo->names[FASTFETCH_LOGO_MAX_NAMES]; ++names) { printf("\"%s\" ", *names); } diff --git a/src/modules/bluetoothradio/bluetoothradio.c b/src/modules/bluetoothradio/bluetoothradio.c index 1ebd34c45..518689af3 100644 --- a/src/modules/bluetoothradio/bluetoothradio.c +++ b/src/modules/bluetoothradio/bluetoothradio.c @@ -27,7 +27,7 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio })); } - const char* version = NULL; + const char* version = nullptr; switch (radio->lmpVersion < 0 ? -radio->lmpVersion : radio->lmpVersion) { case 0: diff --git a/src/modules/break/break.c b/src/modules/break/break.c index e560e18a6..76e9f0fc2 100644 --- a/src/modules/break/break.c +++ b/src/modules/break/break.c @@ -16,7 +16,7 @@ void ffParseBreakJsonObject(FF_A_UNUSED FFBreakOptions* options, FF_A_UNUSED yyj continue; } - ffPrintError(FF_BREAK_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); + ffPrintError(FF_BREAK_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); } } diff --git a/src/modules/codec/codec.c b/src/modules/codec/codec.c index 4e6889e30..5d3cbac90 100644 --- a/src/modules/codec/codec.c +++ b/src/modules/codec/codec.c @@ -174,7 +174,7 @@ void ffParseCodecJsonObject(FFCodecOptions* options, yyjson_val* module) { {}, }); if (error) { - ffPrintError(FF_CODEC_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); + ffPrintError(FF_CODEC_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); } else { options->showType = (FFCodecShowType) value; } diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index ff821d12f..43cdffb31 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -164,7 +164,7 @@ void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module) { {}, }); if (error) { - ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); + ffPrintError(FF_COLORS_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); } else { options->symbol = (FFColorsSymbol) value; } @@ -178,7 +178,7 @@ void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module) { if (unsafe_yyjson_equals_str(key, "block")) { if (!yyjson_is_obj(val)) { - ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: must be an object", unsafe_yyjson_get_str(key)); + ffPrintError(FF_COLORS_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: must be an object", unsafe_yyjson_get_str(key)); } else { yyjson_val* width = yyjson_obj_get(val, "width"); if (width) { @@ -188,14 +188,14 @@ void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module) { yyjson_val* range = yyjson_obj_get(val, "range"); if (range) { if (!yyjson_is_arr(range) || yyjson_arr_size(range) != 2) { - ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: must be an array of 2 elements", unsafe_yyjson_get_str(key)); + ffPrintError(FF_COLORS_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: must be an array of 2 elements", unsafe_yyjson_get_str(key)); } else { uint8_t start = (uint8_t) yyjson_get_uint(yyjson_arr_get(range, 0)); uint8_t end = (uint8_t) yyjson_get_uint(yyjson_arr_get(range, 1)); if (start > end) { - ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: range[0] > range[1]", unsafe_yyjson_get_str(key)); + ffPrintError(FF_COLORS_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: range[0] > range[1]", unsafe_yyjson_get_str(key)); } else if (end > 15) { - ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: range[1] > 15", unsafe_yyjson_get_str(key)); + ffPrintError(FF_COLORS_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: range[1] > 15", unsafe_yyjson_get_str(key)); } else { options->block.range[0] = start; options->block.range[1] = end; @@ -215,14 +215,14 @@ void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module) { {}, }); if (error) { - ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); + ffPrintError(FF_COLORS_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); } else { options->brightness = (FFColorsBrightness) value; } continue; } - ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); + ffPrintError(FF_COLORS_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); } } diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 989091117..fc4b3cfa0 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -19,7 +19,7 @@ bool ffPrintCommand(FFCommandOptions* options) { if (options->splitLines) { uint8_t index = 0; - char* line = NULL; + char* line = nullptr; size_t len = 0; while (ffStrbufGetline(&line, &len, &result)) { if (options->moduleArgs.outputFormat.length == 0) { @@ -110,7 +110,7 @@ bool ffGenerateCommandJsonResult(FF_A_UNUSED FFCommandOptions* options, yyjson_m if (options->splitLines) { yyjson_mut_val* jsonArray = yyjson_mut_obj_add_arr(doc, module, "result"); - char* line = NULL; + char* line = nullptr; size_t len = 0; while (ffStrbufGetline(&line, &len, &result)) { yyjson_mut_arr_add_strncpy(doc, jsonArray, line, len); diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index cb06d0723..72192e260 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -21,7 +21,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index FF_STRBUF_AUTO_DESTROY mountpointLink = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY nameLink = ffStrbufCreate(); #ifdef __linux__ - if (getenv("WSL_DISTRO_NAME") != NULL && getenv("WT_SESSION") != NULL) { + if (getenv("WSL_DISTRO_NAME") != nullptr && getenv("WT_SESSION") != nullptr) { if (ffStrbufEqualS(&disk->filesystem, "9p") && ffStrbufStartsWithS(&disk->mountpoint, "/mnt/")) { ffStrbufSetF(&mountpointLink, "\e]8;;file:///%c:/\e\\%s\e]8;;\e\\", disk->mountpoint.chars[5], disk->mountpoint.chars); ffStrbufSetF(&nameLink, "\e]8;;file:///%c:/\e\\%s\e]8;;\e\\", disk->mountpoint.chars[5], disk->name.chars); diff --git a/src/modules/display/display.c b/src/modules/display/display.c index be3d66f75..a7da2e8ba 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -65,7 +65,7 @@ bool ffPrintDisplay(FFDisplayOptions* options) { for (uint32_t i = 0; i < dsResult->displays.length; i++) { FFDisplayResult* result = FF_LIST_GET(FFDisplayResult, dsResult->displays, i); uint32_t moduleIndex = dsResult->displays.length == 1 ? 0 : i + 1; - const char* displayType = result->type == FF_DISPLAY_TYPE_UNKNOWN ? NULL : result->type == FF_DISPLAY_TYPE_BUILTIN ? "Built-in" + const char* displayType = result->type == FF_DISPLAY_TYPE_UNKNOWN ? nullptr : result->type == FF_DISPLAY_TYPE_BUILTIN ? "Built-in" : "External"; ffStrbufClear(&key); diff --git a/src/modules/dns/dns.c b/src/modules/dns/dns.c index d7c90c4d8..79df55bac 100644 --- a/src/modules/dns/dns.c +++ b/src/modules/dns/dns.c @@ -73,7 +73,7 @@ void ffParseDNSJsonObject(FFDNSOptions* options, yyjson_val* module) { {}, }); if (error) { - ffPrintError(FF_DNS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); + ffPrintError(FF_DNS_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); } else { options->showType = (FFDNSShowType) value; } diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 032474f04..163fca8fb 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -412,7 +412,7 @@ bool ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_ type = "Discrete"; break; default: - type = NULL; + type = nullptr; break; } if (type) { diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index ef4a110cd..59068614b 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -308,7 +308,7 @@ void ffGenerateLocalIpJsonConfig(FFLocalIpOptions* options, yyjson_mut_doc* doc, if (options->ipv6Type == FF_LOCALIP_IPV6_TYPE_AUTO) { yyjson_mut_obj_add_bool(doc, module, "showIpv6", !!(options->showType & FF_LOCALIP_TYPE_IPV6_BIT)); } else { - const char* str = NULL; + const char* str = nullptr; switch (options->ipv6Type) { case FF_LOCALIP_IPV6_TYPE_GUA_BIT: str = "gua"; diff --git a/src/modules/logo/logo.c b/src/modules/logo/logo.c index 54a0f97d6..a4952a726 100644 --- a/src/modules/logo/logo.c +++ b/src/modules/logo/logo.c @@ -4,7 +4,7 @@ #include "options/logo.h" bool ffPrintLogo(FF_A_UNUSED FFLogoOptions* options) { - ffPrintError(FF_LOGO_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_DEFAULT, "Supported in JSON format only"); + ffPrintError(FF_LOGO_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_DEFAULT, "Supported in JSON format only"); return false; } @@ -16,7 +16,7 @@ void ffParseLogoJsonObject(FF_A_UNUSED FFLogoOptions* options, FF_A_UNUSED yyjso continue; } - ffPrintError(FF_LOGO_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); + ffPrintError(FF_LOGO_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); } } diff --git a/src/modules/modules.c b/src/modules/modules.c index 837871187..bcc4afdf4 100644 --- a/src/modules/modules.c +++ b/src/modules/modules.c @@ -6,7 +6,7 @@ // We rely `LTO` to remove the unused code (only enabled in Release mode) static FFModuleBaseInfo* A[] = { - NULL, + nullptr, }; static FFModuleBaseInfo* B[] = { @@ -37,7 +37,7 @@ static FFModuleBaseInfo* B[] = { #if !FF_MODULE_DISABLE_BTRFS &ffBtrfsModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* C[] = { @@ -71,7 +71,7 @@ static FFModuleBaseInfo* C[] = { #if !FF_MODULE_DISABLE_CUSTOM &ffCustomModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* D[] = { @@ -93,21 +93,21 @@ static FFModuleBaseInfo* D[] = { #if !FF_MODULE_DISABLE_DNS &ffDNSModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* E[] = { #if !FF_MODULE_DISABLE_EDITOR &ffEditorModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* F[] = { #if !FF_MODULE_DISABLE_FONT &ffFontModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* G[] = { @@ -117,14 +117,14 @@ static FFModuleBaseInfo* G[] = { #if !FF_MODULE_DISABLE_GPU &ffGPUModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* H[] = { #if !FF_MODULE_DISABLE_HOST &ffHostModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* I[] = { @@ -134,11 +134,11 @@ static FFModuleBaseInfo* I[] = { #if !FF_MODULE_DISABLE_INITSYSTEM &ffInitSystemModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* J[] = { - NULL, + nullptr, }; static FFModuleBaseInfo* K[] = { @@ -148,7 +148,7 @@ static FFModuleBaseInfo* K[] = { #if !FF_MODULE_DISABLE_KEYBOARD &ffKeyboardModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* L[] = { @@ -167,7 +167,7 @@ static FFModuleBaseInfo* L[] = { #if !FF_MODULE_DISABLE_LOGO &ffLogoModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* M[] = { @@ -183,14 +183,14 @@ static FFModuleBaseInfo* M[] = { #if !FF_MODULE_DISABLE_MOUSE &ffMouseModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* N[] = { #if !FF_MODULE_DISABLE_NETIO &ffNetIOModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* O[] = { @@ -203,7 +203,7 @@ static FFModuleBaseInfo* O[] = { #if !FF_MODULE_DISABLE_OS &ffOSModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* P[] = { @@ -228,15 +228,15 @@ static FFModuleBaseInfo* P[] = { #if !FF_MODULE_DISABLE_PUBLICIP &ffPublicIPModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* Q[] = { - NULL, + nullptr, }; static FFModuleBaseInfo* R[] = { - NULL, + nullptr, }; static FFModuleBaseInfo* S[] = { @@ -252,7 +252,7 @@ static FFModuleBaseInfo* S[] = { #if !FF_MODULE_DISABLE_SWAP &ffSwapModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* T[] = { @@ -277,7 +277,7 @@ static FFModuleBaseInfo* T[] = { #if !FF_MODULE_DISABLE_TPM &ffTPMModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* U[] = { @@ -287,7 +287,7 @@ static FFModuleBaseInfo* U[] = { #if !FF_MODULE_DISABLE_USERS &ffUsersModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* V[] = { @@ -297,7 +297,7 @@ static FFModuleBaseInfo* V[] = { #if !FF_MODULE_DISABLE_VULKAN &ffVulkanModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* W[] = { @@ -316,22 +316,22 @@ static FFModuleBaseInfo* W[] = { #if !FF_MODULE_DISABLE_WMTHEME &ffWMThemeModuleInfo, #endif - NULL, + nullptr, }; static FFModuleBaseInfo* X[] = { - NULL, + nullptr, }; static FFModuleBaseInfo* Y[] = { - NULL, + nullptr, }; static FFModuleBaseInfo* Z[] = { #if !FF_MODULE_DISABLE_ZPOOL &ffZpoolModuleInfo, #endif - NULL, + nullptr, }; FFModuleBaseInfo** ffModuleInfos[] = { diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index d69b3fe79..f27ff8200 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -8,7 +8,7 @@ bool ffPrintOpenCL(FFOpenCLOptions* options) { FFOpenCLResult* result = ffDetectOpenCL(); - if (result->error != NULL) { + if (result->error != nullptr) { ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", result->error); return false; } @@ -46,7 +46,7 @@ void ffGenerateOpenCLJsonConfig(FFOpenCLOptions* options, yyjson_mut_doc* doc, y bool ffGenerateOpenCLJsonResult(FF_A_UNUSED FFOpenCLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFOpenCLResult* result = ffDetectOpenCL(); - if (result->error != NULL) { + if (result->error != nullptr) { yyjson_mut_obj_add_str(doc, module, "error", result->error); return false; } diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 0754cb20c..d325089bd 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -95,7 +95,7 @@ bool ffGenerateOpenGLJsonResult(FF_A_UNUSED FFOpenGLOptions* options, yyjson_mut ffStrbufInit(&result.library); const char* error = ffDetectOpenGL(options, &result); - if (error != NULL) { + if (error != nullptr) { yyjson_mut_obj_add_str(doc, module, "error", error); } else { yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result"); diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 4c5b4bc92..e0179b1e9 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -95,11 +95,11 @@ void ffParseSeparatorJsonObject(FFSeparatorOptions* options, yyjson_val* module) } if (unsafe_yyjson_equals_str(key, "length")) { - ffPrintError(FF_SEPARATOR_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "The option length has been renamed to times."); + ffPrintError(FF_SEPARATOR_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "The option length has been renamed to times."); continue; } - ffPrintError(FF_SEPARATOR_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); + ffPrintError(FF_SEPARATOR_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); } } diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 97e58430b..43893de38 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -124,7 +124,7 @@ void ffParseTitleJsonObject(FFTitleOptions* options, yyjson_val* module) { continue; } - ffPrintError(FF_TITLE_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); + ffPrintError(FF_TITLE_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", unsafe_yyjson_get_str(key)); } } diff --git a/src/options/display.c b/src/options/display.c index fe9481909..a60286c86 100644 --- a/src/options/display.c +++ b/src/options/display.c @@ -10,7 +10,7 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_val* root, yyjson_val** pkey) { yyjson_val* object = yyjson_obj_get(root, "display"); if (!object) { - return NULL; + return nullptr; } if (!yyjson_is_obj(object)) { return "Property 'display' must be an object"; @@ -571,11 +571,11 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va } } - return NULL; + return nullptr; } static inline void optionCheckString(const char* key, const char* value, FFstrbuf* buffer) { - if (value == NULL) { + if (value == nullptr) { fprintf(stderr, "Error: usage: %s \n", key); exit(477); } diff --git a/src/options/general.c b/src/options/general.c index 1e1355df8..d1ee8e781 100644 --- a/src/options/general.c +++ b/src/options/general.c @@ -9,7 +9,7 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_val* root, yyjson_val** pkey) { yyjson_val* object = yyjson_obj_get(root, "general"); if (!object) { - return NULL; + return nullptr; } if (!yyjson_is_obj(object)) { return "Property 'general' must be an object"; @@ -60,7 +60,7 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va } } - return NULL; + return nullptr; } bool ffOptionsParseGeneralCommandLine(FFOptionsGeneral* options, const char* key, const char* value) { diff --git a/src/options/logo.c b/src/options/logo.c index 99e22c99c..e62bd23b7 100644 --- a/src/options/logo.c +++ b/src/options/logo.c @@ -38,7 +38,7 @@ bool ffOptionsParseLogoCommandLine(FFOptionsLogo* options, const char* key, cons if (subKey) { if (subKey[0] == '\0') { logoType: - if (value == NULL) { + if (value == nullptr) { fprintf(stderr, "Error: usage: %s \n", key); exit(477); } @@ -80,7 +80,7 @@ bool ffOptionsParseLogoCommandLine(FFOptionsLogo* options, const char* key, cons fprintf(stderr, "Error: invalid --color-[1-9] index: %c\n", key[13]); exit(472); } - if (value == NULL) { + if (value == nullptr) { fprintf(stderr, "Error: usage: %s \n", key); exit(477); } @@ -219,7 +219,7 @@ void ffOptionsDestroyLogo(FFOptionsLogo* options) { const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* root, yyjson_val** pkey) { yyjson_val* object = yyjson_obj_get(root, "logo"); if (!object) { - return NULL; + return nullptr; } if (yyjson_is_null(object)) { options->type = FF_LOGO_TYPE_NONE; @@ -227,12 +227,12 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo options->paddingBottom = 0; options->paddingRight = 0; options->paddingLeft = 0; - return NULL; + return nullptr; } if (yyjson_is_str(object)) { ffStrbufSetJsonVal(&options->source, object); - return NULL; + return nullptr; } if (!yyjson_is_obj(object)) { @@ -281,7 +281,7 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo yyjson_val *keyc, *valc; size_t idxc, maxc; yyjson_obj_foreach (val, idxc, maxc, keyc, valc) { - uint32_t index = (uint32_t) strtoul(unsafe_yyjson_get_str(keyc), NULL, 10); + uint32_t index = (uint32_t) strtoul(unsafe_yyjson_get_str(keyc), nullptr, 10); if (index < 1 || index > FASTFETCH_LOGO_MAX_COLORS) { return "Keys of property 'color' must be a number between 1 to 9"; } @@ -428,7 +428,7 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo } } - return NULL; + return nullptr; } void ffOptionsGenerateLogoJsonConfig(FFdata* data, FFOptionsLogo* options) {