From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 2FFB9396D29 for ; Wed, 3 Jun 2026 09:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780479349; cv=none; b=Sy4yo+EJIJCoanH6XGYAhfjTdJI6wN2x3r1nHVh/ikRDituMYPSNENJh9ty/duPyoJ7kfij3nbeRlnVLxTEbaFVyHgleHfq5stLY9iBen6vmxQ+ZxvdIoMUDzxaKmdtrA1gu77NMO0EIC0pl9oSbaDbatMLDZuDa52QgZpTtPv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780479349; c=relaxed/simple; bh=V2xMW1FiYgw+V1AATb6ESENWWBaUELbeOhyK20NKrO8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MW0NGPwwnlqpG1tCiCeIAAUaKFDhWxKalkGmi8V/s6OvXQW+19EatLJA0aZUY7KdckL/kjgI6TPUAOcpkg7xWS3hJbvPVeijKPfJNTg/tOxBM1LMd1uDlLK3tAm+trvzvDdlajQKTJ5z3VhB1OmJ8idO1HMaoelpqkLeiBEBECE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iDpXWCbx; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iDpXWCbx" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490b8a97b11so5092905e9.0 for ; Wed, 03 Jun 2026 02:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780479346; x=1781084146; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=g4JIYSiibWt607X9ebCWaFxpgtq0tZd9h7UsdQPSIWI=; b=iDpXWCbxc8xsqKMAiPqGWzOdh0nsdIj3huZPfy09eMIpkz/grCsYfMETyzYKHnk9Pa ov+LnVElIlBzLAnKQ0BSQScuJc+ViVpXp53CPpZj8meUOSoN4vatBEhwlWzKcFh1ozuh nNwSCs0hZZfC8lxrWqYHPXi8lhS4MPDFYSQ73XVKIHqWVUtrcEWnl8C1gbSfOjeVaRO+ jSLAQ7W38+B0yoRa5BPHUFL2sb8qvE7yPpkTaK+MeMbGioUAmb0MV6xYVl3DCH3QHAP9 klwL1zmWQH1L0vrz4A5MY+GJdgf7mwwX7DKREdFE/ZVm1PY2J3p1xyho6xfsFkQq81yu csMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780479346; x=1781084146; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=g4JIYSiibWt607X9ebCWaFxpgtq0tZd9h7UsdQPSIWI=; b=FdU+DKFibD6UZADuwWHormA+3dzkMGMkCpZNeeBBPr0fF9eOaNE7hJiZiceSzDuxLg vBPmcwYivXPmimDb/F8o3AENcBteve/2zpSnSVZOUP+do4Pw+pUw+qZrZIQzkOiXgX22 nFzuswbaSozoL7fgdNKfuZ5ikh/vU2peb0Phikz2AhSGni12MEod28T9tNfIFrsgMRqm ymF5Mta2gTdNJy4qEkJ9QmC4ji3L3/nq7U+S62ystCqWyR7dIcQKwQVbnCUzVmb4B8Ql QjQUUbzs7iKx/c48x2UCQlcr+b24Arf8oUCY1tyeoaOVmPdGxvMW3fKoa51YlKQI2Nob CuLA== X-Forwarded-Encrypted: i=1; AFNElJ/xr7a5lA+Xd3Y+BaquVKqmxxhFxFgAVfy5oU/UJ3ysibBiYYq0ANiUP0pSKqiHysg7QRZgYqXjik4Qk4o=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6mrEQN0GnTf76D9mK9Lphe1itGPZfrNOysgb8cpSnJS87P9MO FCK8Xi/xOixVi+4dtPuTZa6hlD3gvfYBUrQpIFoqW8WDWUyY24wOnLtm5stMVbF6 X-Gm-Gg: Acq92OHz9ym3KaAbv9mZ6d56shzWu40JCgf0q3Bt9zKYSO2z/c6zV3+dcFwzx88qnnd GXgdicfykUr11XhVpkxO1P0vRC257g8vv2UzMsFTcF69eIreM3+l/AQSDbocqSOQjcPt9zHxFDp tUnFbM341/foGypT3I1pHDrVTXZSVy0fjxm7J0o8TKLlryApVQK0C7QdicDqqttKvSOgp8XxxjC hg5vYnTDkyMt1l8v8Up3/ZEUT1U0NmwrYMRVV7W1Zx5W5V70/F6/wVv/niSfFlh718gmQ7j4QVZ O6YFEJQ7zYSmI3EYMsd9pUH7FmwoB1mqQ4yydCGNNegnETsQDlKAJBKoU4H3W5admwAMDZl60a8 eNr2Qh3KsqP0ab9GG5mzM9oo962BsjRvwMSTZFmEQad4cHCZJS5rnEsUHa+IrB/KHWubeDASOPf O7CsW2J0G4j98XcAzZjLu0SiNqREXNISu/WP2r4lri3mqnVOIq1VXN58LjzIxMkntVCcaqfKw= X-Received: by 2002:a05:600c:8b5b:b0:490:4ee0:82f9 with SMTP id 5b1f17b1804b1-490b5e73dbamr40853665e9.7.1780479346271; Wed, 03 Jun 2026 02:35:46 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b0e823f7sm141738035e9.13.2026.06.03.02.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 02:35:45 -0700 (PDT) Date: Wed, 3 Jun 2026 10:35:39 +0100 From: David Laight To: Petr Mladek Cc: Thorsten Blum , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib/vsprintf: replace min_t/max_t with min/max Message-ID: <20260603103539.13028bf4@pumpkin> In-Reply-To: References: <20260518123145.79411-3-thorsten.blum@linux.dev> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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-Transfer-Encoding: 7bit On Thu, 21 May 2026 15:49:12 +0200 Petr Mladek wrote: > On Mon 2026-05-18 14:31:47, Thorsten Blum wrote: > > Use the simpler min()/max() macros since the values are all compatible. > > > > --- a/lib/vsprintf.c > > +++ b/lib/vsprintf.c > > @@ -1208,7 +1208,7 @@ char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, > > } > > > > if (spec.field_width > 0) > > - len = min_t(int, spec.field_width, 64); > > + len = min(spec.field_width, 64); > > Honestly, I do not see any big advantage in replacing the macros. > In fact, the min()/max() macros are even more complex because > they check compatibility of the compared types. But min_t() is often worse that just letting the compiler promote a negative signed value to a very large unsigned one. There are basically three common misuses: 1) Using the type you want the result to be. 2) Using the smaller type, including 'long' v 'u64' on 32bit. 3) Thinking min_t(type, a, b) is the best way to compare items of type 'type'. All not helped by checkpatch suggesting that: min(foo, (type)bar) is 'an opportunity for': min_t(type, foo, bar) but the latter is: min((type)foo, (type)bar) and you never need both casts. There are also a few of the pointless/buggy: min_t(u8, foo, U8_MAX) but you'd notice that the test: if ((u8)foo > U8_MAX) doesn't do what was intended. Ideally min_t() ought to be killed, but it is a big job. (The sort of thing Linus could because of his 'god' bit.) -- David > > IMHO, this adds non-necessary churn into the git history without > an obvious advantage. > > Best Regards, > Petr >