The "array_index_mask_nospec" code has been updated to allow index
argument to have const-qualified type.
Now the stack variable "idx" is no longer required and can be removed.
We should directly pass the const variable "id" to array_index_mask_nospec

Signed-off-by: Aashish Lakhwara <[email protected]>
Signed-off-by: Himanshu Shukla <[email protected]>
---
 kernel/time/posix-timers.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index e08ce3f..face369 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -1357,8 +1357,6 @@ static int common_nsleep(const clockid_t which_clock, int 
flags,
 
 static const struct k_clock *clockid_to_kclock(const clockid_t id)
 {
-       clockid_t idx = id;
-
        if (id < 0) {
                return (id & CLOCKFD_MASK) == CLOCKFD ?
                        &clock_posix_dynamic : &clock_posix_cpu;
@@ -1367,5 +1365,5 @@ static const struct k_clock *clockid_to_kclock(const 
clockid_t id)
        if (id >= ARRAY_SIZE(posix_clocks))
                return NULL;
 
-       return posix_clocks[array_index_nospec(idx, ARRAY_SIZE(posix_clocks))];
+       return posix_clocks[array_index_nospec(id, ARRAY_SIZE(posix_clocks))];
 }
-- 
1.9.1

Reply via email to