From patchwork Mon Apr 15 12:20:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13629903 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 799A16D1B5; Mon, 15 Apr 2024 12:20:48 +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=1713183648; cv=none; b=U98HmTXd72ftqLnemWmStu+D6GsnXoKgED/MvbYiqRs1dFkEthm9TH4e9DjwZhIa/1U0urojYNGetufgY8CIsJ1ONC2JxS7DqmN36yhzgQwqPgzPrGxmd4bhfSp+M/Xpb471A9duaOPLrzXXH4WaU5Xu/y6OmvofVQQBg1j8NrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713183648; c=relaxed/simple; bh=9rWj91Ui3yXdrYdI/xJnn3eqhuI+T44/0BgWu41vBio=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mjjR0whXUB7c3Kru21/N4HPBDOh4T//jYlu8zQt8GM+x3uv9WeWAVKEd6pklE+RCIYTPO9GpjEoVHR0eS5XHwG3x/OG7ShNi5GTyd4YtDUKeJnmmTzVGYvmRj0mMuOo6hOfLraQ1vxtg9N77rKnEn/1c3p0P043mwMgSR+1NghI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rSrP0dWT; 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="rSrP0dWT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28CCFC4AF07; Mon, 15 Apr 2024 12:20:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713183648; bh=9rWj91Ui3yXdrYdI/xJnn3eqhuI+T44/0BgWu41vBio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rSrP0dWTMu2/IdKx7qvepoKhAnZ7EOl7KGN9Nh/Hq9qybD2qbUBwiDqqbEiLlvdJH bBzACt7BoWDybOEUMOq4C3MJcjoCuhq5567XE1yXGNv1DkpBds7ZzvAnwaHzrFjXeH /9CA62207RipTTXueygEh1xelWDTACJah/x/3AbQ6R8xFAZ4OLJK/EI94lW0VP0Rz6 NJrXuFN6CYP1YHqq9NbxyrlAKoJaA0gPVKh/xod14ayxUkh0YdqhVQ5gpx9YOMcLse jd0WyIBPS8hpm1bPZqPHLKyMH7Q13Avdjn3f8aGR8urL4iOIkfyRCqZvN6iFQT99CN g5bh1Nfz7PRWg== From: Arnd Bergmann To: Andrew Morton Cc: Arnd Bergmann , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Kees Cook , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] [v3] kbuild: turn on -Wextra by default Date: Mon, 15 Apr 2024 14:20:32 +0200 Message-Id: <20240415122037.1983124-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240415122037.1983124-1-arnd@kernel.org> References: <20240415122037.1983124-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann The -Wextra option controls a number of different warnings that differ slightly by compiler version. Some are useful in general, others are better left at W=1 or higher. Based on earlier work, the ones that should be disabled by default are left for the higher warning levels already, and a lot of the useful ones have no remaining output when enabled. Move the -Wextra option up into the set of default-enabled warnings and just rely on the individual ones getting disabled as needed. The -Wunused warning was always grouped with this, so turn it on by default as well, except for the -Wunused-parameter warning that really has no value at all for the kernel since many interfaces have intentionally unused arguments. Acked-by: Nathan Chancellor Signed-off-by: Arnd Bergmann Reviewed-by: Kees Cook --- scripts/Makefile.extrawarn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index c5af566e911a..c247552c192c 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -82,12 +82,14 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) # Warn if there is an enum types mismatch KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion) +KBUILD_CFLAGS += -Wextra +KBUILD_CFLAGS += -Wunused + # # W=1 - warnings which may be relevant and do not occur too often # ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) -KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter KBUILD_CFLAGS += $(call cc-option, -Wrestrict) KBUILD_CFLAGS += -Wmissing-format-attribute KBUILD_CFLAGS += -Wold-style-definition @@ -190,6 +192,7 @@ else # The following turn off the warnings enabled by -Wextra KBUILD_CFLAGS += -Wno-sign-compare +KBUILD_CFLAGS += -Wno-unused-parameter endif From patchwork Mon Apr 15 12:20:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13629904 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 B6CE06E612; Mon, 15 Apr 2024 12:20:50 +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=1713183650; cv=none; b=Rd90qPFKs6vVZjARAMuVJGcuVabmT8b0yDixAcxWBuEjO6Fp/GgqN9/bWJMoNWUEQry9QVVdLb16kCyZYRYCfIZ7gKWKQaKzLnbDyeL96DbP1M4/oPRvsmEbXk7tmQFQ1QWJSPrJkGVOKGvDyGaFuVIwCEVODZLaY0OyzcNS1SU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713183650; c=relaxed/simple; bh=eLuBpJKWhyM4IlNLRbcijbvdvKbw+xEyERqd1eOHI0E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q8z4nhaLle4Lw1kp7S2Uj9Ev0XRgM25/+rEPlZn6PYHTJQYbIcZQ4FyPZfLxB3aP6iPJAyaYedmmW6m4Umt5NXuBRzmJpPELzAtF0SfdaRToeVJDtC1vFoGGny/Z7bWYDDiRFLhEZOD/ghIXCk4Z7re2ECduk/wLJ6ZV1ArYnxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i7rNnt4o; 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="i7rNnt4o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DE58C3277B; Mon, 15 Apr 2024 12:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713183650; bh=eLuBpJKWhyM4IlNLRbcijbvdvKbw+xEyERqd1eOHI0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i7rNnt4oi5SBsEAOZbb234zsfmvss2yhv/ZCiVHEtRa9wACjgvLvKMPzMtU4nJnNu 7cKfrxmtQsJElyGYLFiDLW7az7bN/RvFHKatGpIuVAUwxRqDWdE0pgABqXJaASheUP gMK3fRjJa+bk7tAgcyFlET1CVhEs3g4WjDEwEEBzo+Y/Q5yxi5p6xQC1U3/zsDpRWf 4UP/G6GUgPaH9J+kOCW8W9uyFrGJ9qluidrPUUjtYatSm/s2XbfZHUWAUjXO/VYfPr zQUABzblNx0ze2zXNyH3lmMCS1YtB3huNrmDmU1/wilYGg2idfuHSpNT+GWmSHLwdZ cq8sujwxUrcnQ== From: Arnd Bergmann To: Andrew Morton Cc: Arnd Bergmann , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Kees Cook , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] [v3] kbuild: remove redundant extra warning flags Date: Mon, 15 Apr 2024 14:20:33 +0200 Message-Id: <20240415122037.1983124-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240415122037.1983124-1-arnd@kernel.org> References: <20240415122037.1983124-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann There is no point in turning individual options off and then on again, or vice versa, as the last one always wins. Now that -Wextra always gets passed first, remove all the redundant lines about warnings that are implied by either -Wall or -Wextra, and keep only the last one that disables it in some configurations. This should not have any effect but keep the Makefile more readable and the command line shorter. Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index c247552c192c..8b3f5b62b837 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -37,11 +37,6 @@ else KBUILD_CFLAGS += -Wno-main endif -# These warnings generated too much noise in a regular build. -# Use make W=1 to enable them (see scripts/Makefile.extrawarn) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) - # These result in bogus false positives KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer) @@ -90,16 +85,9 @@ KBUILD_CFLAGS += -Wunused # ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) -KBUILD_CFLAGS += $(call cc-option, -Wrestrict) KBUILD_CFLAGS += -Wmissing-format-attribute -KBUILD_CFLAGS += -Wold-style-definition KBUILD_CFLAGS += -Wmissing-include-dirs -KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable) KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable) -KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned) -KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow) -KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation) -KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation) KBUILD_CPPFLAGS += -Wundef KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1 @@ -150,9 +138,6 @@ ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),) KBUILD_CFLAGS += -Wdisabled-optimization KBUILD_CFLAGS += -Wshadow KBUILD_CFLAGS += $(call cc-option, -Wlogical-op) -KBUILD_CFLAGS += -Wmissing-field-initializers -KBUILD_CFLAGS += -Wtype-limits -KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized) KBUILD_CFLAGS += $(call cc-option, -Wunused-macros) KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2 From patchwork Mon Apr 15 12:20:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13629905 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 D72D96EB65; Mon, 15 Apr 2024 12:20:52 +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=1713183652; cv=none; b=ZpqXawLhpNBnP1y6yA0669NQpL2J/WXE34Em0fEqzQHndfIaunP9pHikDoD6FsiZXTszy6dne6BMxINizy4rI7GiyBZerkGpPLppTX7OcF/C10eBzAJ7spimA4N8Qc6ags6QGJyebJU4bWn8ky25v+sEBI1KO5lJI3DAD/KqjJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713183652; c=relaxed/simple; bh=mTgeIYCmciNqI0jeKacsXjlw+DjiDCIlmChxzf0Df80=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HhRRCIO2lpCkG1VWMQxBkmGg8SeQD+S9EFQgL+Kw7qDqe3ApOoORhEs+Vhj1iRiOSKq/1UeKZNzchnZ9hlWaZg0DBVyYUkxbY+fh6z/yJf2jeWVKlBbuEXv4uCGIRGdaviOVeLDbYcWYSjfB/SHYWpQdMLzSi3v6gw7yMhml30A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FHaHYBEZ; 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="FHaHYBEZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF78FC4AF08; Mon, 15 Apr 2024 12:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713183652; bh=mTgeIYCmciNqI0jeKacsXjlw+DjiDCIlmChxzf0Df80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FHaHYBEZ7SwFPB2Y0v2tECQAWnBsG4DlLTyyZQnL0MJNEHRZsBSTk9W0dV5QkLC6U cak7Eq3NKoczjdsX0hYxKg3iegMBZOjhFp6/jcpCe+PxlgHqaRAf4k70LS09vPPjm9 okaPj6Wsar6jC0iNTh3GVWeQCnKKvZMjSEh+J+444WkbUhwHPE4HaEBrVSsGwE+hKH n7Q6KbyFhjuKgFLXscf2NPtabfl0RuonGzelISpB4ZQgL99/yy/4vogkC4mSg9zH57 ux+0ImSsTfOZH48BJR+CRCyKKaa3rVIbwafFkDvAl5k4qtRv7jVLnahYD0NpEVnoSR EGu5WEwGDkMrA== From: Arnd Bergmann To: Andrew Morton Cc: Arnd Bergmann , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Kees Cook , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] [v3] kbuild: turn on -Wrestrict by default Date: Mon, 15 Apr 2024 14:20:34 +0200 Message-Id: <20240415122037.1983124-4-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240415122037.1983124-1-arnd@kernel.org> References: <20240415122037.1983124-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann All known -Wrestrict warnings are addressed now, so don't disable the warning any more. Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 8b3f5b62b837..95466a04d51b 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -98,7 +98,6 @@ else # Suppress them by using -Wno... except for W=1. KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) -KBUILD_CFLAGS += $(call cc-disable-warning, restrict) KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) From patchwork Mon Apr 15 12:20:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13629906 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 4EB296F515; Mon, 15 Apr 2024 12:20:54 +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=1713183655; cv=none; b=gPmTnVfqxWD5T0gDsYhHaYxlvnzfBtJ1pBV0rSSTAq1USwu4WLF9yu8focsFCHmTSDCcm3xUIn9uIb5UleEGjleVvCT7/guZSnhkS/n/UN2lplFcGlen9WE7HL4rJ5jdmY6VN31iicBE6JHbqIz3JaOeGk2+20nXkt7ga7ZIp9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713183655; c=relaxed/simple; bh=8JKhrJT3q63/BXO9ILtj2EX2ia1+UIIUhuNAvPawccM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ATsOLcE6uOUUdluzRk/lDUHjyxkFSQM0bY3Tq2Xc0a6crqrEvjcc8dWMSzyVFZZKXiKzPjjW0K2gC4rmrxbdvemMbbltvceOHaDANIlXMZT08lOl9Ri4K37wA9A4YagQWn4MQhp8gLzIpzMitc3r7I74nGM9w5Xfdtsef/WH0v4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qnlL7jUD; 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="qnlL7jUD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2C02C32783; Mon, 15 Apr 2024 12:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713183654; bh=8JKhrJT3q63/BXO9ILtj2EX2ia1+UIIUhuNAvPawccM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qnlL7jUDv7TTP2v4bEWYvzv+ygQxlEQxsAxojfWkiCbLzw0rr+JALMsJJ6C2XHw81 ku2Snmkl4o/iEbG+KibhPGJSLDQJaJmr1h5UusKYVoAPrBzup0Z54IVC40VBFgyiRg 8YcwiZaG5Yh9ya6CloB9jKCNZxuNL3oyzBMzBQDCk1dPi7REMFtgr7eOWtvqRZRC73 L9whn9FXY+oazENeODSNeyYMGgeYSK/oOCEPnxxmkTZmcD4KHMRT5DzO+naXkpCy53 c/wzLjuSSV+f8aga5cXQhtsOeQOEQRGngzChWdHc/J6HepFlhET/6OTph2+BugApGs gMyH+QcwWWx4A== From: Arnd Bergmann To: Andrew Morton Cc: Arnd Bergmann , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Kees Cook , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] [v3] kbuild: enable -Wformat-truncation on clang Date: Mon, 15 Apr 2024 14:20:35 +0200 Message-Id: <20240415122037.1983124-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240415122037.1983124-1-arnd@kernel.org> References: <20240415122037.1983124-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann This warning option still produces output on gcc but is now clean when building with clang, so enable it conditionally on the compiler for now. As far as I can tell, the remaining warnings with gcc are the result of analysing the code more deeply across inlining, while clang only does this within a function. Link: https://lore.kernel.org/lkml/20240326230511.GA2796782@dev-arch.thelio-3990X/ Link: https://lore.kernel.org/linux-patches/20231002-disable-wformat-truncation-overflow-non-kprintf-v1-1-35179205c8d9@kernel.org/ Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 95466a04d51b..202e26e6f29f 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -100,7 +100,14 @@ KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) +ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) +else +# Clang checks for overflow/truncation with '%p', while GCC does not: +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219 +KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf) +KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf) +endif KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang From patchwork Mon Apr 15 12:20:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13629907 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 82D016FE13; Mon, 15 Apr 2024 12:20:57 +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=1713183657; cv=none; b=DYKuooGkW0xZC8/a/G48PuOS0mevLqBwRXrq/jmKcpisZ1RaLI0UVc4EmA5goAS97A+BtBhSnUs0YlPnfyFH3AK4zhEO8QO6qGLhsOVHPhtAdVdM8Em0mkwTvDb4Yn8DiBSq0tbn63G2dCe8B7GBbR4oTvOSG+ifR6Z2hIGtt8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713183657; c=relaxed/simple; bh=9eX7Dorhxn5NmgYg6HTuaELf/+jBReTSX1vzE2y0wKY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sSxFzFGBFNUlkMGleD//nfahiwMVpWSqe+lLm4NbN9ApxMUFLDsG27Ry/Jib95cDPpAzgl4wXqpugEjIUdaWOu6dYmj2D00lq+EozlTQSsQ75mE5PUBK4KqYxDFfYo7N4rTsiz84v5IuuRXxDhLl4ScbM5p0KnMPmAF8Ra9yVrU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZT1G/BPb; 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="ZT1G/BPb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40002C2BD10; Mon, 15 Apr 2024 12:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713183657; bh=9eX7Dorhxn5NmgYg6HTuaELf/+jBReTSX1vzE2y0wKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZT1G/BPbNSMh3ZCBNEwiAXm4fbRIwJ9kPZOjYGWNY/HkyZQSY0ruRxm6AWE+cYdQt KfrInn4GQEHhz0QTDxUF/nJdU2IV1zGjTozYC+/W2EhkiJhz663HgJd5BwRjLbWnMe 0zlk+xB6SZg2spnt41CFG8IGmrOvJL+SQHQ0szlxenVHQpxyf1RT8k1TJLi8embn45 gP7kSEDhccftWGh49Hc7541un1bFN5OY+u50M6j9/YXAvoPfWoiYmUUmvfLqv2AGWZ zF3IkXEH26G9g4zqJJ4UaF37EvcxoLNHXib5hFQB/ZPPSSQW6zra6fSRabdmjG2laj iwuWZnZpRxUSg== From: Arnd Bergmann To: Andrew Morton Cc: Arnd Bergmann , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Kees Cook , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] [v3] kbuild: enable -Wcast-function-type-strict unconditionally Date: Mon, 15 Apr 2024 14:20:36 +0200 Message-Id: <20240415122037.1983124-6-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240415122037.1983124-1-arnd@kernel.org> References: <20240415122037.1983124-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann All known function cast warnings are now addressed, so the warning can be enabled globally to catch new ones more quickly. Signed-off-by: Arnd Bergmann Reviewed-by: Kees Cook --- scripts/Makefile.extrawarn | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 202e26e6f29f..1d13cecc7cc7 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -129,7 +129,6 @@ endif KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast) KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access) -KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict) KBUILD_CFLAGS += -Wno-enum-compare-conditional KBUILD_CFLAGS += -Wno-enum-enum-conversion endif From patchwork Mon Apr 15 12:20:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13629908 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 BCD7670CAD; Mon, 15 Apr 2024 12:20:59 +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=1713183659; cv=none; b=Q+N9J3nwy4fJ/sokrJU4GpcSeZtHylc2dYmPDu20/WsFHFOhgOG21bn5uilHUcI/fx/mET17IChxzpKYBDYKt92aXYciD0Wwp0GpUjwVw4bYEIWqGG7pwfN+B9WWX6a664zfIT+2VCxKS2PmvPAEeLIPpuHvIZelU5nAzfA5VOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713183659; c=relaxed/simple; bh=rFheM71yjeyhsdNNlmFP4+aGuyKqpUtHIcDrzZ28OAI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e4ADMjHrM/gI0pNg7MOJdGlmaBMx18CBY0mRUonpuL0uIw89PhkI+v1sDjhB4xvqGQ+mV82Wr7sfCS+22HWVd9H2zdr4+7T1UTXD4z824UkMCrDiXk0x6voM+ZpGJJZDJ8fRXEncZabZvRJB+umV1P3ER2XEEo301f3fX4AsJIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eQpdE6Gu; 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="eQpdE6Gu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81A4FC4AF07; Mon, 15 Apr 2024 12:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713183659; bh=rFheM71yjeyhsdNNlmFP4+aGuyKqpUtHIcDrzZ28OAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQpdE6GuxbEQNfuOyFt+EkGaz36CTj5VFlsD3OgUJGhuFsy9ntPntCbL7Gte3FBcY 1kc8TnF7C28DHfBAPorUAdaOyRfq1pPxA5KrV59hyC/aMWMVSiIQRTf6mzdI2HIOIq oIci99l9WdfM/aSfPq+iF+58mVD1nEoKEyOFk+F1bX1rKCBzUuq7caFE5RGr0qkxwn JtKr7+oTM/eODyORqhiBBMkti4HoLHteI+MT6kjf5Lnm6xdW+LxaZ96BHzHQs5PdbC grhTAqAjwaJa31mr13JqPu1+HClA74HitSBcQJN5vC+7FpB68Kj8Ty2KyCfQUJJ9be X4n2O1ZkQ92sQ== From: Arnd Bergmann To: Andrew Morton Cc: Arnd Bergmann , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Kees Cook , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] [v3] kbuild: enable -Wstringop-truncation globally Date: Mon, 15 Apr 2024 14:20:37 +0200 Message-Id: <20240415122037.1983124-7-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240415122037.1983124-1-arnd@kernel.org> References: <20240415122037.1983124-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann The remaining warnings of this type have been addressed, so it can now be enabled by default, rather than only for W=1. Signed-off-by: Arnd Bergmann Reviewed-by: Kees Cook --- v3: no changes v2: no changes --- scripts/Makefile.extrawarn | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 1d13cecc7cc7..17c511ddf48a 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -108,7 +108,6 @@ else KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf) KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf) endif -KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang