Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2905487ybk; Mon, 18 May 2020 10:47:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJil7TVPvJpys7ZXZPkO+VgFvSfjwcLtmZPqkGnZurZLsZpMDDp9p5uyxZzIhfvayVKtMS X-Received: by 2002:a17:906:4eda:: with SMTP id i26mr16349046ejv.228.1589824024053; Mon, 18 May 2020 10:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589824024; cv=none; d=google.com; s=arc-20160816; b=UtmGc9TfeGHdJMQnMSCAREWqKk3XHJPMhswVSHK5G5mFXsvTMqxhw5h8By5DTM/QkG JbN+BpRegLK+mpCIMdAZA2ZcH0oZs7cezx/RUgrkEpoPlngsSMV8MelcDuq8xp882HdS 5AyfUc/rvqhI1diG8LtPqTtGaJFTI/pOjq34p2yeRDkR/5JTtJChWx1rQ/tJRT/cH1Jz Ro9jfDhDkkLYKv7FehUniIh4WGbo57eyesUjvTdh8eLyKVQYm15+JmUhCqIiAM+h+q2P OerBOMHk2LqIFvX2JKILnxv1UAJldH7kaSi+EYqsugSSUq/GjpSF5NC+3X3PJ30H1iq9 Iqag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m1DKyHJDCmUkUfmQ3XhuHiHTWSQnuNoN53weD0ClwRo=; b=hz+df4lB3g5isPQ5ADMO4FeqN4vtHxTomEkQioJ44eCBqg4a/kl8FB9W420nRc+52S dGdzxVYXKqhTin1OLdG5MCIMnsgr/ZzR1VzKBNWpj7Tut41AR8hrpWQI1BpiQ8fLW6Vz mnSJz8XboOfuj5KNZkkWMtsy5iydywTlGXinppiasxXqqRwc1nK0OPL2VcJKdr+HQL02 PpLHLuX2TwV8/O9e1UUpgK/XONM/nlD8+J8f7jk8hzenbp4eWy2G0dE9S3U2qbxe98ob 30Sz+wGLUB6wQasxPIxsQtK/1eNE1cAo2ONUIPoXR0Ks5arn/Dl9kkItZg0wBrqTPkS9 S3mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YVwSh0Uc; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si7171169ejk.381.2020.05.18.10.46.41; Mon, 18 May 2020 10:47:04 -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=default header.b=YVwSh0Uc; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729715AbgERRoR (ORCPT + 99 others); Mon, 18 May 2020 13:44:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:42342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729704AbgERRoN (ORCPT ); Mon, 18 May 2020 13:44:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 930AF20835; Mon, 18 May 2020 17:44:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589823853; bh=FVLgpGr8qex7mofHgRNQMo+UaiHfOrUMGaBPTCsnP+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YVwSh0UcozbEvk+Z9SBff4MkW8Bal3iH/DXTWRHOqiX8MTRucHMRbXxWlSbMa0HWf 5PH1FF1sS3u82YXCODiC2EE2IkcvVIpsV6sLI0Kzj0h/D4XJfzmJzxZ2Er9J2oOa9g yYfaGQW6Fuq+xNP2UEucUdSLXVJhcXSFFUbeFNSA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds Subject: [PATCH 4.9 61/90] Stop the ad-hoc games with -Wno-maybe-initialized Date: Mon, 18 May 2020 19:36:39 +0200 Message-Id: <20200518173503.542960889@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.930655662@linuxfoundation.org> References: <20200518173450.930655662@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Torvalds commit 78a5255ffb6a1af189a83e493d916ba1c54d8c75 upstream. We have some rather random rules about when we accept the "maybe-initialized" warnings, and when we don't. For example, we consider it unreliable for gcc versions < 4.9, but also if -O3 is enabled, or if optimizing for size. And then various kernel config options disabled it, because they know that they trigger that warning by confusing gcc sufficiently (ie PROFILE_ALL_BRANCHES). And now gcc-10 seems to be introducing a lot of those warnings too, so it falls under the same heading as 4.9 did. At the same time, we have a very straightforward way to _enable_ that warning when wanted: use "W=2" to enable more warnings. So stop playing these ad-hoc games, and just disable that warning by default, with the known and straight-forward "if you want to work on the extra compiler warnings, use W=123". Would it be great to have code that is always so obvious that it never confuses the compiler whether a variable is used initialized or not? Yes, it would. In a perfect world, the compilers would be smarter, and our source code would be simpler. That's currently not the world we live in, though. Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- Makefile | 7 +++---- init/Kconfig | 17 ----------------- kernel/trace/Kconfig | 1 - 3 files changed, 3 insertions(+), 22 deletions(-) --- a/Makefile +++ b/Makefile @@ -663,10 +663,6 @@ else KBUILD_CFLAGS += -O2 endif -ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED -KBUILD_CFLAGS += -Wno-maybe-uninitialized -endif - # Tell gcc to never replace conditional load with a non-conditional one KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) @@ -801,6 +797,9 @@ KBUILD_CFLAGS += $(call cc-disable-warni # disable stringop warnings in gcc 8+ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) +# Enabled with W=2, disabled by default as noisy +KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) + # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) --- a/init/Kconfig +++ b/init/Kconfig @@ -16,22 +16,6 @@ config DEFCONFIG_LIST default "$ARCH_DEFCONFIG" default "arch/$ARCH/defconfig" -config CC_HAS_WARN_MAYBE_UNINITIALIZED - def_bool $(cc-option,-Wmaybe-uninitialized) - help - GCC >= 4.7 supports this option. - -config CC_DISABLE_WARN_MAYBE_UNINITIALIZED - bool - depends on CC_HAS_WARN_MAYBE_UNINITIALIZED - default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9 - help - GCC's -Wmaybe-uninitialized is not reliable by definition. - Lots of false positive warnings are produced in some cases. - - If this option is enabled, -Wno-maybe-uninitialzed is passed - to the compiler to suppress maybe-uninitialized warnings. - config CONSTRUCTORS bool depends on !UML @@ -1349,7 +1333,6 @@ config CC_OPTIMIZE_FOR_PERFORMANCE config CC_OPTIMIZE_FOR_SIZE bool "Optimize for size" - imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives help Enabling this option will pass "-Os" instead of "-O2" to your compiler resulting in a smaller kernel. --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -342,7 +342,6 @@ config PROFILE_ANNOTATED_BRANCHES config PROFILE_ALL_BRANCHES bool "Profile all if conditionals" select TRACE_BRANCH_PROFILING - imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives help This tracer profiles all branch conditions. Every if () taken in the kernel is recorded whether it hit or miss.