Message ID | 8732ef5f809c47c28a7be47c938b28d4@AcuMS.aculab.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2508014vqi; Mon, 18 Sep 2023 01:33:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk/DXkRXgP7RgN7Jk9mGVOHSM/6KBy3+7AWTho+bdyfEJENIjaPTfliKWBjkxFWo0nG/uM X-Received: by 2002:a54:4390:0:b0:3a7:9e5d:4c with SMTP id u16-20020a544390000000b003a79e5d004cmr8957936oiv.37.1695026039515; Mon, 18 Sep 2023 01:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695026039; cv=none; d=google.com; s=arc-20160816; b=usLq216F0oFfQm5jRkf0rx/UOqHxHD97d25lks8ZuDiPBWdNPFJs5GVUA7l0QqUelO CT1MpnB+5ZObL2AdngWlBKIpToHlAq6Q57zueX8PX4BIs4qbp2bd0p2yX7imTOMgX6Tz QVvy4DTqyk02HGb5AAmjwiy4D309017cL9jgBO71Md6ddjmgVPkVqRWvnjbkcl8ska/E Cmv/a672fDec2S1DfjTAkMVDiyDWS6gqsfQZqLcAcFQQWdOCAnC2DCib2r5JNbBHJmXw uvx6i2WQcQaWWz6Wp5AIacg+BUSLur7ussstGbJQQcpXz9QnXTdms0eRV39oRc+PI+uq 136g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=ujzGNZc5qrLo3HrbR8Ll3D8Wt5MoD2OQRU/eJEXwEzs=; fh=O7+mvh5MpI0TRpoWjlJXbuqRWYgEFgj8fdoOuxSUxxo=; b=ihCgCDnYrfFw8nBIhSr6mooJ2YOTOSR95NU4bzk/HaTFoR4Rp1Xxa0/nCLw4vibPEJ 2FzM+yqJruJAXp2fn7JUVZu8IvSvNBD9lbWWBSS07Ll7RrwhbLAP9a7qOstsQr31g4kH CrZSo5yxSI4OF9MJwe2iDk8Fpqh+364afW8OtXWGjn03VIzVptfj6aGSPyLzC9YQus1O CAlIUTSmeW0Vw7nZS2DTZuEwxD1+Vumv/oVoE6u7ug1b43SYSgdEFXNdUcMnuHwNX2lD bqiKVdpsdZNcOZAWGHONPlGffx10QlUI3+jOF+9Yalk5VksId90RTEatWtsuHDGdqoyU DGZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i136-20020a636d8e000000b0055bc23bdde5si4730991pgc.176.2023.09.18.01.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 01:33:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 8281E822F8F0; Mon, 18 Sep 2023 01:23:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240626AbjIRIWg convert rfc822-to-8bit (ORCPT <rfc822;kernel.ruili@gmail.com> + 27 others); Mon, 18 Sep 2023 04:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241246AbjIRIVm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 18 Sep 2023 04:21:42 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA5551BEB for <linux-kernel@vger.kernel.org>; Mon, 18 Sep 2023 01:19:04 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-272-E9YBwqP4P06q7i8DA9kLLg-1; Mon, 18 Sep 2023 09:18:52 +0100 X-MC-Unique: E9YBwqP4P06q7i8DA9kLLg-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 18 Sep 2023 09:18:40 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Mon, 18 Sep 2023 09:18:40 +0100 From: David Laight <David.Laight@ACULAB.COM> To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> CC: Linus Torvalds <torvalds@linux-foundation.org>, 'Andy Shevchenko' <andriy.shevchenko@linux.intel.com>, 'Andrew Morton' <akpm@linux-foundation.org>, "'Matthew Wilcox (Oracle)'" <willy@infradead.org>, 'Christoph Hellwig' <hch@infradead.org>, "'Jason A. Donenfeld'" <Jason@zx2c4.com> Subject: [PATCH next v4 4/5] minmax: Allow comparisons of 'int' against 'unsigned char/short'. Thread-Topic: [PATCH next v4 4/5] minmax: Allow comparisons of 'int' against 'unsigned char/short'. Thread-Index: AdnqCL56uRkZZqjMT8+4JbTB+DfbRQ== Date: Mon, 18 Sep 2023 08:18:40 +0000 Message-ID: <8732ef5f809c47c28a7be47c938b28d4@AcuMS.aculab.com> References: <b97faef60ad24922b530241c5d7c933c@AcuMS.aculab.com> In-Reply-To: <b97faef60ad24922b530241c5d7c933c@AcuMS.aculab.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:23:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777363624416540308 X-GMAIL-MSGID: 1777363624416540308 |
Series |
minmax: Relax type checks in min() and max().
|
|
Commit Message
David Laight
Sept. 18, 2023, 8:18 a.m. UTC
Since 'unsigned char/short' get promoted to 'signed int' it is
safe to compare them against an 'int' value.
Signed-off-by: David Laight <david.laight@aculab.com>
---
v4: No change
v3: No change
v2: No change
include/linux/minmax.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 1b6e7268af75..b636c3c50248 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -25,8 +25,9 @@ __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \ is_signed_type(typeof(x)), 0) -#define __types_ok(x, y) \ - (__is_signed(x) == __is_signed(y)) +#define __types_ok(x, y) \ + (__is_signed(x) == __is_signed(y) || \ + __is_signed((x) + 0) == __is_signed((y) + 0)) #define __cmp_op_min < #define __cmp_op_max >