mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-08 10:26:14 -04:00
MINOR: cpuset: make the API support negative CPU IDs
Negative IDs are very convenient to mean "not set", so let's just make the cpuset API robust against this, especially with ha_cpuset_isset() so that we don't have to manually add this check everywhere when a value is not known.
This commit is contained in:
parent
f156baf8ce
commit
32bb68e736
1 changed files with 3 additions and 3 deletions
|
|
@ -21,7 +21,7 @@ void ha_cpuset_zero(struct hap_cpuset *set)
|
|||
|
||||
int ha_cpuset_set(struct hap_cpuset *set, int cpu)
|
||||
{
|
||||
if (cpu >= ha_cpuset_size())
|
||||
if (cpu < 0 || cpu >= ha_cpuset_size())
|
||||
return 1;
|
||||
|
||||
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)
|
||||
|
|
@ -36,7 +36,7 @@ int ha_cpuset_set(struct hap_cpuset *set, int cpu)
|
|||
|
||||
int ha_cpuset_clr(struct hap_cpuset *set, int cpu)
|
||||
{
|
||||
if (cpu >= ha_cpuset_size())
|
||||
if (cpu < 0 || cpu >= ha_cpuset_size())
|
||||
return 1;
|
||||
|
||||
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)
|
||||
|
|
@ -77,7 +77,7 @@ void ha_cpuset_or(struct hap_cpuset *dst, struct hap_cpuset *src)
|
|||
|
||||
int ha_cpuset_isset(const struct hap_cpuset *set, int cpu)
|
||||
{
|
||||
if (cpu >= ha_cpuset_size())
|
||||
if (cpu < 0 || cpu >= ha_cpuset_size())
|
||||
return 0;
|
||||
|
||||
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)
|
||||
|
|
|
|||
Loading…
Reference in a new issue