Skip to content

Commit 74b408f

Browse files
t-8chKAGA-KOKO
authored andcommitted
selftests: vDSO: vdso_test_abi: Use explicit indices for name array
The array relies on the numeric values of the clock IDs. When reading the code it is not obvious that the order is correct. Make the code easier to read by using explicit indices. While at it make the array static. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250812-vdso-tests-fixes-v2-5-90f499dd35f8@linutronix.de
1 parent d7516f2 commit 74b408f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tools/testing/selftests/vDSO/vdso_test_abi.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ typedef long (*vdso_clock_gettime_t)(clockid_t clk_id, struct timespec *ts);
3131
typedef long (*vdso_clock_getres_t)(clockid_t clk_id, struct timespec *ts);
3232
typedef time_t (*vdso_time_t)(time_t *t);
3333

34-
const char *vdso_clock_name[12] = {
35-
"CLOCK_REALTIME",
36-
"CLOCK_MONOTONIC",
37-
"CLOCK_PROCESS_CPUTIME_ID",
38-
"CLOCK_THREAD_CPUTIME_ID",
39-
"CLOCK_MONOTONIC_RAW",
40-
"CLOCK_REALTIME_COARSE",
41-
"CLOCK_MONOTONIC_COARSE",
42-
"CLOCK_BOOTTIME",
43-
"CLOCK_REALTIME_ALARM",
44-
"CLOCK_BOOTTIME_ALARM",
45-
"CLOCK_SGI_CYCLE",
46-
"CLOCK_TAI",
34+
static const char * const vdso_clock_name[] = {
35+
[CLOCK_REALTIME] = "CLOCK_REALTIME",
36+
[CLOCK_MONOTONIC] = "CLOCK_MONOTONIC",
37+
[CLOCK_PROCESS_CPUTIME_ID] = "CLOCK_PROCESS_CPUTIME_ID",
38+
[CLOCK_THREAD_CPUTIME_ID] = "CLOCK_THREAD_CPUTIME_ID",
39+
[CLOCK_MONOTONIC_RAW] = "CLOCK_MONOTONIC_RAW",
40+
[CLOCK_REALTIME_COARSE] = "CLOCK_REALTIME_COARSE",
41+
[CLOCK_MONOTONIC_COARSE] = "CLOCK_MONOTONIC_COARSE",
42+
[CLOCK_BOOTTIME] = "CLOCK_BOOTTIME",
43+
[CLOCK_REALTIME_ALARM] = "CLOCK_REALTIME_ALARM",
44+
[CLOCK_BOOTTIME_ALARM] = "CLOCK_BOOTTIME_ALARM",
45+
[10 /* CLOCK_SGI_CYCLE */] = "CLOCK_SGI_CYCLE",
46+
[CLOCK_TAI] = "CLOCK_TAI",
4747
};
4848

4949
static void vdso_test_gettimeofday(void)

0 commit comments

Comments
 (0)