mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ const char* ffDetectBios(FFBiosResult* bios) {
|
||||
|
||||
ffStrbufSetStatic(&bios->type, "Bootloader");
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -27,5 +27,5 @@ const char* ffDetectBios(FFBiosResult* result) {
|
||||
: "BIOS");
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ const char* ffDetectBios(FFBiosResult* bios) {
|
||||
} else {
|
||||
ffStrbufSetStatic(&bios->type, "BIOS");
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -108,5 +108,5 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -28,5 +28,5 @@ const char* ffDetectBoard(FFBoardResult* result) {
|
||||
ffCfStrGetString(manufacturer, &result->vendor);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -22,5 +22,5 @@ const char* ffDetectBoard(FFBoardResult* board) {
|
||||
ffStrbufSubstrBefore(&board->vendor, comma);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -42,5 +42,5 @@ const char* ffDetectBoard(FFBoardResult* board) {
|
||||
ffStrbufSetStatic(&board->version, ffSmbiosLocateString(strings, data->Version));
|
||||
ffCleanUpSmbiosValue(&board->version);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -58,5 +58,5 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
result->secureBoot = !!buffer[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -13,5 +13,5 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
|
||||
// TODO: detectSecureBoot(&result->secureBoot);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -28,5 +28,5 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
result->secureBoot = buffer[4] == 1;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -42,5 +42,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist*
|
||||
|
||||
} while (screen.SetToNext() == B_OK);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -22,5 +22,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist*
|
||||
brightness->current = value;
|
||||
brightness->builtin = true;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -40,5 +40,5 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist*
|
||||
brightness->builtin = true;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <linux/videodev2.h>";
|
||||
|
||||
@@ -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(); });
|
||||
|
||||
|
||||
@@ -76,6 +76,6 @@ const char* ffChassisTypeToString(uint32_t type) {
|
||||
case 0x24:
|
||||
return "Stick PC";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -35,5 +35,5 @@ const char* ffDetectChassis(FFChassisResult* result) {
|
||||
result->type.chars[0] = (char) toupper(result->type.chars[0]);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -50,5 +50,5 @@ const char* ffDetectChassis(FFChassisResult* result) {
|
||||
ffCleanUpSmbiosValue(&result->version);
|
||||
ffStrbufSetStatic(&result->type, ffChassisTypeToString(data->Type));
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+17
-17
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
// <groups>
|
||||
// <group level="1" cache-level="3">
|
||||
// <cpu count="4" mask="f,0,0,0">0, 1, 2, 3</cpu>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -4,28 +4,28 @@
|
||||
#include <kstat.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include <wchar.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -59,5 +59,5 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -78,5 +78,5 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) {
|
||||
ffCPUCacheAddItem(result, level, size, 0, type);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ void ffPrepareCPUUsage(void) {
|
||||
}
|
||||
|
||||
const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result) {
|
||||
const char* error = NULL;
|
||||
const char* error = nullptr;
|
||||
if (startTime == 0) {
|
||||
ffListInit(&cpuTimes1);
|
||||
error = ffGetCpuUsageInfo(&cpuTimes1);
|
||||
@@ -70,5 +70,5 @@ retry:
|
||||
cpuTime1->totalAll = cpuTime2->totalAll;
|
||||
}
|
||||
startTime = ffTimeGetNow();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -29,5 +29,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
}
|
||||
|
||||
vm_deallocate(mach_task_self(), (vm_address_t) cpuInfo, numCpuInfo * sizeof(integer_t));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
#else
|
||||
int ctls[] = { CTL_KERN, KERN_CP_TIME };
|
||||
#endif
|
||||
if (sysctl(ctls, 2, NULL, &neededLength, NULL, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
|
||||
if (sysctl(ctls, 2, nullptr, &neededLength, nullptr, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, nullptr) failed";
|
||||
}
|
||||
#else
|
||||
if (sysctlbyname("kern.cp_times", NULL, &neededLength, NULL, 0) != 0) {
|
||||
return "sysctlbyname(kern.cp_times, NULL) failed";
|
||||
if (sysctlbyname("kern.cp_times", nullptr, &neededLength, nullptr, 0) != 0) {
|
||||
return "sysctlbyname(kern.cp_times, nullptr) failed";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,11 +33,11 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
FF_AUTO_FREE uint64_t (*cpTimes)[CPUSTATES] = malloc(neededLength);
|
||||
|
||||
#if __OpenBSD__ || __NetBSD__
|
||||
if (sysctl(ctls, 2, cpTimes, &neededLength, NULL, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
|
||||
if (sysctl(ctls, 2, cpTimes, &neededLength, nullptr, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, nullptr) failed";
|
||||
}
|
||||
#else
|
||||
if (sysctlbyname("kern.cp_times", cpTimes, &neededLength, NULL, 0) != 0) {
|
||||
if (sysctlbyname("kern.cp_times", cpTimes, &neededLength, nullptr, 0) != 0) {
|
||||
return "sysctlbyname(kern.cp_times, cpTime) failed";
|
||||
}
|
||||
#endif
|
||||
@@ -54,5 +54,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
};
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
info->totalAll = uptime;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
buf[nRead] = '\0';
|
||||
|
||||
// Skip first line
|
||||
char* start = NULL;
|
||||
if ((start = strchr(buf, '\n')) == NULL) {
|
||||
char* start = nullptr;
|
||||
if ((start = strchr(buf, '\n')) == nullptr) {
|
||||
return "skip first line failed";
|
||||
}
|
||||
++start;
|
||||
|
||||
uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0;
|
||||
char* token = NULL;
|
||||
char* token = nullptr;
|
||||
while ((token = strchr(start, '\n'))) {
|
||||
if (sscanf(start, "cpu%*d%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%*[^\n]\n", &user, &nice, &system, &idle, &iowait, &irq, &softirq) == 7) {
|
||||
uint64_t inUse = user + nice + system + irq + softirq;
|
||||
@@ -42,5 +42,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
start = token + 1;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
}
|
||||
|
||||
for (int i = 0;; ++i) {
|
||||
kstat_t* ks = kstat_lookup(kc, "cpu_stat", i, NULL);
|
||||
kstat_t* ks = kstat_lookup(kc, "cpu_stat", i, nullptr);
|
||||
|
||||
cpu_stat_t cs;
|
||||
if (!ks || kstat_read(kc, ks, &cs) < 0) {
|
||||
@@ -34,5 +34,5 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
.totalAll = total,
|
||||
};
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
static const char* getInfoByNqsi(FFlist* cpuTimes) {
|
||||
ULONG size = 0;
|
||||
if (NtQuerySystemInformation(SystemProcessorPerformanceInformation, NULL, 0, &size) != STATUS_INFO_LENGTH_MISMATCH) {
|
||||
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, NULL) failed";
|
||||
if (NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr, 0, &size) != STATUS_INFO_LENGTH_MISMATCH) {
|
||||
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr) failed";
|
||||
}
|
||||
|
||||
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* FF_AUTO_FREE pinfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*) malloc(size);
|
||||
@@ -35,13 +35,13 @@ static const char* getInfoByNqsi(FFlist* cpuTimes) {
|
||||
};
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
static HANDLE hQuery = NULL;
|
||||
static HANDLE hQuery = nullptr;
|
||||
|
||||
if (hQuery == NULL) {
|
||||
if (hQuery == nullptr) {
|
||||
struct FFPerfQuerySpec {
|
||||
PERF_COUNTER_IDENTIFIER Identifier;
|
||||
WCHAR Name[16];
|
||||
@@ -57,7 +57,7 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
.Name = PERF_WILDCARD_INSTANCE,
|
||||
};
|
||||
|
||||
if (PerfOpenQueryHandle(NULL, &hQuery) != ERROR_SUCCESS) {
|
||||
if (PerfOpenQueryHandle(nullptr, &hQuery) != ERROR_SUCCESS) {
|
||||
PerfCloseQueryHandle(hQuery);
|
||||
hQuery = INVALID_HANDLE_VALUE;
|
||||
return "PerfOpenQueryHandle() failed";
|
||||
@@ -81,8 +81,8 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
}
|
||||
|
||||
DWORD dataSize = 0;
|
||||
if (PerfQueryCounterData(hQuery, NULL, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
|
||||
return "PerfQueryCounterData(NULL) failed";
|
||||
if (PerfQueryCounterData(hQuery, nullptr, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
|
||||
return "PerfQueryCounterData(nullptr) failed";
|
||||
}
|
||||
|
||||
if (dataSize <= sizeof(PERF_DATA_HEADER) + sizeof(PERF_COUNTER_HEADER)) {
|
||||
@@ -133,7 +133,7 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
pCounterData = (PERF_COUNTER_DATA*) ((BYTE*) pCounterData + pCounterData->dwSize);
|
||||
}
|
||||
|
||||
if (wcschr(instanceName, L'_') == NULL /* ignore `_Total` */) {
|
||||
if (wcschr(instanceName, L'_') == nullptr /* ignore `_Total` */) {
|
||||
if (processorUtility == UINT64_MAX) {
|
||||
return "Counter \"% Processor Utility\" are not supported";
|
||||
}
|
||||
@@ -148,17 +148,17 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
pInstanceHeader = (PERF_INSTANCE_HEADER*) pCounterData;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
const char* error = NULL;
|
||||
const char* error = nullptr;
|
||||
|
||||
if (ffIsWindows10OrGreater()) {
|
||||
error = getInfoByPerflib(cpuTimes);
|
||||
FF_DEBUG("Get CPU usage info by Perflib: %s", error ?: "success");
|
||||
if (!error) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
ffListClear(cpuTimes);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
+20
-20
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -70,5 +70,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
disk->createTime = (uint64_t) crTime * 1000;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -53,5 +53,5 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -38,5 +38,5 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
device->writeCount = kio.writes;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <winioctl.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 ||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user