Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2269471rdd; Fri, 12 Jan 2024 04:50:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZ1soZFEJeaQn0i9co3E7dVkcG+vCIIGogGmfXLu/N8YuGg1zg8jwDpCUSOmPDBtfrjxdc X-Received: by 2002:a05:622a:286:b0:429:bb09:6106 with SMTP id z6-20020a05622a028600b00429bb096106mr1497346qtw.1.1705063818314; Fri, 12 Jan 2024 04:50:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705063818; cv=none; d=google.com; s=arc-20160816; b=exPBiiYeCOlfQpYDtLpBMVbHrGsA50TR3HCa6Vqqd8NXp/YN4zanqu8ku+GcyEXRXm 9AH/UOAohqRz/WP6TU1tM9XeHCZJkRbbPBvKh5N/teW+MODbkwnMv/E0I/jc9XU9iGS3 FU9shmyCfPk20w3hs7unPJrCENHqRwc/EsLedT0nhTCHjTPIy8lNcYnWVKRF/RE/ZQ6N Vu8y1qiojRfX5ha38wxR3xr4hbW8Eyc1a+QVh2n6ohhENNJaAnM31WO9Bp4K3ZfAINaR DEQ/vlRjfcP8bQCpnU81JJYbLjUIM4QNofLr9I+YuIexVtDUEiGVw5BbUWqfsL1eS8im /G7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ffDVakycpQ7cBopIWY9dBvwcHA+X2IQ9A3mW/X1FrhM=; fh=qGAKtm2PD+NxJ1Hk/Ovt7q824zeHFTw93aNWsehQ8wc=; b=nW8UNtWppz9ehC7Ayx93T0RY/PuB8l0ZsXdvKcuBbY9zxOG7A1dt0VR07qUX1TUN6y LxJCHdQCukleMBijbr1EPG0IAfHZ3fYLMEg32JAaFbOK0DpdcyGSYdB0m99HsFD8y4nR AQCfZiodphQgZm48jKz+3ZidNNj9mhdRBNrjsZFkwSdb1YB0I2iuFvB7uFrQb2ohkiRz tZTDYVGNtfI8PfiboG/37m9VHhIaBPJybGBHL0TwbjNRvwAUndTBZfWD82F96sTZjgxF IXnlqziajQ3yFMOSxLCjgzo3f+6+7Abxw/HqucTaUmzZfEc6A+XeVfIsaUg28ib0ugc2 dyZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hIYUIJtj; spf=pass (google.com: domain of linux-kernel+bounces-24665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f6-20020ac859c6000000b00429cf4bb161si872811qtf.641.2024.01.12.04.50.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 04:50:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hIYUIJtj; spf=pass (google.com: domain of linux-kernel+bounces-24665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 16F2A1C21899 for ; Fri, 12 Jan 2024 12:50:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 826B55EE94; Fri, 12 Jan 2024 12:50:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hIYUIJtj" Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E80041C67 for ; Fri, 12 Jan 2024 12:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3367601a301so5434118f8f.2 for ; Fri, 12 Jan 2024 04:50:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705063807; x=1705668607; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ffDVakycpQ7cBopIWY9dBvwcHA+X2IQ9A3mW/X1FrhM=; b=hIYUIJtjccgYIWeij0u5a7U68yOaLxWxzB0M9RK+aZwIyckVFyQ5oZXL8MfRs5IM/J WppvpCirjX3NeLDJfaXymuTCRLlCZmFPUDQbEcuTDuH6MEK/SCvj++UzH1DPfSUWAbtM PTeCMMT3T2VjhWDyD8ABP6ggo2rAqFly2ykorLbErlBxS0HUlTHpPdP1NdR8aHFqa19M ijWWDMxLoTd971Pg+87hbw9e3eYoJpWscHbBecXS16gKYZKaluCMcQ2byekNwUWUZftG OqiF5Nac56TPsOcICwBU4+J3I6D8SzdwE7fiySzXfr0z3XjCferSWSQRCmlKjH5gX5m7 gL5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705063807; x=1705668607; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ffDVakycpQ7cBopIWY9dBvwcHA+X2IQ9A3mW/X1FrhM=; b=GpQxipKG3nd7KVRR2mNufAJDQ1pOXiqEiLhWmL3+bvieaoWOAbKMovdHw4KGz6Mxst wGwlbwuoRgEKCwkmM7j8tghohR1dH8njmqELZGNSrd7ptHq8X2SxUpmd9VKahpnE0UFp EG+QxHKI6cy7JZ/WPix+J/ItnLeXweOhQORV0tlQnx9vDJHdgfC4zKvA0LWRAVKupRnR 6DI8W/HTdzkoKThcAMMC9AkJpsE45gxdt6GP8nz8tcifrtu3wjC/x3LmsYTG88xW5uls ++63KiS9TAqw2Y/44NSCRtgGiai/hfp56OF1LpIQ20P45KShKgnWLCZ+IdeEMni0ZCV/ FbLA== X-Gm-Message-State: AOJu0Yynv2/K9ZNL7lEojZsuIr5rLc80H3iv6XWhdODQBE6Nk7O7F9yU WNxQgXY/2gRcsyjg/gg8TRqkUetQpH8QBA== X-Received: by 2002:a05:600c:358e:b0:40e:3cab:ef76 with SMTP id p14-20020a05600c358e00b0040e3cabef76mr455609wmq.117.1705063807082; Fri, 12 Jan 2024 04:50:07 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id d11-20020adfa34b000000b00336e15fbc85sm3807205wrb.82.2024.01.12.04.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 04:50:06 -0800 (PST) Date: Fri, 12 Jan 2024 15:49:59 +0300 From: Dan Carpenter To: David Laight Cc: "linux-kernel@vger.kernel.org" , Linus Torvalds , 'Andy Shevchenko' , 'Andrew Morton' , "'Matthew Wilcox (Oracle)'" , 'Christoph Hellwig' , "'Jason A. Donenfeld'" Subject: Re: [PATCH next v4 1/5] minmax: Add umin(a, b) and umax(a, b) Message-ID: <737627fd-b68b-4c9d-8700-f0e0d6d9cec8@moroto.mountain> References: <41d93ca827a248698ec64bf57e0c05a5@AcuMS.aculab.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41d93ca827a248698ec64bf57e0c05a5@AcuMS.aculab.com> On Mon, Sep 18, 2023 at 08:16:30AM +0000, David Laight wrote: > +/** > + * umin - return minimum of two non-negative values > + * Signed types are zero extended to match a larger unsigned type. > + * @x: first value > + * @y: second value > + */ > +#define umin(x, y) \ > + __careful_cmp((x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull, <) Why do we match "a larger unsigned type" instead of ULL_MAX? Presumably it helps performance somehow... I agree that it's probably fine but I would be more comfortable if it skipped UINT_MAX and jumped directly to ULONG_MAX. These days 4 gigs is small potatoes. The vmalloc() function can allocate 4G so we've had integer overflow bugs with this before. regards, dan carpenter