Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2524342rwd; Fri, 16 Jun 2023 05:03:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bSwKu/bMlfd9IzdzbkxnL361W3z5VZjoXFFMQsCk4IlNCwIKT2Ha/XesYSaWMq9Et7aXq X-Received: by 2002:a05:6a20:4289:b0:10c:62b3:7dc4 with SMTP id o9-20020a056a20428900b0010c62b37dc4mr2084284pzj.55.1686917015549; Fri, 16 Jun 2023 05:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686917015; cv=none; d=google.com; s=arc-20160816; b=kInyXXT6AKaP2Y3we1BNC+4WUZlwRUhUah2V+zqdWLZzKpBXIl9Cbseol77GFfzH8O xyH/S4Ox9iSzfLKf8sXcRgFouNECl8wxtCdHdKrWAW8zkxtThyqXo8V6V+riQbt5f9mI qwMEuoWY00yVWzN0WjfoBnPRXmg4bsMr18WSRMU7QbDrVN3wMeEWAtJiswc0mN7jzBk3 Sy6MWDV4xSx8Rz2bx0k5kR5XlNMMjce3htcssHIhbQzB4RtGQ3uinGdNsNEXCbrbkO8p fiicGrnXwn1sdjC3ReLVKibZYZ+kmvwyPjg8HxhcnRGj0UvuC9Ezq/4K5IlRuvTRQo3d x1+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=oLKhvPrptWFoCmJpHArFvlKc/yEEcCk45NeiCg0/3Yg=; b=n0KK5miqCaxH4Zh2cBsCynkmILT0Ud8sbD/Iea8hW6VppplhdYVjLbI64y9H+Ur+pl qxZfMcZoYSt4J4Z4K+I/dbJ8YEJEM6w01prf/uQohLg9Hvg/MQxvwgmxeW8tVZuYQMmQ SA4ilmoahD8gwq9vPllACXcxjhLMX0qr9o+RHrbQk8u2xs++uJ69EjbyY/kDCmHiQtTI +IKPstpqZ3QjqCQBox544wmHJGriF+Jq3UKe+AVeNph+fqd2fTwlr6krN349J0HAAOUi fKYFIKv9jTQNEr0yYZHySit0bvk/nwHZTkH/4H9S/iOP5Myva+4Z2iYR99rsEMET7Rge vIrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LL2WMmiQ; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a654b8d000000b00543d32f92ecsi1442946pgq.472.2023.06.16.05.03.23; Fri, 16 Jun 2023 05:03:35 -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; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LL2WMmiQ; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344249AbjFPLs7 (ORCPT + 99 others); Fri, 16 Jun 2023 07:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343703AbjFPLsu (ORCPT ); Fri, 16 Jun 2023 07:48:50 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B79191; Fri, 16 Jun 2023 04:48:49 -0700 (PDT) X-GND-Sasl: herve.codina@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686916128; h=from:from: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; bh=oLKhvPrptWFoCmJpHArFvlKc/yEEcCk45NeiCg0/3Yg=; b=LL2WMmiQsuIm4g/hjHsD81IzOy08yCDudlals5vYRPZBYhTAwXCnSUWZD8hxJ1ixAlMj+V JYx7e7oVG7MoU4swUjUs2j3hAl6PBV8k7c7E5Z7FNSQjf1MGesJQQ9L4BsP3a4lkHTruFS BK1MVffkb7DWP+kNcYd4mIHG8qYIeHpOKVlSFUfAFgzubUkRbgV9EtXs2U2uTjAypYYwH9 X0BbwTXxmZ4PXGtrmlSI8s15MuoaOxM/rZ9NXiLu2AhOzPTH1rrRD1xPYHWoxQr4VO4lCA Z+JVCActDH1jkX1Xa+2xdSqlAOUVJwvSZ1BHYnfBUFMZlRIxDPGj4GXVSs0pQg== X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id A2CD0C0002; Fri, 16 Jun 2023 11:48:45 +0000 (UTC) Date: Fri, 16 Jun 2023 13:48:44 +0200 From: Herve Codina To: David Laight Cc: Andy Shevchenko , Liam Girdwood , Mark Brown , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , "Kuninori Morimoto" , "alsa-devel@alsa-project.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-iio@vger.kernel.org" , Christophe Leroy , Thomas Petazzoni Subject: Re: [PATCH v4 07/13] minmax: Introduce {min,max}_array() Message-ID: <20230616134844.09e7fda3@bootlin.com> In-Reply-To: <6c7fe34f7b65421ab618d33ba907ae09@AcuMS.aculab.com> References: <20230614074904.29085-1-herve.codina@bootlin.com> <20230614074904.29085-8-herve.codina@bootlin.com> <20230614114214.1371485e@bootlin.com> <20230614223418.0d7e355d@bootlin.com> <20230615113512.07967677@bootlin.com> <6c7fe34f7b65421ab618d33ba907ae09@AcuMS.aculab.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hi David, On Fri, 16 Jun 2023 09:08:22 +0000 David Laight wrote: ... > > Just define two variables typeof(__array[0] + 0) one for an element > and one for the limit. > The just test (eg): > if (limit > item) limit = item; > finally cast the limit back to the original type. > The promotions of char/short to signed int won't matter. > There is no need for all the type-checking in min/max. > > Indeed, if min_t(type, a, b) is in anyway sane it should > expand to: > type _a = a, _b = b; > _a < _b ? _a : _b > without any of the checks that min() does. I finally move to use _Generic() in order to "unconstify" and avoid the integer promotion. With this done, no extra cast is needed and min()/max() are usable. The patch is available in the v5 series. https://lore.kernel.org/linux-kernel/20230615152631.224529-8-herve.codina@bootlin.com/ Do you think the code present in the v5 series should be changed ? If so, can you give me your feedback on the v5 series ? Thanks for your review, Hervé