mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-08 14:10:11 +01:00
Global: fixes bugs found by CI
The code quality is to be improved...
This commit is contained in:
@@ -116,7 +116,7 @@ bool ffEdidGetSerial(const uint8_t edid[128], FFstrbuf* result) {
|
||||
|
||||
if (int_serial != 0 && int_serial != 0xFFFFFFFF) {
|
||||
ffStrbufSetF(result, "0x%08X", int_serial);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ static const struct FFCodecVdpauCodec {
|
||||
};
|
||||
|
||||
static const char* ffDetectCodecByVdpau(FFCodecOptions* options, FFlist* result) {
|
||||
if (options->showType != FF_CODEC_SHOW_TYPE_DECODER) {
|
||||
if (!(options->showType & FF_CODEC_SHOW_TYPE_DECODER)) {
|
||||
return "VDPAU only supports decoding";
|
||||
}
|
||||
|
||||
|
||||
@@ -778,11 +778,14 @@ 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 = strtoul(buf, NULL, 10);
|
||||
if (__builtin_expect(id > 64, false)) { // Do 129-socket boards exist?
|
||||
pkgHigh |= 1ULL << (id - 64);
|
||||
} else if (__builtin_expect(id <= 64, true)) {
|
||||
pkgLow |= 1ULL << id;
|
||||
unsigned long long id = strtoull(buf, NULL, 10);
|
||||
if (__builtin_expect(id < 128, true)) {
|
||||
// Do 129-socket boards exist?
|
||||
if (__builtin_expect(id >= 64, false)) {
|
||||
pkgHigh |= 1ULL << (id - 64);
|
||||
} else {
|
||||
pkgLow |= 1ULL << id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,19 +188,19 @@ const char* detectByEglext(FFlist* result) {
|
||||
if (ffeglQueryDevicesEXT(ARRAY_SIZE(devices), devices, &numDevices) == EGL_TRUE) {
|
||||
FF_DEBUG("eglQueryDevicesEXT() returned %d device(s)", numDevices);
|
||||
for (EGLint i = 0; i < numDevices; i++) {
|
||||
const EGLDeviceEXT device = &devices[i];
|
||||
const EGLDeviceEXT device = devices[i];
|
||||
if (device == (EGLDeviceEXT) EGL_NO_DEVICE_EXT || device == (EGLDeviceEXT) EGL_BAD_DEVICE_EXT) {
|
||||
FF_DEBUG("eglQueryDevicesEXT() returned invalid device at index %d", i);
|
||||
continue;
|
||||
}
|
||||
const char* exts = (const char*) ffeglQueryDeviceStringEXT(devices[i], EGL_EXTENSIONS);
|
||||
const char* exts = (const char*) ffeglQueryDeviceStringEXT(device, EGL_EXTENSIONS);
|
||||
FF_DEBUG("eglQueryDeviceStringEXT() returned extensions for device %d: %s", i, exts);
|
||||
if (exts && ffStrContains(exts, "EGL_MESA_device_software")) {
|
||||
FF_DEBUG("eglQueryDeviceStringEXT() returned software device at index %d, skipping", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
const char* name = ffeglQueryDeviceStringEXT(devices[i], EGL_RENDERER_EXT);
|
||||
const char* name = ffeglQueryDeviceStringEXT(device, EGL_RENDERER_EXT);
|
||||
if (!name) {
|
||||
FF_DEBUG("eglQueryDeviceStringEXT() returned NULL name for device %d, skipping", i);
|
||||
continue;
|
||||
@@ -209,7 +209,7 @@ const char* detectByEglext(FFlist* result) {
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *result);
|
||||
ffStrbufInitS(&gpu->name, name);
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
ffStrbufInitS(&gpu->driver, ffeglQueryDeviceStringEXT(devices[i], EGL_DRIVER_NAME_EXT));
|
||||
ffStrbufInitS(&gpu->driver, ffeglQueryDeviceStringEXT(device, EGL_DRIVER_NAME_EXT));
|
||||
ffStrbufInitF(&gpu->platformApi, "egl-ext");
|
||||
ffStrbufInit(&gpu->memoryType);
|
||||
gpu->index = FF_GPU_INDEX_UNSET;
|
||||
@@ -222,10 +222,10 @@ const char* detectByEglext(FFlist* result) {
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
gpu->pcieSpeed = FF_GPU_PCIE_SPEED_UNSET;
|
||||
|
||||
ffeglQueryDeviceBinaryEXT(devices[i], EGL_DEVICE_UUID_EXT, sizeof(gpu->deviceId), &gpu->deviceId, NULL);
|
||||
ffeglQueryDeviceBinaryEXT(device, EGL_DEVICE_UUID_EXT, sizeof(gpu->deviceId), &gpu->deviceId, NULL);
|
||||
|
||||
if (!normalizeVendorName(gpu)) {
|
||||
ffStrbufSetS(&gpu->vendor, ffeglQueryDeviceStringEXT(devices[i], EGL_VENDOR));
|
||||
ffStrbufSetS(&gpu->vendor, ffeglQueryDeviceStringEXT(device, EGL_VENDOR));
|
||||
}
|
||||
|
||||
FF_DEBUG("Detected GPU %d: vendor='%s', name='%s', driver='%s', id='%16" PRIX64 "'", i, gpu->vendor.chars, gpu->name.chars, gpu->driver.chars, gpu->deviceId);
|
||||
@@ -325,7 +325,7 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) {
|
||||
}
|
||||
|
||||
bool ffGPUFillVendorByDeviceName(FFGPUResult* gpu) {
|
||||
if (gpu->type == FF_GPU_TYPE_UNKNOWN) {
|
||||
if (gpu->type != FF_GPU_TYPE_UNKNOWN) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ const char* ffGPUDetectByDrmBSD(const FFGPUOptions* options, FFlist* gpus) {
|
||||
driverName[0] = '\0';
|
||||
struct drm_version ver = {
|
||||
.name = driverName,
|
||||
.name_len = ARRAY_SIZE(driverName),
|
||||
.name_len = ARRAY_SIZE(driverName) - 1,
|
||||
};
|
||||
if (ioctl(fd, DRM_IOCTL_VERSION, &ver) == 0) {
|
||||
driverName[ver.name_len] = '\0';
|
||||
|
||||
@@ -246,10 +246,10 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
|
||||
ctl_pci_state_t pciState = { .Size = sizeof(pciState), .Version = 0 };
|
||||
if (igclData.ffctlPciGetState(device, &pciState) == CTL_RESULT_SUCCESS) {
|
||||
if (pciState.speed.gen > 0) {
|
||||
result.psMax->gen = (uint16_t) pciState.speed.gen;
|
||||
result.psCurr->gen = (uint16_t) pciState.speed.gen;
|
||||
}
|
||||
if (pciState.speed.width > 0) {
|
||||
result.psMax->lanes = (uint16_t) pciState.speed.width;
|
||||
result.psCurr->lanes = (uint16_t) pciState.speed.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +146,10 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
case 3: ffStrbufSetStatic(&item->conn.security, "WPA1+2"); break;
|
||||
default: ffStrbufSetStatic(&item->conn.security, "WPA"); break;
|
||||
}
|
||||
} else {
|
||||
ffStrbufSetStatic(&item->conn.security, "WPA");
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
ffStrbufSetF(&item->conn.security, "Unknown (%d)", ireq.i_val);
|
||||
|
||||
@@ -67,7 +67,7 @@ bool ffPrintMonitor(FFMonitorOptions* options) {
|
||||
}));
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&display->name);
|
||||
// result is a singleton, so we don't destroy the members
|
||||
++index;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user