Message ID | 34492660a17e44c19a98c4f0f37f6320@AcuMS.aculab.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp530817vqg; Fri, 28 Jul 2023 09:00:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzHYdSXeZmMLIZ/j3/98DeiW8rA/noCRnYE1SfIXnjMIqikjlHUsxcho5WvmaojBMw+MSi X-Received: by 2002:a17:907:770f:b0:99b:d2a9:9a01 with SMTP id kw15-20020a170907770f00b0099bd2a99a01mr3284078ejc.0.1690560009922; Fri, 28 Jul 2023 09:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690560009; cv=none; d=google.com; s=arc-20160816; b=jIeD/vPMizsOS491BtYPYN2V3gqTqliDuytldxQrxZmGRhiYQSXxmMIIdYoFYP6BlB BXDyNTm0g4U9iyjLp2tZLq7J1W2jLZydhqAGG9mtmhtE+LJZhAV30Vt9G7/dYH7lbuV7 cxz+M6HHNffDiueHUo3DektdVt6g3gvJNcjxLJ0sHwM6XFgJ8zL+nZNkuS3pED/IigEh tCGySaZSrYgYl8Oagi/gQ9YuScnCLWmvhn4efysGnTjsV7k1nOO8no1PJXZnwS8VQ9+5 5FtBTeBIRZ62yYasm4sesGK0fF/XqLeYHWUj3o2FTvkzp3JgU8E7VzX2CgRFZCaAW+hU cN7w== 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:to:from; bh=iaaCzc6Q9i6O/CVRA6Hi/kM6L9NyFKotzDsqlMeuki8=; fh=lQu0FQMQB/KijsOLYPBSZ4oPXp6gJVSgtvs90PKCM00=; b=y1fhti8UV/AmeQXDfVnbuaILw5I9KJ3GLptUF6ppWTMiR+FQwKpsksemoeq2HNw2/a NrzaGLDHOyPbS78992V3qA4sZEVwRxPvBREg9gER/qjtZRPnJ/JibOBLf1z+xsYjLSrD fAwTI0gYX6t9SScgljndflN0/OaCsyuU4PRGpA+iaxEj7APjmgb1IGUtBlmx8dFlce1B GHWSpppsbjB7/9JqgrR3SmDnZI3BQ4IK+ExpaBou0A7OhJbtak9NQPJXrvEPGhm6080d o9Gz2gXWeemASAyHsJ2u7sRK4mnue2MESMDRQNrixTfa7T5loVlai1/lNa/mtnsPvSVP Jsag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay21-20020a170906d29500b0099bd68129dcsi2824468ejb.760.2023.07.28.08.59.45; Fri, 28 Jul 2023 09:00:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236734AbjG1Owz convert rfc822-to-8bit (ORCPT <rfc822;hanasaki@gmail.com> + 99 others); Fri, 28 Jul 2023 10:52:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjG1Owy (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 28 Jul 2023 10:52:54 -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 8262BCE for <linux-kernel@vger.kernel.org>; Fri, 28 Jul 2023 07:52:53 -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-236-Fp2cxm8lMJC0BQqv7saK6A-1; Fri, 28 Jul 2023 15:52:50 +0100 X-MC-Unique: Fp2cxm8lMJC0BQqv7saK6A-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; Fri, 28 Jul 2023 15:52:49 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Fri, 28 Jul 2023 15:52:49 +0100 From: David Laight <David.Laight@ACULAB.COM> To: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.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 v2 4/5] minmax: Allow comparisons of 'int' against 'unsigned char/short'. Thread-Topic: [PATCH next v2 4/5] minmax: Allow comparisons of 'int' against 'unsigned char/short'. Thread-Index: AdnBYyrMGD35ZuQNSpqtqF8DHKMGsw== Date: Fri, 28 Jul 2023 14:52:49 +0000 Message-ID: <34492660a17e44c19a98c4f0f37f6320@AcuMS.aculab.com> References: <bde3d2dc933848bbaceeb9b7102f6f4c@AcuMS.aculab.com> In-Reply-To: <bde3d2dc933848bbaceeb9b7102f6f4c@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_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772680653144574660 X-GMAIL-MSGID: 1772680653144574660 |
Series |
minmax: Relax type checks in min() and max().
|
|
Commit Message
David Laight
July 28, 2023, 2:52 p.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>
---
v2: No change
include/linux/minmax.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 4c77ac9ed284..7d3ad9cbbff6 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -20,7 +20,8 @@ (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) #define __types_ok(x, y) \ - (is_signed_type(typeof(x)) == is_signed_type(typeof(y))) + (is_signed_type(typeof(x)) == is_signed_type(typeof(y)) || \ + is_signed_type(typeof((x) + 0)) == is_signed_type(typeof((y) + 0))) #define __cmp_op_min < #define __cmp_op_max >