Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7730155rwd; Tue, 20 Jun 2023 05:36:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4TPnuBM/+KAWReF96bLz30Kfiu03hgPhWA9aVw6YaNA9LDBDatADiqOKQUvVz2wovis7y/ X-Received: by 2002:a17:902:82cb:b0:1a6:4a64:4d27 with SMTP id u11-20020a17090282cb00b001a64a644d27mr9899671plz.40.1687264575839; Tue, 20 Jun 2023 05:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687264575; cv=none; d=google.com; s=arc-20160816; b=HZs6pClEk9glgFtvMwbJ8DPWNZml7EtWwjyP2Bm1TZzcHqgFieGHD0B9xVrtmsNSYW lgipdjargd6ZNxcMx4ugFKoBVar+HDa//UxHPSCMqg/lCkDjLgqBPPxa8fGkbkq9ZkVO OhD9/QjCgz3Br1gle4jEcVELYIYTrVkzExR82I1GHgNVlcivgIIVYt/OkxIlfLeQnELS zhdS+Yij8VxTWLHFNycekavL2fR8wA4hheRa8XX2P9omHIrqpHxUqE9hBmoKhUL0pCpn sD1fqWTg1JSw3tShYVZPmL5Km4710p8Nh3GRugT9DPdrTrVHQiP2Sy5OV747Jb7EWCrs Q0/w== 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=s+aPjj3zDYed1LoWXIgwQE0VtTe966vahbShjsT+LTo=; b=nA5HIgE//F6rR8qpuX75nDXZgGpXFwLqW1+wzb26POyLU4kiYlvQSOXoDDili424FU zTDV2Yjkc2c+Pr+3Y22+mTuH2ZweD2NMpwGmC8OcpksV8mm+cWHsZ3KiSxI+8Jfx08xE qSIEZ7Swl9nhdjqM9lD08pxX8Npi/4Y0YCHO8Rtv1B6WV9c/b7CQSNsgpQtSfzjKHb3t TweDwH1YZFw4PbEOkhCDycafxVMSnPp3HmXSw+M8xPjYZ9FAja3+LLJa+vY6fXCkoMJ9 AmoPc4M30fxxFIOiqSrWXRYx97Of/+hHAI+dkQey05FqTthWV2dPHGZoURlSjxO1AKRM XDYw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020a170902ec8100b001b55c029108si1936458plg.363.2023.06.20.05.36.03; Tue, 20 Jun 2023 05:36:15 -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 S231978AbjFTMHH convert rfc822-to-8bit (ORCPT + 99 others); Tue, 20 Jun 2023 08:07:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232036AbjFTMG4 (ORCPT ); Tue, 20 Jun 2023 08:06:56 -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 9D79CE7 for ; Tue, 20 Jun 2023 05:06:54 -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-212-qWok5JaiM8qFyY53-503-g-1; Tue, 20 Jun 2023 13:06:52 +0100 X-MC-Unique: qWok5JaiM8qFyY53-503-g-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 20 Jun 2023 13:06:49 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Tue, 20 Jun 2023 13:06:49 +0100 From: David Laight To: 'Andy Shevchenko' , Jens Axboe , Greg Kroah-Hartman , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v1 1/1] pktcdvd: Use clamp_val() instead of min()+max() Thread-Topic: [PATCH v1 1/1] pktcdvd: Use clamp_val() instead of min()+max() Thread-Index: AQHZoF6FIyAIB0qgg0eyK+mA2nZIdK+TnYVA Date: Tue, 20 Jun 2023 12:06:49 +0000 Message-ID: <9258be5d31104805b63bb1a64317a448@AcuMS.aculab.com> References: <20230616142614.36206-1-andriy.shevchenko@linux.intel.com> In-Reply-To: <20230616142614.36206-1-andriy.shevchenko@linux.intel.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: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko > Sent: 16 June 2023 15:26 > > In a couple of places replace min()+max() pair by clamp_val(). > > Signed-off-by: Andy Shevchenko > --- > drivers/block/pktcdvd.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c > index a1428538bda5..18a960bb6165 100644 > --- a/drivers/block/pktcdvd.c > +++ b/drivers/block/pktcdvd.c > @@ -208,14 +208,11 @@ static DEVICE_ATTR_RO(size); > static void init_write_congestion_marks(int* lo, int* hi) > { > if (*hi > 0) { > - *hi = max(*hi, 500); > - *hi = min(*hi, 1000000); > + *hi = clamp_val(*hi, 500, 1000000); (standard rant about minmax.h) clamp_val() is pretty much broken by design. It MIGHT be ok here but it casts both limits to the type of the value being compared. In general that is just plain wrong. Like min_t() it is generally ok because the kernel only uses unsigned values between 0 and MAXINT. If min/max were ok, then using clamp() should also be ok. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)