Building with clang, I see the following warning:

In file included from posix_timers.c:17:
./../kselftest.h:398:6: warning: variable 'major' is used uninitialized 
whenever '||' condition is true [-Wsometimes-uninitialized]
        if (uname(&info) || sscanf(info.release, "%u.%u.", &major, &minor) != 2)
            ^~~~~~~~~~~~
./../kselftest.h:401:9: note: uninitialized use occurs here
        return major > min_major || (major == min_major && minor >= min_minor);
               ^~~~~

This is a bit of a red-herring as if the uname() call did fail,
we would hit ksft_exit_fail_msg() which should exit.

But to make clang happpy, lets initialize the major/minor values
to zero.

Cc: Shuah Khan <[email protected]>
Cc: Anna-Maria Behnsen <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: Bill Wendling <[email protected]>
Cc: Justin Stitt <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Edward Liaw <[email protected]>
Cc: Carlos Llamas <[email protected]>
Cc: [email protected]
Cc: [email protected]
Fixes: 6d029c25b71f ("selftests/timers/posix_timers: Reimplement 
check_timer_distribution()")
Signed-off-by: John Stultz <[email protected]>
---
 tools/testing/selftests/kselftest.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kselftest.h 
b/tools/testing/selftests/kselftest.h
index 973b18e156b2..12e2f3ab8b13 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -392,7 +392,7 @@ static inline __printf(1, 2) int ksft_exit_skip(const char 
*msg, ...)
 static inline int ksft_min_kernel_version(unsigned int min_major,
                                          unsigned int min_minor)
 {
-       unsigned int major, minor;
+       unsigned int major = 0, minor = 0;
        struct utsname info;
 
        if (uname(&info) || sscanf(info.release, "%u.%u.", &major, &minor) != 2)
-- 
2.44.0.478.gd926399ef9-goog


Reply via email to