Fix the following Coverity complaint:
1. negative_return: Calling sysconf, which might return a negative value.
2. return_negative_fn: Returning the return value of sysconf, which might be negative.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
#ifndef FIO_HAVE_CPU_CONF_SYSCONF
static inline unsigned int cpus_configured(void)
{
- return sysconf(_SC_NPROCESSORS_CONF);
+ int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
+
+ return nr_cpus >= 1 ? nr_cpus : 1;
}
#endif