From ecee5694fb02782bd9d4b8827602aa57e6374614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 4 Sep 2026 19:35:17 +0800 Subject: [PATCH] Global: uses `strtoull` for uint64_t Fixes #2563 #2564 --- src/detection/cpu/cpu_linux.c | 2 +- src/detection/gpu/gpu_linux.c | 2 +- src/detection/gpu/gpu_sunos.c | 2 +- src/detection/physicaldisk/physicaldisk_linux.c | 2 +- src/detection/physicalmemory/physicalmemory_apple.m | 2 +- src/detection/swap/swap_linux.c | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 589d0ac01..4a338ea4e 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -712,7 +712,7 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options) { while ((p = memmem(p, cpuinfo->length - (uint32_t) (p - cpuinfo->chars), "\nphysical id\t:", strlen("\nphysical id\t:")))) { p += strlen("\nphysical id\t:"); char* pend; - unsigned long long id = strtoul(p, &pend, 10); + unsigned long id = strtoul(p, &pend, 10); if (__builtin_expect(id > 64, false)) { // Do 129-socket boards exist? high |= 1ULL << (id - 64); } else { diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 9575d9ff4..d812e08b7 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -426,7 +426,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf ffStrbufAppendS(deviceDir, "/revision"); if (ffReadFileBuffer(deviceDir->chars, buffer)) { char* pend; - uint64_t revision = strtoul(buffer->chars, &pend, 16); + uint32_t revision = (uint32_t) strtoul(buffer->chars, &pend, 16); if (pend != buffer->chars) { ffGPUQueryAmdGpuName((uint16_t) deviceId, (uint8_t) revision, gpu); } diff --git a/src/detection/gpu/gpu_sunos.c b/src/detection/gpu/gpu_sunos.c index 8e896625f..fb9db7a29 100644 --- a/src/detection/gpu/gpu_sunos.c +++ b/src/detection/gpu/gpu_sunos.c @@ -19,7 +19,7 @@ static int walkDevTree(di_node_t node, [[maybe_unused]] di_minor_t minor, FFlist gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; gpu->type = FF_GPU_TYPE_UNKNOWN; gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; - gpu->deviceId = strtoul(di_bus_addr(node), nullptr, 16); + gpu->deviceId = (uint64_t) strtoull(di_bus_addr(node), nullptr, 16); gpu->frequency = FF_GPU_FREQUENCY_UNSET; gpu->pcieSpeed = FF_GPU_PCIE_SPEED_UNSET; diff --git a/src/detection/physicaldisk/physicaldisk_linux.c b/src/detection/physicaldisk/physicaldisk_linux.c index b6d4c755f..525e391bf 100644 --- a/src/detection/physicaldisk/physicaldisk_linux.c +++ b/src/detection/physicaldisk/physicaldisk_linux.c @@ -34,7 +34,7 @@ static void parsePhysicalDisk(int dfd, const char* devName, FFPhysicalDiskOption ssize_t fileSize = ffReadFileDataRelative(dfd, "size", ARRAY_SIZE(blkSize) - 1, blkSize); if (fileSize > 0) { blkSize[fileSize] = 0; - size = (uint64_t) strtoul(blkSize, nullptr, 10) * 512; + size = (uint64_t) strtoull(blkSize, nullptr, 10) * 512; } } diff --git a/src/detection/physicalmemory/physicalmemory_apple.m b/src/detection/physicalmemory/physicalmemory_apple.m index c58c2f14b..4ce579702 100644 --- a/src/detection/physicalmemory/physicalmemory_apple.m +++ b/src/detection/physicalmemory/physicalmemory_apple.m @@ -38,7 +38,7 @@ static void appendDevice( if (size) { char* unit = nullptr; - device->size = strtoul(size.UTF8String, &unit, 10); + device->size = (uint64_t) strtoull(size.UTF8String, &unit, 10); if (*unit == ' ') ++unit; switch (*unit) diff --git a/src/detection/swap/swap_linux.c b/src/detection/swap/swap_linux.c index d72125d78..5d456626c 100644 --- a/src/detection/swap/swap_linux.c +++ b/src/detection/swap/swap_linux.c @@ -19,11 +19,11 @@ static const char* detectByProcMeminfo(FFlist* result) { char* token = nullptr; if ((token = strstr(buf, "SwapTotal:")) != nullptr) { - swapTotal = strtoul(token + strlen("SwapTotal:"), nullptr, 10); + swapTotal = (uint64_t) strtoull(token + strlen("SwapTotal:"), nullptr, 10); } if ((token = strstr(buf, "SwapFree:")) != nullptr) { - swapFree = strtoul(token + strlen("SwapFree:"), nullptr, 10); + swapFree = (uint64_t) strtoull(token + strlen("SwapFree:"), nullptr, 10); } FFSwapResult* swap = FF_LIST_ADD(FFSwapResult, *result);