@@ -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;
}
@@ -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)
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> --- testcases/kernel/syscalls/ioprio/ioprio.h | 4 ++-- testcases/kernel/syscalls/ioprio/ioprio_set03.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)