Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp68836lqn; Thu, 11 Apr 2024 14:12:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9VUgYll0r9NEvFhJ9UerrWgPp9my0EFp7Qme8unne/2mrHdEEBNfAgBnuqqIBimlY4Z0JDnSwjJp8wjq2eftf+iv8HtAFKgJuh9UhOQ== X-Google-Smtp-Source: AGHT+IEDeeDBMNj5qZ/e1P5A4AfZu9FTLLHr6APyYvP5CFEyJ1EGKR0rrz0MgyHI5/N5syCVF3pv X-Received: by 2002:a17:906:3c55:b0:a52:1491:aad with SMTP id i21-20020a1709063c5500b00a5214910aadmr505579ejg.74.1712869932051; Thu, 11 Apr 2024 14:12:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712869932; cv=pass; d=google.com; s=arc-20160816; b=ZDYfOX9rRfemyn0ajmmRYUPMvFqtvFn1Ig9Uwf66tWhexx5nqHtCuekUxVVJ1lwavF arGM4T3xLzf+678bK+j1yIKfsCbAmSLTvIFBe+KtmGd4d6m7x4HQ/XNrQv83zmm9zsb6 E+facEQgyh+sX5MD8rs+RA/b92XF+hcTG7Y/BgwPb8iWYmVUFKKwHRcEkDrLeGy6I0/w 4ZaKdT6Z/bab1gqHqHX2PfoCP6rppe3+AkZAUS0nxeGoHXyOLoANLgdafAumdqlNMvqz eGh/5L+udS+pxr/iUBhLkgxBmsAy0CipT1HPOcgCME3J4HqiM8FvSkQwG4XX7PyO+k1K leLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=38LeeLy9B9nLfzSgbJxSutTG0T1HzptAeGhsMkzO9sI=; fh=q1haRi0AJmYeVIM65J0uoPlg+WcY5y5ZbiLHJSl/nEE=; b=jyMgMGfov3H0jeKGIJS3W73/Y+QwW5xEywH+ycy+02DWdE8YVrm93dX35RByzI5pfk PHi/KY9gq3OC9NTy2HT/MKuV1KXCJvT4tMZvNAwpTuePqiG3F/GkVxga2gh+lIHzgjNG v6NaPymZefYaxHZs1gaBFAdY8mvTOVYJReskjw0yJZtkDOAKL+wHiReMJaKgLN/40Nyv sHtrB87DICOYzkTrXT9IAisn2uNseu3NvbGUB/NZS3/HnL9b8zO3IbcRdpa8y+jqtxim kr3l+EWK7EFlYZwA6QYVoNF3DqOwfdN48ID6NRXSxrD/umwROjfnL5JpLKvYloLIpD8O hQ5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=R9Z2wqZK; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linuxfoundation.org dmarc=pass fromdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-141612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id nc18-20020a1709071c1200b00a519ff0c0a1si1099406ejc.513.2024.04.11.14.12.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 14:12:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=R9Z2wqZK; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linuxfoundation.org dmarc=pass fromdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-141612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F1E771F2153E for ; Thu, 11 Apr 2024 21:11:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40C7017582; Thu, 11 Apr 2024 21:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="R9Z2wqZK" Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 036F92CCD7 for ; Thu, 11 Apr 2024 21:11:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712869871; cv=none; b=UatQEqWXZSV+umRvsAdQLlfpOi6QKUg6rD5RMB1Jyov9/OIjGyQpbKXqAoT/ljwiA1YHaUc3lm/6thkvTDDHP+iAfu5+4KHMjBnUWV9pIrQCQJ7JyjxpobzGL5/PZ9EZXbfSdBRCxFk9dT4dKW7fWnP7tokAQ3L5mA93EZfgiN4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712869871; c=relaxed/simple; bh=IEBJoFDSC/xhmN89SjQvJVuzGWr9gyS0EGlcaOZ8eMc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Hghdoa3dbUE5BfJ+CH8GCV+T/ljfot15152Ld9Ix7aYOQZUYydslCnZJG4yxfH3tB1snvLfwINob53v/7JAvFNjzNwBy3SiEMNu9031F9tI7wGma9HRGjKrO/NhNkQtD/Hg1oNpXsdz/xnMj9VHuxrkOKi2H6FSuV2+TiZfE3sM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=R9Z2wqZK; arc=none smtp.client-ip=209.85.166.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-7c8e4c0412dso2935339f.1 for ; Thu, 11 Apr 2024 14:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1712869868; x=1713474668; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=38LeeLy9B9nLfzSgbJxSutTG0T1HzptAeGhsMkzO9sI=; b=R9Z2wqZKlDPndBsAvIivYDjvNSev/rgLBf4LwV3Kni+m23IgN+pDY7fFz4kNLdy9oI vGm+hpHztC/B5G2tl4YXlLW/fLuLYOKO20cS9sFLm30Q16Nb8SB0NH1z/qQUZSSgRvFN CuBaI4aGvrwTEqpRTBQfPPwmf8GqNLPCSzznU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712869868; x=1713474668; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=38LeeLy9B9nLfzSgbJxSutTG0T1HzptAeGhsMkzO9sI=; b=khfDFsSSG9RrJYTygVZidlQjqVGOcWIUZzTjiEB/A0rWOKPYPeFg24aHBnmWAT9H6j Il97S0sYWUTrZd2ylQDvjAmCcjtHXcqcmRcdOhnrS+eEh6MLrZqoMLwh6+ua6VPSXskp YOMwmY1zeSfSEXy94UCugntUOFb9nh5g23FLCnXtGbtGA98Y7N4DS5gpgTSoZReytIjr yCED5V0va4MIvF1ufpBvCk53HAWdt0PaPy7bjxezgzEJbUKm9viT0hNPCcMNV1FEOWJI dVYepk4oPpWv4gSJsQIDFxXxTVZh5ehBenCNNZIUUz/fCIKL2jd77b5m3XJdjXuzj4bW wCdQ== X-Forwarded-Encrypted: i=1; AJvYcCWhwt1itcuLRUjndJQagnQ+r+vueFqLmdMi2AqJL+3yThQQvcxht+ldu411WOsIpyIk2d4xa2omi0CTRcg+tS3ouXOY4HJy6K/UnnA7 X-Gm-Message-State: AOJu0Ywhq2MkAzm9MhYO6+9HQxClPRg058akecb/ErV8ef+27UWKOG8D oaWETQuzC4AVkQ7ANvoiYjV5rAwmsnC5ig3m7BEteDZw43Hr93jobhs2KyLVlek= X-Received: by 2002:a6b:c34e:0:b0:7d6:7b7c:8257 with SMTP id t75-20020a6bc34e000000b007d67b7c8257mr1040368iof.0.1712869868075; Thu, 11 Apr 2024 14:11:08 -0700 (PDT) Received: from [192.168.1.128] ([38.175.170.29]) by smtp.gmail.com with ESMTPSA id bv21-20020a056638449500b0048075de1461sm598414jab.90.2024.04.11.14.11.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Apr 2024 14:11:07 -0700 (PDT) Message-ID: <8254ab4d-9cb6-402e-80dd-d9ec70d77de5@linuxfoundation.org> Date: Thu, 11 Apr 2024 15:11:07 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] kselftest: Mark functions that unconditionally call exit() as __noreturn To: Nathan Chancellor , tglx@linutronix.de, shuah@kernel.org, Muhammad Usama Anjum Cc: oleg@redhat.com, anna-maria@linutronix.de, frederic@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, John Stultz , Shuah Khan References: <20240411-mark-kselftest-exit-funcs-noreturn-v1-1-b027c948f586@kernel.org> Content-Language: en-US From: Shuah Khan In-Reply-To: <20240411-mark-kselftest-exit-funcs-noreturn-v1-1-b027c948f586@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/11/24 12:45, Nathan Chancellor wrote: > After commit 6d029c25b71f ("selftests/timers/posix_timers: Reimplement > check_timer_distribution()"), clang warns: > > tools/testing/selftests/timers/../kselftest.h:398:6: warning: variable 'major' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized] > 398 | if (uname(&info) || sscanf(info.release, "%u.%u.", &major, &minor) != 2) > | ^~~~~~~~~~~~ > tools/testing/selftests/timers/../kselftest.h:401:9: note: uninitialized use occurs here > 401 | return major > min_major || (major == min_major && minor >= min_minor); > | ^~~~~ > tools/testing/selftests/timers/../kselftest.h:398:6: note: remove the '||' if its condition is always false > 398 | if (uname(&info) || sscanf(info.release, "%u.%u.", &major, &minor) != 2) > | ^~~~~~~~~~~~~~~ > tools/testing/selftests/timers/../kselftest.h:395:20: note: initialize the variable 'major' to silence this warning > 395 | unsigned int major, minor; > | ^ > | = 0 > > This is a false positive because if uname() fails, ksft_exit_fail_msg() > will be called, which unconditionally calls exit(), a noreturn function. > However, clang does not know that ksft_exit_fail_msg() will call exit() > at the point in the pipeline that the warning is emitted because > inlining has not occurred, so it assumes control flow will resume > normally after ksft_exit_fail_msg() is called. > > Make it clear to clang that all of the functions that call exit() > unconditionally in kselftest.h are noreturn transitively by marking them > explicitly with '__attribute__((__noreturn__))', which clears up the > warning above and any future warnings that may appear for the same > reason. > > Fixes: 6d029c25b71f ("selftests/timers/posix_timers: Reimplement check_timer_distribution()") > Reported-by: John Stultz > Closes: https://lore.kernel.org/all/20240410232637.4135564-2-jstultz@google.com/ > Signed-off-by: Nathan Chancellor > --- > I have based this change on timers/urgent, as the commit that introduces > this particular warning is there and it is marked for stable, even > though this appears to be a generic kselftest issue. I think it makes > the most sense for this change to go via timers/urgent with Shuah's ack. > While __noreturn with a return type other than 'void' does not make much > sense semantically, there are many places that these functions are used > as the return value for other functions such as main(), so I did not > change the return type of these functions from 'int' to 'void' to > minimize the necessary changes for a backport (it is an existing issue > anyways). > > I see there is another instance of this problem that will need to be > addressed in -next, introduced by commit f07041728422 ("selftests: add > ksft_exit_fail_perror()"). Thank you. Assuming this is going through tip/timers/urgent Acked-by: Shuah Khan Usama, please send patch fixing this problem in next on top of commit f07041728422 ("selftests: add > ksft_exit_fail_perror()"). thanks, -- Shuah