mirror of https://git.ffmpeg.org/ffmpeg.git
cpu: Restructure code to avoid pointless ret variable indirection
libavutil/cpu.c:133:9: warning: unused variable ‘ret’ [-Wunused-variable]
This commit is contained in:
parent
46ce9ded96
commit
f0ce1d9909
|
@ -130,27 +130,23 @@ int av_parse_cpu_flags(const char *s)
|
|||
|
||||
int av_cpu_count(void)
|
||||
{
|
||||
int ret, nb_cpus = 1;
|
||||
int nb_cpus = 1;
|
||||
#if HAVE_SCHED_GETAFFINITY && defined(CPU_COUNT)
|
||||
cpu_set_t cpuset;
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
|
||||
ret = sched_getaffinity(0, sizeof(cpuset), &cpuset);
|
||||
if (!ret) {
|
||||
if (!sched_getaffinity(0, sizeof(cpuset), &cpuset))
|
||||
nb_cpus = CPU_COUNT(&cpuset);
|
||||
}
|
||||
#elif HAVE_GETPROCESSAFFINITYMASK
|
||||
DWORD_PTR proc_aff, sys_aff;
|
||||
ret = GetProcessAffinityMask(GetCurrentProcess(), &proc_aff, &sys_aff);
|
||||
if (ret)
|
||||
if (GetProcessAffinityMask(GetCurrentProcess(), &proc_aff, &sys_aff))
|
||||
nb_cpus = av_popcount64(proc_aff);
|
||||
#elif HAVE_SYSCTL && defined(HW_NCPU)
|
||||
int mib[2] = { CTL_HW, HW_NCPU };
|
||||
size_t len = sizeof(nb_cpus);
|
||||
|
||||
ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0);
|
||||
if (ret == -1)
|
||||
if (sysctl(mib, 2, &nb_cpus, &len, NULL, 0) == -1)
|
||||
nb_cpus = 0;
|
||||
#elif HAVE_SYSCONF && defined(_SC_NPROC_ONLN)
|
||||
nb_cpus = sysconf(_SC_NPROC_ONLN);
|
||||
|
|
Loading…
Reference in New Issue