From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76950DF5C; Thu, 11 Apr 2024 18:47:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712861230; cv=none; b=d8MXoL0ZWGBsZwGpdXcrZU/KoRCBnRjiUyuuVO1dY0CC3SW8inP2+NZH7JmXJ1BVKfWkj7p2VNSZOczmAktIUVhEcmOjOdofKWyNozRFI/zLucxolY6H4cSi1U/1R0VPfHYfZmu9V4vBbACd2ZkjhUdGs3uvZyTg6+wBrLZ67g4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712861230; c=relaxed/simple; bh=MCeR7HtXL7nbj9uUbgxs72avaXllwlL5Zu3wM03KPLA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=crhKlZoeB8YLa/70tVKsOSYt5ZUAtQ0fRx+LJlzd97/KVLoZRJBgdnJsiGgwz9yVvJtyPRlLqmuZgNpqVe3Ki1SimA11n/Z2a5WblHhpZClXrEsjZ3MKsMyCzTo7r6ghdfGAffRlFhMsLCT8GP9TJfCUh0BpJmCdIJpU2n0v/Ms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=De7ESMTs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="De7ESMTs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DACAC072AA; Thu, 11 Apr 2024 18:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712861230; bh=MCeR7HtXL7nbj9uUbgxs72avaXllwlL5Zu3wM03KPLA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=De7ESMTs/7MYP2JnavGZGYEyz6N/7fYQmuLWAZ+K1zgQNOGKxGyN/uGL7eS+4QeYl SfZa3knyteFFXBQ39dEaunMhzCgxjza3gMgMvCXqnuLyGk13Q+hg4PNKZmAiL6Ywnv XrYKvb3Ifw++Y6/Kvr7KIMro4g0fW7MzhI19oE0FZzeZX8fzqgxg46rtE5wmRjd8Fb v8K+vBi0zTZq8hplA+tCBOjuM4q/Dop8Rv3q8SSFbgZ0wIlWy8PnasGM0fDVCbba8R nNfjlaUP90z5VZELIByN671DugpZNvnWyRQ8IsBkndZIrMHpcKtesXLW2uQW3bzfFI bX3PGc+eSZMAg== Date: Thu, 11 Apr 2024 11:47:07 -0700 From: Nathan Chancellor To: John Stultz Cc: LKML , Shuah Khan , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Stephen Boyd , Nick Desaulniers , Bill Wendling , Justin Stitt , Oleg Nesterov , Andrew Morton , Edward Liaw , Carlos Llamas , kernel-team@android.com, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 2/3] selftests: timers: Fix uninitialized variable warning in ksft_min_kernel_version Message-ID: <20240411184707.GA153244@dev-arch.thelio-3990X> References: <20240410232637.4135564-1-jstultz@google.com> <20240410232637.4135564-2-jstultz@google.com> <20240411153945.GA2507795@dev-arch.thelio-3990X> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Apr 11, 2024 at 11:11:59AM -0700, John Stultz wrote: > On Thu, Apr 11, 2024 at 8:39 AM Nathan Chancellor wrote: > > On Wed, Apr 10, 2024 at 04:26:29PM -0700, John Stultz wrote: > > > 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. > > > > Correct, although we have not really conveyed that to the compiler, > > right? exit() is noreturn, which means all functions that call exit() > > unconditionally are also noreturn, such as ksft_exit_fail_msg(). LLVM > > will figure this out once it performs inlining and such but that happens > > after clang's static analysis phase that this warning occurs in. I think > > a better solution would be to add __noreturn to the functions in > > tools/testing/selftests/kselftest.h that call exit(), so that the > > compiler is aware of this through all pipeline phases, maybe something > > like this? It resolves the wawrning for me. > > No objection from me if this is the better approach. > > Would you send that patch out? Done: https://lore.kernel.org/20240411-mark-kselftest-exit-funcs-noreturn-v1-1-b027c948f586@kernel.org/ If you have to respin this series for some reason, feel free to include that change so that they go together, up to you though. Cheers, nathan