Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4499393pxb; Thu, 14 Oct 2021 06:28:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK83aTnE1mqDSC1pJyCcxzLh4acYIvljn3Tv5xYvEUlAInQIJAjwt1a4gyfG5WcoSXRwkp X-Received: by 2002:a17:90b:1910:: with SMTP id mp16mr6216665pjb.30.1634218128644; Thu, 14 Oct 2021 06:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634218128; cv=none; d=google.com; s=arc-20160816; b=Rrr98og2WrrWiZKWqRNiVFQ1TNP5NAdRMrAIOHZzgo6kY/M6qWiOaFOlyY56BPRVw5 4JQfvzojRRbH2Q/0PPiqs23Ui1ZLMvo1KRvQ7sCHgy6PKrAFg9giQGJuUCMHxT2Om4F9 7iP0jVV9CJDdjV/ZvRo76vfb8pW5DA3zWXjuCtFVNRn9OGwYNPkayV1a+fBKmZ4nDU1J 01dpRxJkGNZ+9lvNX8znvSLSn14qCjdMun7ZOpAEf2d6U01YFplgD5WWVem69JbQUGjx 250oJTRZR+1bk1yy8kU/d50jqpdR4iRiAdds1nTfFxw7R+mFw745/AAqHxRDxljh/4XD z6iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=G+VO9ZdHg0tocQP/MydlT/+6nSf/b5PZODHMM4DS8qk=; b=t+wGgLZNN0mPpkj3Vcv2hjP4xtRjwe2GyXH1kYhciRfArq18FmC/f3pUqBe26p1xWe ybfFjKwCTrohIRM2jAvp+ta431O9eDFsNix2gESykzTrdK+mDmgwI4p4RfLvtguwPJsj SXsnfuyyZ+tHTZV3pMRkOhtjUpNvIQablGDEpjYLJ2ygQ5/uyZeZk+Hn8avLj60zrewO 4kFaOwtdwEir0VQeLpgXcuOBKPFqNAkPA2kvj7lqzfGVMvLeYHP9mKjxEhUkLWZvKftb 5K81phRNhaFFQrbkjtHjJCDz4Co6tsqTxYQEKA0LYXJtATqz429eD7m6zXdeOSGRw+C5 9jGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fdPjx+zg; 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 j73si3361160pge.284.2021.10.14.06.28.33; Thu, 14 Oct 2021 06:28:48 -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=fdPjx+zg; 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 S231166AbhJNN1N (ORCPT + 99 others); Thu, 14 Oct 2021 09:27:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:40626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbhJNN1M (ORCPT ); Thu, 14 Oct 2021 09:27:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BA8E2610CC; Thu, 14 Oct 2021 13:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634217908; bh=f1U17lI/SG3Xtkx8l82Y51XiQPdYrJgA9xNytnxUdvg=; h=Date:From:To:Cc:Subject:From; b=fdPjx+zgbWP0/AQqTSFcwHC7T11+SIgyDZeXZ8TuxMozmtOmOdWr/RcCUb0xe5gNf nu1xQdT7BaEASOPuajx0/NXdLTtHXFQj84Xpy1QI8l8VtWgwrpT0ne+32cxHFQCBXj e8jRBfx146GQ2DrB3Dgr89lfTpldx7afZgKVcYGRMsAtGAtOwdRKQF72NFDJLitL3i 43QjAnFdw17RzeQOF6B/qGYFcwIgpvhwmTVPvqqGg0DwsL3SOLi80ECaoBYavgUk6u Yu3ulnQ39UaR0PxNkcbGTkBygAJrYeS7Ow5Nl7IBjXU/oXc+k3lE24yw6272eUtHuC xIBnYHrKzAQgg== Date: Thu, 14 Oct 2021 15:23:31 +0200 From: Miguel Ojeda To: Nathan Chancellor , Nick Desaulniers Cc: Kees Cook , Peter Zijlstra , Miguel Ojeda , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn Message-ID: <20211014132331.GA4811@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: elm/2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org `__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 --- 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