mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -61,11 +61,11 @@ FF_A_UNUSED static const char* drmFindRenderFromCard(const char* drmCardKey, FFs
|
||||
}
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (ffStrStartsWith(entry->d_name, "render")) {
|
||||
ffStrbufSetS(result, "/dev/dri/");
|
||||
ffStrbufAppendS(result, entry->d_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return "Failed to find render device";
|
||||
@@ -95,7 +95,7 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu,
|
||||
}
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ static void pciDetectIntelSpecific(const FFGPUOptions* options, FFGPUResult* gpu
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDir->chars);
|
||||
if (dirp) {
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ static const char* pciDetectTempGeneral(const FFGPUOptions* options, FFGPUResult
|
||||
}
|
||||
ffStrbufSubstrBefore(pciDir, pciDirLen);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* drmDetectNouveauSpecific(FFGPUResult* gpu, const char* drmKey, FFstrbuf* buffer) {
|
||||
@@ -302,7 +302,7 @@ static const char* pciDetectZxSpecific(const FFGPUOptions* options, FFGPUResult*
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline uint16_t pcieLinkSpeedToGen(const FFstrbuf* buffer) {
|
||||
@@ -344,7 +344,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
}
|
||||
|
||||
char pciPath[PATH_MAX];
|
||||
const char* pPciPath = NULL;
|
||||
const char* pPciPath = nullptr;
|
||||
if (drmKey) {
|
||||
ssize_t pathLength = readlink(deviceDir->chars, pciPath, ARRAY_SIZE(pciPath) - 1);
|
||||
if (pathLength <= 0) {
|
||||
@@ -352,7 +352,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
}
|
||||
pciPath[pathLength] = '\0';
|
||||
pPciPath = strrchr(pciPath, '/');
|
||||
if (__builtin_expect(pPciPath != NULL, true)) {
|
||||
if (__builtin_expect(pPciPath != nullptr, true)) {
|
||||
pPciPath++;
|
||||
} else {
|
||||
pPciPath = pciPath;
|
||||
@@ -394,7 +394,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(deviceDir->chars);
|
||||
if (dirp) {
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (ffStrStartsWith(entry->d_name, "card")) {
|
||||
ffStrCopy(drmKeyBuffer, entry->d_name, ARRAY_SIZE(drmKeyBuffer));
|
||||
drmKey = drmKeyBuffer;
|
||||
@@ -415,7 +415,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) {
|
||||
bool ok = false;
|
||||
if (drmKey && options->driverSpecific) {
|
||||
ok = drmDetectAmdSpecific(options, gpu, drmKey, buffer) == NULL;
|
||||
ok = drmDetectAmdSpecific(options, gpu, drmKey, buffer) == nullptr;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
@@ -491,7 +491,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if __aarch64__
|
||||
@@ -510,7 +510,7 @@ FF_A_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const ch
|
||||
return ffDrmDetectAsahi(gpu, fd);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -563,7 +563,7 @@ static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, co
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
@@ -572,16 +572,16 @@ static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
const uint32_t drmDirLength = drmDir.length;
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir(drmDir.chars);
|
||||
if (dir == NULL) {
|
||||
if (dir == nullptr) {
|
||||
return "Failed to open `/sys/class/drm/`";
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (!ffStrStartsWith(entry->d_name, "card") ||
|
||||
strchr(entry->d_name + 4, '-') != NULL) {
|
||||
strchr(entry->d_name + 4, '-') != nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
@@ -611,7 +611,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
const char* pciDirPath = "/sys/bus/pci/devices/";
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDirPath);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return "Failed to open `/sys/bus/pci/devices/`";
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -639,24 +639,24 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
ffStrbufSubstrBefore(&pciDir, pciDevDirLength);
|
||||
assert(ffStrbufStartsWithS(&buffer, "pci:"));
|
||||
|
||||
detectPci(options, gpus, &buffer, &pciDir, NULL);
|
||||
detectPci(options, gpus, &buffer, &pciDir, nullptr);
|
||||
ffStrbufSubstrBefore(&pciDir, pciBaseDirLength);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
#if __x86_64__ || __aarch64__
|
||||
const char* ffGPUDetectWsl2(const FFGPUOptions* options, FFlist* gpus);
|
||||
if (ffGPUDetectWsl2(options, gpus) == NULL) {
|
||||
return NULL;
|
||||
if (ffGPUDetectWsl2(options, gpus) == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO) {
|
||||
if (drmDetectGPUs(options, gpus) == NULL && gpus->length > 0) {
|
||||
return NULL;
|
||||
if (drmDetectGPUs(options, gpus) == nullptr && gpus->length > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return pciDetectGPUs(options, gpus);
|
||||
|
||||
Reference in New Issue
Block a user