From: Colin Ian King Date: Mon, 17 Apr 2023 10:47:43 +0000 (+0100) Subject: kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined X-Git-Tag: v6.6.7~2579^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=375b9ff53cb6f9c042817b75f2be0a650626dc4f;p=platform%2Fkernel%2Flinux-starfive.git kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined In the unlikely case that CLOCK_REALTIME is not defined, variable ret is not initialized and further accumulation of return values to ret can leave ret in an undefined state. Fix this by initialized ret to zero and changing the assignment of ret to an accumulation for the CLOCK_REALTIME case. Fixes: 03f55c7952c9 ("kselftest: Extend vDSO selftest to clock_getres") Signed-off-by: Colin Ian King Reviewed-by: Vincenzo Frascino Signed-off-by: Shuah Khan --- diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c index 15dcee1..38d46a8 100644 --- a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c +++ b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c @@ -84,12 +84,12 @@ static inline int vdso_test_clock(unsigned int clock_id) int main(int argc, char **argv) { - int ret; + int ret = 0; #if _POSIX_TIMERS > 0 #ifdef CLOCK_REALTIME - ret = vdso_test_clock(CLOCK_REALTIME); + ret += vdso_test_clock(CLOCK_REALTIME); #endif #ifdef CLOCK_BOOTTIME