From nobody Sat Feb 7 19:41:31 2026 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 2857F18FDAF; Fri, 19 Dec 2025 22:40:25 +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=1766184025; cv=none; b=gT5wip1ePm6bU4wwG7aBanF6twW6uyzjAlj+Ga1q+s7ZK6Bm1QiDXLNXJ3nw3X0j/xV/H7RY99UTsc6fqfWtIZdQvfIfQtYHIo1iroXvWsG6D3CABcbHCG38LXNjWLmOQQqsEN1T+6XYhMXddwnC4tGlbpN/h+UfqdnR0tlHRVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766184025; c=relaxed/simple; bh=ap8MRB6u43PIFW27qfddd/82fqc/71rc4wGTDPI7wLo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EDGbl+klYnDdl1oHvKPp/+ZG71R/M1uGUg6+lfUrcHEg2OnIQAzgvQDFcvG30E6+1m+nDKGmkgpBkQmb7CTIAgXWBwcg/YOVQntssToVNSPIN2Ugavsjaj2HztFhPyYlzNII5vYnSmkePxiqp0iFjBK+05pPuSlQfvKsbB9HFPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tb5vscoD; 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="Tb5vscoD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D82CC113D0; Fri, 19 Dec 2025 22:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766184024; bh=ap8MRB6u43PIFW27qfddd/82fqc/71rc4wGTDPI7wLo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Tb5vscoDw5UPBzWlw7lS7k32m1rdT2wMczjZSevjFzarIQwwZ8OqNpRnd+QJtpD85 upPevm3y9OIb2elSe+lEg73VuVA73WinBRg2hPwAk5p1wU8YP6iujSYUVj/PVlcr2F 5OMRtIu+bdwC2g3daGLUSNtEowGf/Vps7R6vWdxRsBAefto4/Xy/6ca+VMqjU8isDX 9oV3bDFfjNhxWHjoV68T2eXcZhUFNo+NOrTugH5cuyOZFGceW6VbJxuW0wG4a+R7UJ JMBYOoACYCQrfCLuKd77uWKxuKGxCZQz3okCdpIvbLSx5Z0JaKsqSY1A+vYvqy+HLg v6aVxQuxgPilg== From: Vincent Mailhol Date: Fri, 19 Dec 2025 23:39:45 +0100 Subject: [PATCH v2 1/4] kbuild: remove gcc's -Wtype-limits Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251219-remove_wtype-limits-v2-1-2e92b3f566c5@kernel.org> References: <20251219-remove_wtype-limits-v2-0-2e92b3f566c5@kernel.org> In-Reply-To: <20251219-remove_wtype-limits-v2-0-2e92b3f566c5@kernel.org> To: Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chris Mason , David Sterba , Kees Cook , "Gustavo A. R. Silva" Cc: Linus Torvalds , linux-kbuild@vger.kernel.org, linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-btrfs@vger.kernel.org, linux-hardening@vger.kernel.org, Vincent Mailhol X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3600; i=mailhol@kernel.org; h=from:subject:message-id; bh=ap8MRB6u43PIFW27qfddd/82fqc/71rc4wGTDPI7wLo=; b=owGbwMvMwCV2McXO4Xp97WbG02pJDJmuV+xvHvP/qS1XYXPiX433Jz/HroLZBpEzj7qU7tTr5 /9v8fhsx0QWBjEuBksxRZZl5ZzcCh2F3mGH/lrCzGFlAhkiLdLAAAQsDHy5iXmlRjpGeqbahnqG hjpAJgMXpwBMtYYvwz+91DtK75VbhTPMdj+PszxxP9BuupS3eOuxc/8aIqavm7mMkWEBt+wHj/D 9nSprFGdeeSnEpTtxeUrTrRg+f8M3r04nfeEDAA== X-Developer-Key: i=mailhol@kernel.org; a=openpgp; fpr=ED8F700574E67F20E574E8E2AB5FEB886DBB99C2 W=3D2 builds are heavily polluted by the -Wtype-limits warning. Here are some W=3D12 statistics on Linux v6.19-rc1 for an x86_64 defconfig (with just CONFIG_WERROR set to "n") using gcc 14.3.1: Warning name count percent ------------------------------------------------- -Wlogical-op 2 0.00 % -Wmaybe-uninitialized 138 0.20 % -Wunused-macros 869 1.24 % -Wmissing-field-initializers 1418 2.02 % -Wshadow 2234 3.19 % -Wtype-limits 65378 93.35 % ------------------------------------------------- Total 70039 100.00 % As we can see, -Wtype-limits represents the vast majority of all warnings. The reason behind this is that these warnings appear in some common header files, meaning that some unique warnings are repeated tens of thousands of times (once per header inclusion). Add to this the fact that each warning is coupled with a dozen lines detailing some macro expansion. The end result is that the W=3D2 output is just too bloated and painful to use. Three years ago, I proposed in [1] modifying one such header to silence that noise. Because the code was not faulty, Linus rejected the idea and instead suggested simply removing that warning. At that time, I could not bring myself to send such a patch because, despite its problems, -Wtype-limits would still catch the below bug: unsigned int ret; ret =3D check(); if (ret < 0) error(); Meanwhile, based on another suggestion from Linus, I added a new check to sparse [2] that would catch the above bug without the useless spam. With this, remove gcc's -Wtype-limits. People who still want to catch incorrect comparisons between unsigned integers and zero can now use sparse instead. On a side note, clang also has a -Wtype-limits warning but: * it is not enabled in the kernel at the moment because, contrary to gcc, clang did not include it under -Wextra. * it does not warn if the code results from a macro expansion. So, if activated, it would not cause as much spam as gcc does. * -Wtype-limits is split into four sub-warnings [3] meaning that if it were to be activated, we could select which one to keep. So there is no present need to explicitly disable -Wtype-limits in clang. [1] linux/bits.h: GENMASK_INPUT_CHECK: reduce W=3D2 noise by 31% treewide Link: https://lore.kernel.org/all/20220308141201.2343757-1-mailhol.vincent@= wanadoo.fr/ [2] Warn about "unsigned value that used to be signed against zero" Link: https://lore.kernel.org/all/20250921061337.3047616-1-mailhol@kernel.o= rg/ [3] clang's -Wtype-limits Link: https://clang.llvm.org/docs/DiagnosticsReference.html#wtype-limits Reviewed-by: Nicolas Schier Signed-off-by: Vincent Mailhol --- scripts/Makefile.warn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn index 68e6fafcb80c..c593ab1257de 100644 --- a/scripts/Makefile.warn +++ b/scripts/Makefile.warn @@ -55,6 +55,9 @@ else KBUILD_CFLAGS +=3D -Wno-main endif =20 +# Too noisy on range checks and in macros handling both signed and unsigne= d. +KBUILD_CFLAGS +=3D -Wno-type-limits + # These result in bogus false positives KBUILD_CFLAGS +=3D $(call cc-option, -Wno-dangling-pointer) =20 @@ -174,7 +177,6 @@ else =20 # The following turn off the warnings enabled by -Wextra KBUILD_CFLAGS +=3D -Wno-missing-field-initializers -KBUILD_CFLAGS +=3D -Wno-type-limits KBUILD_CFLAGS +=3D -Wno-shift-negative-value =20 ifdef CONFIG_CC_IS_CLANG --=20 2.51.2 From nobody Sat Feb 7 19:41:31 2026 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 4D6B428DB76; Fri, 19 Dec 2025 22:40:31 +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=1766184031; cv=none; b=DgLqjYs27z215YlDKEzB7Uh/op8PUxtzjTEuVKQxA/zDFmuLs0bGmvOCHPoEj6dll1Ssf5qdYTVeXs6wBhqY3Wn/dP0wyCzZTg2LEBGlI/FvG7r0IOBz/Q0g6CohTg23KJgML3ylZfueum1cKuWD4Z6tujZtHCZbeEqtbRdkAMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766184031; c=relaxed/simple; bh=CH51omHx3p6qsRzlcGdmz4sS4fZYMW+MUawnsQlkKh8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=edXD21bIkK8cd8YqIRjrohT9UoMJanSdhb2ZrW4UKWT9txDYggvOs2WiM+tFop5fh1oxHFD3iBlXnQ9QlJ2Cm5mSFEs2yNpcC44fB092GfoDxVCJTN395pmUZXgMx4rd8VfszO6Q4jA0uEVSGFy2Md4NT28MYzISafrAypMY458= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UYyUrRMm; 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="UYyUrRMm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D4C0C4CEF1; Fri, 19 Dec 2025 22:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766184031; bh=CH51omHx3p6qsRzlcGdmz4sS4fZYMW+MUawnsQlkKh8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UYyUrRMmjNfCsp7IYNkf2GE3GqsLbe/e6MI4dGs0mkTAGMNlroOfNKjchxfRho3eN U0Z6I5DBdmyOcwXb6dHzgLkGBfLnjZlX1d4HSxAQmdoQWNJIEjj++enKKTvImVPJ7O 88EvzRC+HEgvdw4uMY7cg145wzDADRZ/KVU3T8Z4RMtunlavbu431/fY/vLLgJpfa2 tWVwfxcTyTHbIzoXQxPqhGW/XEZu0NPqbLGXwIn6c8E/hrhGU0kZRPUbkPkNYPBhDv hPK/5kMT6R8yf+usvTRELgXJGyor+GfBx3ZR1dwy12RaGV54UK87jzghOaezPAx/M2 zvno1rWPPLYKw== From: Vincent Mailhol Date: Fri, 19 Dec 2025 23:39:46 +0100 Subject: [PATCH v2 2/4] kbuild: cleanup local -Wno-type-limits exceptions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251219-remove_wtype-limits-v2-2-2e92b3f566c5@kernel.org> References: <20251219-remove_wtype-limits-v2-0-2e92b3f566c5@kernel.org> In-Reply-To: <20251219-remove_wtype-limits-v2-0-2e92b3f566c5@kernel.org> To: Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chris Mason , David Sterba , Kees Cook , "Gustavo A. R. Silva" Cc: Linus Torvalds , linux-kbuild@vger.kernel.org, linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-btrfs@vger.kernel.org, linux-hardening@vger.kernel.org, Vincent Mailhol X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1412; i=mailhol@kernel.org; h=from:subject:message-id; bh=CH51omHx3p6qsRzlcGdmz4sS4fZYMW+MUawnsQlkKh8=; b=kA0DAAoW0WQ+QNd/fbMByyZiAGlF1EOjMOByv0n126NSjwuXg8j/IxssPc9TKnxzsAAq/pe6F 4iRBAAWCgA5FiEEpncJCyCIcUtWwv050WQ+QNd/fbMFAmlF1EMbFIAAAAAABAAObWFudTIsMi41 KzEuMTEsMiwyAAoJENFkPkDXf32zwuQBALphDSFKpPBiTOKEVIuE94/+YEsRmjpYZiMQ7lDD4SW QAP9FGUN45c8n3tmPLKYM4wGNk16iKXQ0rB7Uoj4K7KqLCQ== X-Developer-Key: i=mailhol@kernel.org; a=openpgp; fpr=ED8F700574E67F20E574E8E2AB5FEB886DBB99C2 Now that -Wtype-limits is globally deactivated, there is no need for local exceptions anymore. Acked-by: David Sterba Signed-off-by: Vincent Mailhol --- Changelog: v1 -> v2: small change in patch description --- drivers/gpu/drm/Makefile | 1 - fs/btrfs/Makefile | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 0e1c668b46d2..b879a60ca79a 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -22,7 +22,6 @@ subdir-ccflags-y +=3D $(call cc-option, -Wstringop-trunca= tion) # The following turn off the warnings enabled by -Wextra ifeq ($(findstring 2, $(KBUILD_EXTRA_WARN)),) subdir-ccflags-y +=3D -Wno-missing-field-initializers -subdir-ccflags-y +=3D -Wno-type-limits subdir-ccflags-y +=3D -Wno-shift-negative-value endif ifeq ($(findstring 3, $(KBUILD_EXTRA_WARN)),) diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile index 743d7677b175..40bc2f7e6f6b 100644 --- a/fs/btrfs/Makefile +++ b/fs/btrfs/Makefile @@ -17,7 +17,6 @@ subdir-ccflags-y +=3D $(condflags) # The following turn off the warnings enabled by -Wextra subdir-ccflags-y +=3D -Wno-missing-field-initializers subdir-ccflags-y +=3D -Wno-sign-compare -subdir-ccflags-y +=3D -Wno-type-limits subdir-ccflags-y +=3D -Wno-shift-negative-value =20 obj-$(CONFIG_BTRFS_FS) :=3D btrfs.o --=20 2.51.2 From nobody Sat Feb 7 19:41:31 2026 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 11B0129BD9A; Fri, 19 Dec 2025 22:40:37 +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=1766184038; cv=none; b=aZgSHek5Jo07PG01Sxn6w2NOapxRwXCk4EupoKSoFfch3d9eQdd6VvPTScNecZ8cT9HOewtJ290aH53f59Zd47CgF32WvsvFRJNvyKtqHvIyQGkAozvtHyWkrBRh/hkZ7wDO79FQQ65hag1ikRDOUuQ59N6t6ihAMUmxvB6s0ho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766184038; c=relaxed/simple; bh=wtRlhF0E9lAMAS6RF9a/BuSBeDduKYxm9+amQIF8Ki8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ss7dakQCzhhaDfVRT3Vbh0qNBir41WZq+AeMMaXGAdEI2Df4csObz1+QYFKBtLyAGe+9w8U2/RK+hHIhtuFCjAWZMe66zI7rQC2AmLR5tuhmEfn0JIdAKLP/z9u4IzAHOU70kUnYVY6kS9oTMSN4SJnMMB783ir9tVS4wIlf++w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UNUQIvXG; 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="UNUQIvXG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADBBDC4CEF1; Fri, 19 Dec 2025 22:40:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766184037; bh=wtRlhF0E9lAMAS6RF9a/BuSBeDduKYxm9+amQIF8Ki8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UNUQIvXG+Z9FaVnBja8B5O12NGutk88wN3q4qUUXtsrEUtmP6zi3hGvyuDDs8eRl2 97pimjmV1nv0W5Oq8CmJm8+QY/K47hZiVYq/BNN3POgNAtq7BjAnFrfNI68sajKKB5 s373akfhE5SIDMv/bn8qQJ2bgyNG5LSRWnpsoNGQqjNmL9QB8iztmEf5AKRGksPX8A /etmXT/1TIGGB0xEErTTk4J6AlXlr1JyTismvhOfTqIz/+vkt96ZiA/H2cu8uimfxa 0vJ9YG3Jq6PRxLHIobJEQQOuQED/ejXO+w8yUFEOxvdDJQ1bwSmP/F3EWXD376Rsym z0yiB64BHBl7w== From: Vincent Mailhol Date: Fri, 19 Dec 2025 23:39:47 +0100 Subject: [PATCH v2 3/4] overflow: Remove is_non_negative() and is_negative() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251219-remove_wtype-limits-v2-3-2e92b3f566c5@kernel.org> References: <20251219-remove_wtype-limits-v2-0-2e92b3f566c5@kernel.org> In-Reply-To: <20251219-remove_wtype-limits-v2-0-2e92b3f566c5@kernel.org> To: Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chris Mason , David Sterba , Kees Cook , "Gustavo A. R. Silva" Cc: Linus Torvalds , linux-kbuild@vger.kernel.org, linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-btrfs@vger.kernel.org, linux-hardening@vger.kernel.org, Vincent Mailhol X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1738; i=mailhol@kernel.org; h=from:subject:message-id; bh=wtRlhF0E9lAMAS6RF9a/BuSBeDduKYxm9+amQIF8Ki8=; b=owGbwMvMwCV2McXO4Xp97WbG02pJDJmuV9zsThw4ZfrOIPRQ++ItJrNPBldduf+xu7xAq26LV 8H6w7ebOyayMIhxMViKKbIsK+fkVugo9A479NcSZg4rE8gQaZEGBiBgYeDLTcwrNdIx0jPVNtQz NNQBMhm4OAVgqo+WMfwVl/scJuBe5eW1+2r48j0sV+Mle7Z4LFaRKLoUMUv+k8p+RobdQlsNlJ8 w6fUYRecZ/Qj9LsjFZ//g8Nak6rrsKXMO3+ACAA== X-Developer-Key: i=mailhol@kernel.org; a=openpgp; fpr=ED8F700574E67F20E574E8E2AB5FEB886DBB99C2 The is_non_negative() and is_negative() function-like macros just exist as a workaround to silence the -Wtype-limits warning. Now that this warning is disabled, those two macros have lost their raison d'=C3=AAtre. Remove them. This reverts commit dc7fe518b049 ("overflow: Fix -Wtype-limits compilation warnings"). Suggested-by: Nicolas Schier Link: https://lore.kernel.org/all/aUT_yWin_xslnOFh@derry.ads.avm.de Signed-off-by: Vincent Mailhol --- Changelog: v1 -> v2: new patch --- include/linux/overflow.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/include/linux/overflow.h b/include/linux/overflow.h index 736f633b2d5f..ab142d60c6b5 100644 --- a/include/linux/overflow.h +++ b/include/linux/overflow.h @@ -36,12 +36,6 @@ #define __type_min(T) ((T)((T)-type_max(T)-(T)1)) #define type_min(t) __type_min(typeof(t)) =20 -/* - * Avoids triggering -Wtype-limits compilation warning, - * while using unsigned data types to check a < 0. - */ -#define is_non_negative(a) ((a) > 0 || (a) =3D=3D 0) -#define is_negative(a) (!(is_non_negative(a))) =20 /* * Allows for effectively applying __must_check to a macro so we can have @@ -201,9 +195,9 @@ static inline bool __must_check __must_check_overflow(b= ool overflow) typeof(d) _d =3D d; \ unsigned long long _a_full =3D _a; \ unsigned int _to_shift =3D \ - is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0; \ + _s >=3D 0 && _s < 8 * sizeof(*d) ? _s : 0; \ *_d =3D (_a_full << _to_shift); \ - (_to_shift !=3D _s || is_negative(*_d) || is_negative(_a) || \ + (_to_shift !=3D _s || *_d < 0 || _a < 0 || \ (*_d >> _to_shift) !=3D _a); \ })) =20 --=20 2.51.2 From nobody Sat Feb 7 19:41:31 2026 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 98D3218FDAF; Fri, 19 Dec 2025 22:40:44 +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=1766184044; cv=none; b=qmD04eOssYUBEoR5sXU00u33ErBkL+l8ikJF/RrIAiaZv+c7V8VIdV+z/m0KVtmn3HKM/X4iWV69hL3NG3RQcSdksh8PTY4sVYJ7ImTB+wsKnP/Q1heN1u1IMgY2lDwdHm9Zgv8KPPPY2N76kLobbdJD50b8ib0M3bjS6hQVDfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766184044; c=relaxed/simple; bh=uAEpBNv+CmgIxmDyHDHgY/r2XzHv2JsQOvxnxQ6j1fI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h19Ce6YpYUb50H+Edc4WwLWJdYO28QbSCiiS7bsVk9EQ6bw+0YfzcAwef6+v6ahDyKCXqicVB2zIahN4gBLoybmgktdtnL47oBGq7Qt/sOyTA3K810MwOVGvd88b2QBnBsskMSz/+dvm9TPRNJK+wh90futFhOYuXYphtfdwI0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qi2gCD/z; 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="Qi2gCD/z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18457C113D0; Fri, 19 Dec 2025 22:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766184044; bh=uAEpBNv+CmgIxmDyHDHgY/r2XzHv2JsQOvxnxQ6j1fI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Qi2gCD/zXBNO6PpRplvsyMGPz4YlZ4NQsZq6oJc4WREI1MKf9btW+c0LqUWho8zCy fMUJ9C7ItN8pdGW9Gg8DiDfbpfqgCcS0ceHQLNXiPQ1xDlDri08JV54M9xr8hrLRgk xbKpWZrLZMJaAP7JqFYbI0RPXwx7nswt3hlY7Sp99Ul9uCbLKS6kyqRnA0Mhpep8mN qgMibLS2l3Fk/tPA5vPv08KDPTLUA9HhCHBEIuCvJN1dU9uux0k8V0nSUmjz4OaiEC MubUbbeHUPFKXNiwdNWROxW4MWuMXgCraVGscMz47UftT+HOFKoj4U3Sz2V/nftcZL ibYGLe4brERxg== From: Vincent Mailhol Date: Fri, 19 Dec 2025 23:39:48 +0100 Subject: [PATCH v2 4/4] minmax: remove useless cast in __is_nonneg() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251219-remove_wtype-limits-v2-4-2e92b3f566c5@kernel.org> References: <20251219-remove_wtype-limits-v2-0-2e92b3f566c5@kernel.org> In-Reply-To: <20251219-remove_wtype-limits-v2-0-2e92b3f566c5@kernel.org> To: Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chris Mason , David Sterba , Kees Cook , "Gustavo A. R. Silva" Cc: Linus Torvalds , linux-kbuild@vger.kernel.org, linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-btrfs@vger.kernel.org, linux-hardening@vger.kernel.org, Vincent Mailhol X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3094; i=mailhol@kernel.org; h=from:subject:message-id; bh=uAEpBNv+CmgIxmDyHDHgY/r2XzHv2JsQOvxnxQ6j1fI=; b=owGbwMvMwCV2McXO4Xp97WbG02pJDJmuVzxNZFtvnF3k4jDx27zFjimNTiyq3zXCrI4nRH1+V dqSvLm1YyILgxgXg6WYIsuyck5uhY5C77BDfy1h5rAygQyRFmlgAAIWBr7cxLxSIx0jPVNtQz1D Qx0gk4GLUwCm+qE0w1/pFp3T5387dN47sNlnk0aYYfO5KfZrjk1svKgoPkVqdfY1RoatvjXXS3i WnCzmPbUxuFEsZoJjz2mdlXX9B/btOBj4dRYnAA== X-Developer-Key: i=mailhol@kernel.org; a=openpgp; fpr=ED8F700574E67F20E574E8E2AB5FEB886DBB99C2 The function like macro __is_nonneg() casts its argument to (long long) in an attempt to silence -Wtype-limits warnings on unsigned values. But this workaround is incomplete as proven here: $ cat foo.c #include int foo(unsigned int a) { return __is_nonneg(a); } $ make CFLAGS_KERNEL=3D"-Wtype-limits" foo.o CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers CC foo.o foo.c: In function 'foo': ./include/linux/minmax.h:68:57: warning: comparison is always true due to= limited range of data type [-Wtype-limits] 68 | #define __is_nonneg(ux) statically_true((long long)(ux) >=3D 0) | ^~ ./include/linux/compiler.h:350:50: note: in definition of macro 'statical= ly_true' 350 | #define statically_true(x) (__builtin_constant_p(x) && (x)) | ^ foo.c:5:16: note: in expansion of macro '__is_nonneg' 5 | return __is_nonneg(a); | ^~~~~~~~~~~ ./include/linux/minmax.h:68:57: warning: comparison is always true due to= limited range of data type [-Wtype-limits] 68 | #define __is_nonneg(ux) statically_true((long long)(ux) >=3D 0) | ^~ ./include/linux/compiler.h:350:57: note: in definition of macro 'statical= ly_true' 350 | #define statically_true(x) (__builtin_constant_p(x) && (x)) | ^ foo.c:5:16: note: in expansion of macro '__is_nonneg' 5 | return __is_nonneg(a); | ^~~~~~~~~~~ And because -Wtype-limits is now globally disabled, such a workaround now becomes useless. Remove the __is_nonneg()'s cast and its related comment. Signed-off-by: Vincent Mailhol --- Changelog: v1 -> v2: new patch --- include/linux/minmax.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index a0158db54a04..3e2e3e539ba1 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -52,9 +52,6 @@ /* * Check whether a signed value is always non-negative. * - * A cast is needed to avoid any warnings from values that aren't signed - * integer types (in which case the result doesn't matter). - * * On 64-bit any integer or pointer type can safely be cast to 'long long'. * But on 32-bit we need to avoid warnings about casting pointers to integ= ers * of different sizes without truncating 64-bit values so 'long' or 'long = long' @@ -65,7 +62,7 @@ * but they are handled by the !is_signed_type() case). */ #if __SIZEOF_POINTER__ =3D=3D __SIZEOF_LONG_LONG__ -#define __is_nonneg(ux) statically_true((long long)(ux) >=3D 0) +#define __is_nonneg(ux) statically_true((ux) >=3D 0) #else #define __is_nonneg(ux) statically_true( \ (typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L)))(ux) >=3D 0) --=20 2.51.2