Skip to content

Commit 783a833

Browse files
harshimogalapallihtejun
authored andcommitted
cgroup/cpuset: Cleanup signedness issue in cpu_exclusive_check()
Smatch complains about returning negative error codes from a type bool function. kernel/cgroup/cpuset.c:705 cpu_exclusive_check() warn: signedness bug returning '(-22)' The code works correctly, but it is confusing. The current behavior is that cpu_exclusive_check() returns true if it's *NOT* exclusive. Rename it to cpusets_are_exclusive() and reverse the returns so it returns true if it is exclusive and false if it's not. Update both callers as well. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <error27@gmail.com> Closes: https://lore.kernel.org/r/202309201706.2LhKdM6o-lkp@intel.com/ Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Acked-by: Waiman Long <longman@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 46c521b commit 783a833

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kernel/cgroup/cpuset.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -719,18 +719,18 @@ static inline struct cpumask *fetch_xcpus(struct cpuset *cs)
719719
}
720720

721721
/*
722-
* cpu_exclusive_check() - check if two cpusets are exclusive
722+
* cpusets_are_exclusive() - check if two cpusets are exclusive
723723
*
724-
* Return 0 if exclusive, -EINVAL if not
724+
* Return true if exclusive, false if not
725725
*/
726-
static inline bool cpu_exclusive_check(struct cpuset *cs1, struct cpuset *cs2)
726+
static inline bool cpusets_are_exclusive(struct cpuset *cs1, struct cpuset *cs2)
727727
{
728728
struct cpumask *xcpus1 = fetch_xcpus(cs1);
729729
struct cpumask *xcpus2 = fetch_xcpus(cs2);
730730

731731
if (cpumask_intersects(xcpus1, xcpus2))
732-
return -EINVAL;
733-
return 0;
732+
return false;
733+
return true;
734734
}
735735

736736
/*
@@ -833,7 +833,7 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
833833
cpuset_for_each_child(c, css, par) {
834834
if ((is_cpu_exclusive(trial) || is_cpu_exclusive(c)) &&
835835
c != cur) {
836-
if (cpu_exclusive_check(trial, c))
836+
if (!cpusets_are_exclusive(trial, c))
837837
goto out;
838838
}
839839
if ((is_mem_exclusive(trial) || is_mem_exclusive(c)) &&
@@ -1875,7 +1875,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
18751875
cpuset_for_each_child(child, css, parent) {
18761876
if (child == cs)
18771877
continue;
1878-
if (cpu_exclusive_check(cs, child)) {
1878+
if (!cpusets_are_exclusive(cs, child)) {
18791879
exclusive = false;
18801880
break;
18811881
}

0 commit comments

Comments
 (0)