From 58f7d6fed4f023fae0ca999e36aa7076499347c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 7 Jun 2024 20:37:44 +0800 Subject: [PATCH] CPUCache (Linux): report error if cache size is unavailable (Android) --- src/detection/cpucache/cpucache_linux.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/detection/cpucache/cpucache_linux.c b/src/detection/cpucache/cpucache_linux.c index 30737fc69..11ec5cbd1 100644 --- a/src/detection/cpucache/cpucache_linux.c +++ b/src/detection/cpucache/cpucache_linux.c @@ -50,7 +50,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result, // deduplicate shared caches ffStrbufAppendF(buffer, "_%u_%u_%u_%u\n", level, sizeKb, lineSize, cacheType); - if (ffStrbufContain(added, buffer)) return "cache already added"; + if (ffStrbufContain(added, buffer)) return NULL; ffStrbufAppend(added, buffer); ffCPUCacheAddItem(result, level, sizeKb * 1024, lineSize, cacheType); return NULL; @@ -71,7 +71,8 @@ static const char* parseCpuCache(FFstrbuf* path, FFCPUCacheResult* result, FFstr || !ffCharIsDigit(pathCacheEntry->d_name[strlen("index")])) continue; ffStrbufAppendS(path, pathCacheEntry->d_name); - parseCpuCacheIndex(path, result, buffer, added); + const char* error = parseCpuCacheIndex(path, result, buffer, added); + if (error) return error; ffStrbufSubstrBefore(path, baseLen); } @@ -97,7 +98,8 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) !ffCharIsDigit(pathCpuEntry->d_name[strlen("cpu")])) continue; ffStrbufAppendS(&path, pathCpuEntry->d_name); - parseCpuCache(&path, result, &buffer, &added); + const char* error = parseCpuCache(&path, result, &buffer, &added); + if (error) return error; ffStrbufSubstrBefore(&path, baseLen); } return NULL;