From nobody Sat Feb 7 15:26:33 2026 Received: from pdx-out-010.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-010.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.12.53.23]) (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 D61062D5C61; Fri, 17 Oct 2025 09:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.12.53.23 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760692439; cv=none; b=IlotQHUxK8JFOw7wo2R9RioC8VuM4MBkv3dNpwy9S8sVw0Q/9Bg6K9Gx5zXnNUQzMaTrko02/nVuWZNjgWSPR95a3j0dQLovm9sxaOqCWrqQD2JeE6WO1dvdMi1J+msFZUysZ99gQPD58UnDz1R9J8C/M2aWRiMVGJpnQeYBVb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760692439; c=relaxed/simple; bh=V2L3IilwofpV6SrsfVTvut5ipDXkokIOm+dTBT4i7eQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lTPQYymuzYxTI6aUIqLNn3C7DWqhHhv+yoldiyMM8P6cN7tmPggW6jZVoXmAIV1J9/uZDuHAr65iaGbD8JAt1xdyydf0nXZXfTmH1Z0+S+fk248PIj0/ZQ6UmHO6vxBXeXE/rKf+VXLdxhBCsJuBgCSWTf0Y0va0V5X6NmK9YKQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=bJS3ICkf; arc=none smtp.client-ip=52.12.53.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="bJS3ICkf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1760692437; x=1792228437; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k0dUe76w+6n5/NfsPbyefGVCom+xh3GGcFcV3Olhmks=; b=bJS3ICkfgFedWl5t3te0XuFgDXWz8nBqHQTRTXEmWIJKuL6qSBM8S6lo qWlp8IVFhGYjuCljEi8GOfcSbqH+tmKEEZvbtP9V9wWtn/s5gI8gv7//Y zdnpZRxAiJ8nFsb7eC7GNe9Gm8l5PF74pM1VygYGU+pIPA6e11ygckgM+ gEApLlTUZ6QclTdRegSo2bp6laPl8PmAE7Cl5kNabPBce5Sboj/z22O+k J+7XV0D5JnsdfIKqakhgqjO4qtfEpn5U89qoIbQeK6i3YQvX0obdlg2UM pKCy7KqUeL7mvB26xraicOcxVnM+0ZFcv0+KspA0RfR1N8nH756RouAHI w==; X-CSE-ConnectionGUID: RXTPyYArTMCGpEZ+E8Xbcw== X-CSE-MsgGUID: BWj3QBi9SQOiPxp1KjHzOA== X-IronPort-AV: E=Sophos;i="6.19,236,1754956800"; d="scan'208";a="4952411" Received: from ip-10-5-0-115.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.0.115]) by internal-pdx-out-010.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2025 09:13:57 +0000 Received: from EX19MTAUWA002.ant.amazon.com [205.251.233.234:21527] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.17.61:2525] with esmtp (Farcaster) id 6e4c0a13-2687-46e7-b791-5c0ff5190e98; Fri, 17 Oct 2025 09:13:57 +0000 (UTC) X-Farcaster-Flow-ID: 6e4c0a13-2687-46e7-b791-5c0ff5190e98 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA002.ant.amazon.com (10.250.64.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.20; Fri, 17 Oct 2025 09:13:56 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.20; Fri, 17 Oct 2025 09:13:41 +0000 From: Eliav Farber To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Arnd Bergmann , Christoph Hellwig , Dan Carpenter , Jens Axboe , Lorenzo Stoakes , Mateusz Guzik , Pedro Falcato Subject: [PATCH v2 27/27 5.10.y] minmax.h: remove some #defines that are only expanded once Date: Fri, 17 Oct 2025 09:05:19 +0000 Message-ID: <20251017090519.46992-28-farbere@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251017090519.46992-1-farbere@amazon.com> References: <20251017090519.46992-1-farbere@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: EX19D040UWA001.ant.amazon.com (10.13.139.22) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="utf-8" 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.acul= ab.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))) =20 /* * 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 integ= ers * 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__ =3D=3D __SIZEOF_LONG_LONG__ +#define __is_nonneg(ux) statically_true((long long)(ux) >=3D 0) #else - #define __signed_type(ux) typeof(__builtin_choose_expr(sizeof(ux) > 4, 1= LL, 1L)) +#define __is_nonneg(ux) statically_true( \ + (typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L)))(ux) >=3D 0) #endif -#define __is_nonneg(ux) statically_true((__signed_type(ux))(ux) >=3D 0) =20 #define __types_ok(ux, uy) \ (__sign_use(ux) & __sign_use(uy)) --=20 2.47.3