Skip to content

Commit 7c54dcb

Browse files
committed
CPU (Linux): fix detection when .../base_frequency doesn't exist
1 parent a107395 commit 7c54dcb

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/detection/cpu/cpu_linux.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static double getFrequency(FFstrbuf* basePath, const char* cpuinfoFileName, cons
102102
if (ok)
103103
return ffStrbufToDouble(buffer) / 1e6;
104104
}
105-
105+
106106
return 0.0/0.0;
107107
}
108108

@@ -114,7 +114,6 @@ static bool detectFrequency(FFCPUResult* cpu)
114114

115115
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
116116
uint32_t baseLen = path.length;
117-
bool flag = false;
118117

119118
struct dirent* entry;
120119
while((entry = readdir(dir)) != NULL)
@@ -123,25 +122,15 @@ static bool detectFrequency(FFCPUResult* cpu)
123122
{
124123
ffStrbufAppendS(&path, entry->d_name);
125124
double fbase = getFrequency(&path, "/base_frequency", NULL, &buffer);
126-
if (fbase != fbase) continue;
127-
double fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
128-
if (fmax != fmax) continue;
129-
130-
if (flag)
131-
{
125+
if (fbase == fbase)
132126
cpu->frequencyBase = cpu->frequencyBase > fbase ? cpu->frequencyBase : fbase;
127+
double fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
128+
if (fmax == fmax)
133129
cpu->frequencyMax = cpu->frequencyMax > fmax ? cpu->frequencyMax : fmax;
134-
}
135-
else
136-
{
137-
cpu->frequencyBase = fbase;
138-
cpu->frequencyMax = fmax;
139-
flag = true;
140-
}
141130
ffStrbufSubstrBefore(&path, baseLen);
142131
}
143132
}
144-
return flag;
133+
return true;
145134
}
146135

147136
static double detectCPUTemp(void)

0 commit comments

Comments
 (0)