Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4793035pxb; Thu, 14 Oct 2021 12:04:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznkKb71IG7mWZToDcB/9QxCMkmKodL0wGX+mp2/JGd+Lw1I4tSKaM8t7IkxPdg7Ui3YuHQ X-Received: by 2002:a17:90a:ff98:: with SMTP id hf24mr16635182pjb.203.1634238267138; Thu, 14 Oct 2021 12:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634238267; cv=none; d=google.com; s=arc-20160816; b=ZFzp/0i4RfaOVk1LruPkjTJ/ZxlvPGwOQfcoStQz+tBNVZzkkka+Bg2tGrCzR/8tbj fbjZ6bVKgPnqf8KljqSa5ZFct1HXnGRBf2RMJgk725150sZx+ZzyvrqdjLJIAjbgbGHd 03YoWD43ezlz6vPJ8OdxgoK91SCjzFINy3Vop82yhbSnD7RTay8tiilHj8fHa+cIJq2T Lm0TBPQsyjC0X9x6+u6bt7Yctz/cNtgW8UY6BH0D6glIp8cE4wVcIZOq7bnHgEbN7ZgN WDZ1GDvfoFf2tOvm0y+9Sg284TSdJu6utVpYAaYFBDXoSLtMveZKb7m3hZCNFzAID8ep I5Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IWUKhC2lnhr3GjpNrspTTNGXYNIW1XOBjVdTwaUB1rI=; b=mhvY194j4sL0lkpPMzwBsN1WIYpx8qGzDYn/qQbGaslsZX7UEt4vRXKkczDT8zUOV+ PkLuKeMPRkPC8u0BqmwHXuID1/QJ3IQW/24er7sxDC7S8RXJvV/2LieBpzw45qR0T05r oVgCLblihc8EOMZrx29ixbOrHpR7MDcXcMvLDYoWbZsjzVaM+7R41DjFX3J7AzI/im3G v4+gvSFebLbiwlZkeDEg6vP3E+EvfipKuYL4q6vKid38Tv9aXBmxisTKD8WZXlOSSC6+ OriAoWiNV0QSkpEUxejzfDDCDGY1e8F3qj2q3Odf16VMWuhT88eDWisxVFZCD7Er2eo8 1nRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jDJf4ujo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si4660857pgj.173.2021.10.14.12.04.07; Thu, 14 Oct 2021 12:04:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jDJf4ujo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233434AbhJNR2k (ORCPT + 99 others); Thu, 14 Oct 2021 13:28:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:50506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231199AbhJNR2g (ORCPT ); Thu, 14 Oct 2021 13:28:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BD2261152; Thu, 14 Oct 2021 17:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634232391; bh=o0QsazVMagTZA1XmrDz3OQqKaBb0s1Tde3hbsP0uePk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jDJf4ujoCOZS0iYOctJNZQGY9RghDBt1PpXR1GZDqqR5AEThHfi3KSmGrD7fYEaC0 oEK42B78SI3dGjnYnaaUWHSlsGNauW6LVwz/TIYxZFKYkKEfnelTBCcFfRQIWMkCuD KHD2m81AjgnXq9nqEf1I0kTQX4D3q1HdRixdreYt5gh4nXxJAol4B7jWiJoStgOmsE dEub2tOq9KlrnwGbblTYlnLPlwi9kmxvBtq4ev3SXfSwQBUV6p5xbuikiXmmAjRSxP monAKViPysgUYuREjDMb+qMcZWFmRGFNfmp1JAaPuno2QZ7/D4k4gDVsCZk8x51jEG yayl6XuJS98rw== Date: Thu, 14 Oct 2021 10:26:27 -0700 From: Nathan Chancellor To: Miguel Ojeda Cc: Nick Desaulniers , Kees Cook , Peter Zijlstra , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn Message-ID: References: <20211014132331.GA4811@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211014132331.GA4811@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 14, 2021 at 03:23:31PM +0200, Miguel Ojeda wrote: > `__compiletime_assert` declares a fake `extern` function > which appears (to the compiler) to be called when the test fails. > > Therefore, compilers may emit possibly-uninitialized warnings > in some cases, even if it will be an error anyway (for compilers > supporting the `error` attribute, e.g. GCC and Clang >= 14) > or a link failure (for those that do not, e.g. Clang < 14). > > Annotating the fake function as `__noreturn` gives them > the information they need to avoid the warning, > e.g. see https://godbolt.org/z/x1v69jjYY. > > Link: https://lore.kernel.org/llvm/202110100514.3h9CI4s0-lkp@intel.com/ > Reported-by: kernel test robot > Signed-off-by: Miguel Ojeda Reviewed-by: Nathan Chancellor > --- > include/linux/compiler_types.h | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h > index b6ff83a714ca..ca1a66b8cd2f 100644 > --- a/include/linux/compiler_types.h > +++ b/include/linux/compiler_types.h > @@ -298,7 +298,13 @@ struct ftrace_likely_data { > #ifdef __OPTIMIZE__ > # define __compiletime_assert(condition, msg, prefix, suffix) \ > do { \ > - extern void prefix ## suffix(void) __compiletime_error(msg); \ > + /* \ > + * __noreturn is needed to give the compiler enough \ > + * information to avoid certain possibly-uninitialized \ > + * warnings (regardless of the build failing). \ > + */ \ > + __noreturn extern void prefix ## suffix(void) \ > + __compiletime_error(msg); \ > if (!(condition)) \ > prefix ## suffix(); \ > } while (0) > -- > 2.33.1 >