git: c1dd895406a8 - stable/14 - sched tests: Avoid underflow when maxcpuid == 0
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 22 Jul 2024 00:55:39 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c1dd895406a849bebeceaac6e6f48c4983c37268 commit c1dd895406a849bebeceaac6e6f48c4983c37268 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-07-14 16:12:32 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-07-22 00:55:27 +0000 sched tests: Avoid underflow when maxcpuid == 0 MFC after: 1 week (cherry picked from commit 5b98bd30686a358b2a20728a4a6b5cecb7e28dc9) --- tests/sys/kern/sched_affinity.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/sys/kern/sched_affinity.c b/tests/sys/kern/sched_affinity.c index dce8678bcf6e..44802c5ac8e1 100644 --- a/tests/sys/kern/sched_affinity.c +++ b/tests/sys/kern/sched_affinity.c @@ -67,13 +67,16 @@ ATF_TC_BODY(test_setinvalidcpu, tc) { size_t cpusetsize; cpuset_t *set; + int cpu; + + cpu = maxcpuid > 1 ? maxcpuid - 1 : 0; cpusetsize = CPU_ALLOC_SIZE(maxcpuid + 1); set = CPU_ALLOC(maxcpuid + 1); ATF_REQUIRE(set != NULL); CPU_ZERO_S(cpusetsize, set); CPU_SET_S(maxcpuid + 1, cpusetsize, set); - CPU_SET_S(maxcpuid - 1, cpusetsize, set); + CPU_SET_S(cpu, cpusetsize, set); ATF_REQUIRE(sched_setaffinity(0, cpusetsize, set) == 0); CPU_FREE(set); @@ -82,7 +85,7 @@ ATF_TC_BODY(test_setinvalidcpu, tc) ATF_REQUIRE(set != NULL); CPU_ZERO_S(cpusetsize, set); CPU_SET_S(maxcpuid + 1, cpusetsize, set); - CPU_SET_S(maxcpuid - 1, cpusetsize, set); + CPU_SET_S(cpu, cpusetsize, set); ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, cpusetsize, set) == -1); ATF_REQUIRE_EQ(errno, EINVAL);