From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D053CAC5B0 for ; Thu, 2 Oct 2025 20:57:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C89A38E0020; Thu, 2 Oct 2025 16:57:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C39F38E001A; Thu, 2 Oct 2025 16:57:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B023E8E0020; Thu, 2 Oct 2025 16:57:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9A5D98E001A for ; Thu, 2 Oct 2025 16:57:33 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5A311140683 for ; Thu, 2 Oct 2025 20:57:33 +0000 (UTC) X-FDA: 83954385186.09.780109B Received: from fra-out-001.esa.eu-central-1.outbound.mail-perimeter.amazon.com (fra-out-001.esa.eu-central-1.outbound.mail-perimeter.amazon.com [18.156.205.64]) by imf29.hostedemail.com (Postfix) with ESMTP id 143F5120008 for ; Thu, 2 Oct 2025 20:57:30 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazoncorp2 header.b=lkEowbjO; spf=pass (imf29.hostedemail.com: domain of "prvs=363ba725c=farbere@amazon.com" designates 18.156.205.64 as permitted sender) smtp.mailfrom="prvs=363ba725c=farbere@amazon.com"; dmarc=pass (policy=quarantine) header.from=amazon.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1759438651; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=k0dUe76w+6n5/NfsPbyefGVCom+xh3GGcFcV3Olhmks=; b=BE2/0H+LlkFkkrMPJFyP+4xcr8tbatQQai06Ftvw/aovGgeK3ucvoMQUEj7dBoe1sO+FKh gPfkImiLtBBBIbijoVyyex1M64zDl/8W04F79XTzofes4o3LWP18oMcUaQXNPcZYuZ9i5Y ZGRUpim2oNQoMVlNTYrTehUCgCibvpA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazoncorp2 header.b=lkEowbjO; spf=pass (imf29.hostedemail.com: domain of "prvs=363ba725c=farbere@amazon.com" designates 18.156.205.64 as permitted sender) smtp.mailfrom="prvs=363ba725c=farbere@amazon.com"; dmarc=pass (policy=quarantine) header.from=amazon.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1759438651; a=rsa-sha256; cv=none; b=hGemb1DDCd4Sbae8IMVstrqn6w6nx4S45xl7V2kguh+MarXIsVAA7maPJ0cZIjHEuyv7CU U1l8cKQlQQNIIHVkjJ/CMwc8Hr5DczQjmwiLNU/OS/QFGjgD7qT7FscocPgHyABbmeaFXq oLvKKehJbNpKcQZHj0KPDnFxkmFfof0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1759438651; x=1790974651; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k0dUe76w+6n5/NfsPbyefGVCom+xh3GGcFcV3Olhmks=; b=lkEowbjO55R/dUguNGFdx043yjkXbdk+3vICDeg3cpjghADnYsDqNVT8 n4pVfBuB7iY8Pld0HsVADlpkKu7+WRkDm74FlyPUOcZRiISAPKV/b26gE hzf1ydUxhqdDz0VLzaO3+oWx3O9/9ksYfwYp3xQhzDEbnhrPw5rEuPjlV 1PKLUXHI4C9qxX7LKqju7Q0A1RUCSZHVJ+MkG39TBIAC+ejkHxrzgu8Ra cP9OdJtB14hszZme5lCRN8xOVmL84dIzqWZXvNhuukjCZeQlPRIMyv42e zy6zaNSCz5pHJ/RxLvkb0HH0fH1i/X4GyzbZq32LhXeVLA56o6fUrbQTR w==; X-CSE-ConnectionGUID: h2zY6dTES+aammnS0EEI3A== X-CSE-MsgGUID: CdnqQ7CqRKKQw4L94J2blQ== X-IronPort-AV: E=Sophos;i="6.18,310,1751241600"; d="scan'208";a="3031119" Received: from ip-10-6-3-216.eu-central-1.compute.internal (HELO smtpout.naws.eu-central-1.prod.farcaster.email.amazon.dev) ([10.6.3.216]) by internal-fra-out-001.esa.eu-central-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2025 20:57:29 +0000 Received: from EX19MTAEUC001.ant.amazon.com [54.240.197.225:18635] by smtpin.naws.eu-central-1.prod.farcaster.email.amazon.dev [10.0.40.83:2525] with esmtp (Farcaster) id d3578000-1116-45a7-ba47-5a8e3d4b0a91; Thu, 2 Oct 2025 20:57:29 +0000 (UTC) X-Farcaster-Flow-ID: d3578000-1116-45a7-ba47-5a8e3d4b0a91 Received: from EX19D018EUA004.ant.amazon.com (10.252.50.85) by EX19MTAEUC001.ant.amazon.com (10.252.51.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.20; Thu, 2 Oct 2025 20:57:19 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by EX19D018EUA004.ant.amazon.com (10.252.50.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.20; Thu, 2 Oct 2025 20:56:52 +0000 From: Eliav Farber To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Arnd Bergmann , Christoph Hellwig , Dan Carpenter , "Jason A. Donenfeld" , Jens Axboe , Lorenzo Stoakes , Mateusz Guzik , "Pedro Falcato" Subject: [PATCH 19/19 5.15.y] minmax.h: remove some #defines that are only expanded once Date: Thu, 2 Oct 2025 20:47:33 +0000 Message-ID: <20251002204733.35652-20-farbere@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251002204733.35652-1-farbere@amazon.com> References: <20251002204733.35652-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.19.116.181] X-ClientProxiedBy: EX19D042UWA002.ant.amazon.com (10.13.139.17) To EX19D018EUA004.ant.amazon.com (10.252.50.85) X-Rspamd-Queue-Id: 143F5120008 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 5udxnhnb7njpsn9wr78dpmgzjt1nu8cn X-HE-Tag: 1759438650-905580 X-HE-Meta: U2FsdGVkX1+HxiSofbqp8RDpbqlJf3Bi1O5yA1SuYqY4ojKU1r0nvqlkyiGjLaHWS7Tf+ZMLt1GxI82vKSwUmPpfLidDNyJ/+NwnbxhBlhhein/YpH3baNQN6tM/YZonUYYiiDpHMd+XTG8iaQBL4ENdngnHwKiZS85S523Q55nORs1mTuDd/W5FXTLd1EjTummtB2XnHzCRK/dAJjfiAAMcfZh2uvysnmG4AmkzkbORagG27u1HB99OY+n5BSpBsVxL0XunniNYHxvLofpb7WZs4Wg/skkRbo5CkpZM8ibiMtWJqNbRBs4t0iYleh7ER+vsw2z8IAB0LoasteElLu0VsqpJKuTlSw+Mq0xVlch//REXw7PHDpccyISdwM40lmrNOQKzEeIrG1lAqXHUrL027mBNbLw3RCUXYTJvygK96YirOwunGIqeSwP9f+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XyG3P3tnoe7osvjhsA2c+iZbvEUWLG9HISwWJGs3+x5OGTWY+hHolh2R08hGYxw1BMfNyZt+dm5dXvbpGDwsw9IA9ol/GdV/BxUFV7I+LTuY1VK6URPjiKUvor2ZbEvlB+3pwKbu4rRT3krgcOBYbBr5ranRxU8JAhQebFIHx56BEheK+r4b5wB/vwhvZIrAtcQ57P9XG6gpzhwOru6ikQrrDgXL6hoeRis7vXToWSjyB48WTytSWfmRIQDyit7ArPlZaTSL+wYqw+P4A2+n6Gt4+AojohaFsJTRuEOabrbQIqNLoiiBYc1lXqwpKohIL/2B0GaDQw4ZZTsh0Boylo0uZRUzgCx+c3qv+8jjABOcXAslisNlDGrugeV7DVCTIrziU4n1QGcLzrj7gK3QWWGsA0lQKCtrWJ7NelsDBzN2b6JT2M/5J+8A2VwgcvNjDkDdKFRaz L3JYk7gq 9m/xnAnmbLpwqalAbqcVkTAGvkrEwkh042GZohyrlmQXGlW+8sBF5sSV9fRtTykALhQVerOmPBkb5t0QdrEFNrDQu4Ot7QKue8KaCuufNZCPErJ2wowIhjMROEu5jkqQ65y49asn1/Sq0gqc3WQaypwNeVpuzYXVsUXjziigOPx0JOwPaI6dqA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: David Laight [ Upstream commit 2b97aaf74ed534fb838d09867d09a3ca5d795208 ] The bodies of __signed_type_use() and __unsigned_type_use() are much the same size as their names - so put the bodies in the only line that expands them. Similarly __signed_type() is defined separately for 64bit and then used exactly once just below. Change the test for __signed_type from CONFIG_64BIT to one based on gcc defined macros so that the code is valid if it gets used outside of a kernel build. Link: https://lkml.kernel.org/r/9386d1ebb8974fbabbed2635160c3975@AcuMS.aculab.com Signed-off-by: David Laight Cc: Andy Shevchenko Cc: Arnd Bergmann Cc: Christoph Hellwig Cc: Dan Carpenter Cc: Jason A. Donenfeld Cc: Jens Axboe Cc: Lorenzo Stoakes Cc: Mateusz Guzik Cc: Matthew Wilcox Cc: Pedro Falcato Signed-off-by: Andrew Morton Signed-off-by: Eliav Farber --- include/linux/minmax.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 2bbdd5b5e07e..eaaf5c008e4d 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -46,10 +46,8 @@ * comparison, and these expressions only need to be careful to not cause * warnings for pointer use. */ -#define __signed_type_use(ux) (2 + __is_nonneg(ux)) -#define __unsigned_type_use(ux) (1 + 2 * (sizeof(ux) < 4)) #define __sign_use(ux) (is_signed_type(typeof(ux)) ? \ - __signed_type_use(ux) : __unsigned_type_use(ux)) + (2 + __is_nonneg(ux)) : (1 + 2 * (sizeof(ux) < 4))) /* * Check whether a signed value is always non-negative. @@ -57,7 +55,7 @@ * 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'. + * 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 integers * of different sizes without truncating 64-bit values so 'long' or 'long long' * must be used depending on the size of the value. @@ -66,12 +64,12 @@ * them, but we do not use s128 types in the kernel (we do use 'u128', * but they are handled by the !is_signed_type() case). */ -#ifdef CONFIG_64BIT - #define __signed_type(ux) long +#if __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__ +#define __is_nonneg(ux) statically_true((long long)(ux) >= 0) #else - #define __signed_type(ux) typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L)) +#define __is_nonneg(ux) statically_true( \ + (typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L)))(ux) >= 0) #endif -#define __is_nonneg(ux) statically_true((__signed_type(ux))(ux) >= 0) #define __types_ok(ux, uy) \ (__sign_use(ux) & __sign_use(uy)) -- 2.47.3