From e08eec813cb0a5fa8ff3f2d5b57cc62ccc265b78 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Wed, 4 May 2022 16:53:23 +0200 Subject: [PATCH] Remove redundant sscanf calls (in (s)scanf a blank validates _zero_ or more whitespace) man sscanf(3): A sequence of white-space characters (space, tab, newline, etc.; see isspace(3)). This directive matches any amount of white space, including none, in the input. --- linux/LinuxProcessList.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 5e18f6d3..e23af209 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -2101,16 +2101,11 @@ static void scanCPUFrequencyFromCPUinfo(LinuxProcessList* this) { if (fgets(buffer, PROC_LINE_LENGTH, file) == NULL) break; - if ( - (sscanf(buffer, "processor : %d", &cpuid) == 1) || - (sscanf(buffer, "processor: %d", &cpuid) == 1) - ) { + if (sscanf(buffer, "processor : %d", &cpuid) == 1) { continue; } else if ( (sscanf(buffer, "cpu MHz : %lf", &frequency) == 1) || - (sscanf(buffer, "cpu MHz: %lf", &frequency) == 1) || - (sscanf(buffer, "clock : %lfMHz", &frequency) == 1) || - (sscanf(buffer, "clock: %lfMHz", &frequency) == 1) + (sscanf(buffer, "clock : %lfMHz", &frequency) == 1) ) { if (cpuid < 0 || (unsigned int)cpuid > (existingCPUs - 1)) { continue;