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 shuah@kernel.org Cc: Anna-Maria Behnsen anna-maria@linutronix.de Cc: Frederic Weisbecker frederic@kernel.org Cc: Thomas Gleixner tglx@linutronix.de Cc: Stephen Boyd sboyd@kernel.org Cc: Nathan Chancellor nathan@kernel.org Cc: Nick Desaulniers ndesaulniers@google.com Cc: Bill Wendling morbo@google.com Cc: Justin Stitt justinstitt@google.com Cc: Oleg Nesterov oleg@redhat.com Cc: Andrew Morton akpm@linux-foundation.org Cc: Edward Liaw edliaw@google.com Cc: Carlos Llamas cmllamas@google.com Cc: kernel-team@android.com Cc: linux-kselftest@vger.kernel.org Fixes: 6d029c25b71f ("selftests/timers/posix_timers: Reimplement check_timer_distribution()") Signed-off-by: John Stultz jstultz@google.com --- 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)