From 767f99cffa97184e1db47916d3e9479b831a84a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 27 Sep 2023 15:11:05 +0800 Subject: [PATCH] CPU (Linux): only try `lscpu` on Linux Since `lscpu` is a program of `util-linux` --- src/detection/cpu/cpu_linux.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 1243fbf78..1241ef889 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -51,16 +51,6 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, ); } - if (cpu->name.length == 0) - { - FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); - if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL })) - { - ffParsePropLines(buffer.chars, "Model name:", &cpu->name); - if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name); - } - } - return NULL; } @@ -174,5 +164,17 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) detectAndroid(cpu); #endif + #ifdef __linux__ + if (cpu->name.length == 0) + { + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL })) + { + ffParsePropLines(buffer.chars, "Model name:", &cpu->name); + if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name); + } + } + #endif + return NULL; }