[LTP] [PATCH v2 2/2] ioprio: Use IOPRIO_PRIO_NUM to check prio range
Damien Le Moal
dlemoal@kernel.org
Thu Jun 8 02:53:15 CEST 2023
Use the macro IOPRIO_PRIO_NUM in prio_in_range() to check the upper
bound of the valid range for priority levels. Similarly, in the test
case ioprio_set03, use this macro to check for failures when the user
attempts using a priority level out of range.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
testcases/kernel/syscalls/ioprio/ioprio.h | 4 ++--
testcases/kernel/syscalls/ioprio/ioprio_set03.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/ioprio/ioprio.h b/testcases/kernel/syscalls/ioprio/ioprio.h
index 6ca134a54..c2115bf20 100644
--- a/testcases/kernel/syscalls/ioprio/ioprio.h
+++ b/testcases/kernel/syscalls/ioprio/ioprio.h
@@ -61,10 +61,10 @@ static inline int sys_ioprio_set(int which, int who, int ioprio)
return tst_syscall(__NR_ioprio_set, which, who, ioprio);
}
-/* Priority range from 0 (highest) to 7 (lowest) */
+/* Priority range from 0 (highest) to IOPRIO_PRIO_NUM (lowest) */
static inline int prio_in_range(int prio)
{
- if ((prio < 0) || (prio > 7))
+ if ((prio < 0) || (prio >= IOPRIO_PRIO_NUM))
return 0;
return 1;
}
diff --git a/testcases/kernel/syscalls/ioprio/ioprio_set03.c b/testcases/kernel/syscalls/ioprio/ioprio_set03.c
index b2c962a6f..d6b44df85 100644
--- a/testcases/kernel/syscalls/ioprio/ioprio_set03.c
+++ b/testcases/kernel/syscalls/ioprio/ioprio_set03.c
@@ -27,7 +27,7 @@ static void run(void)
sys_ioprio_set(IOPRIO_WHO_PROCESS, 0,
IOPRIO_PRIO_VALUE(class, 4));
TEST(sys_ioprio_set(IOPRIO_WHO_PROCESS, 0,
- IOPRIO_PRIO_VALUE(class, 8)));
+ IOPRIO_PRIO_VALUE(class, IOPRIO_PRIO_NUM)));
if (TST_RET == -1) {
ioprio_check_setting(class, 4, 1);
if (errno == EINVAL)
--
2.40.1
More information about the ltp
mailing list