Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3849338pxv; Mon, 19 Jul 2021 10:12:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5H3BeFMhKH35clngM+hlhYVPcVMREa3QneUN7OwFFhfu+k0sxbRqA6rpmZ+tfPBvCBAf2 X-Received: by 2002:a92:bd09:: with SMTP id c9mr17483766ile.233.1626714723888; Mon, 19 Jul 2021 10:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626714723; cv=none; d=google.com; s=arc-20160816; b=YvDpJMju5gibUjgRei277zgxDMk4qpxnsm3TDzWFcXiH6D0wWT2VzIMj9Ztnw9GOib 3lYqZaY+bmJ6AWFaZUmCgD17Wus5SbagafkUYXCMV5pQnQlerGRW6mOsNb/aUkdnRf9Q Ie8GobiuW2qUY4QqZrje7aaL1I9Cn/wgCgKq1WduIFDFHFN5Wn0CXHQQONOl2S00ewuD 6KDfl7Blo3b8cRJFiZqr64wlaorAimGiCxLQ3hYxLxRhDeDrgns6J/OpN2wxPKvRrwmc CsomSan24vQooDR6+9P/iwJwxUTYbbuPX2JbDw6FZFZITsLJFseDf2l4luOGmEnQ5NwS Rtdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=POOnkRkWHKN05QqXi+w+RE5p0959X7Kxu+ZD/T9AHRk=; b=E2+QNq6cljGSWPZEOFTiQVYXRMhFgEHnmfOhdAR5gWKz5OldBw9W1tJvQln1Qt22Qa mUE/U3z1ERP+E3UPHJGblp/EFERu1P82Hdyo/qLvh7EoPcpA48+Gm+1T7Qqt1YtJda+h 51DIRXdnLM1s/9qnh2CkiopGnSxQcAeapf4w0h/IcJvulZVX4mrUHy10hOTdLtYHF7J7 LkQ0MmXqxWNXAlFfWzkSiRKbcEXjenSoTtwT2JCy43PjB8zO7WyGAaDIF+2w8OhdxqkA uUk4M5zLhgRlxLmojMcObSFXznZ7KH7+D5+/3Oxiwqh0n6I6YGJC4pIkQftATC2lA4EE driQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si3467644ilc.19.2021.07.19.10.11.40; Mon, 19 Jul 2021 10:12:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239768AbhGSQa4 (ORCPT + 99 others); Mon, 19 Jul 2021 12:30:56 -0400 Received: from gate.crashing.org ([63.228.1.57]:36742 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354624AbhGSQaW (ORCPT ); Mon, 19 Jul 2021 12:30:22 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 16JH4N2o028857; Mon, 19 Jul 2021 12:04:23 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 16JH4Mln028856; Mon, 19 Jul 2021 12:04:22 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 19 Jul 2021 12:04:22 -0500 From: Segher Boessenkool To: Christophe Leroy Cc: Salah Triki , herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org, paulus@samba.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, davem@davemloft.net Subject: Re: [PATCH] replace if with min Message-ID: <20210719170422.GO1583@gate.crashing.org> References: <20210712204546.GA1492390@pc> <20210719181205.Horde.xU8C00MIRgjqhZQ3-RrANw8@messagerie.c-s.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210719181205.Horde.xU8C00MIRgjqhZQ3-RrANw8@messagerie.c-s.fr> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Jul 19, 2021 at 06:12:05PM +0200, Christophe Leroy wrote: > Salah Triki a ?crit?: > >Replace if with min in order to make code more clean. > >--- a/drivers/crypto/nx/nx-842.c > >+++ b/drivers/crypto/nx/nx-842.c > >@@ -134,8 +134,7 @@ EXPORT_SYMBOL_GPL(nx842_crypto_exit); > > static void check_constraints(struct nx842_constraints *c) > > { > > /* limit maximum, to always have enough bounce buffer to decompress > > */ > >- if (c->maximum > BOUNCE_BUFFER_SIZE) > >- c->maximum = BOUNCE_BUFFER_SIZE; > >+ c->maximum = min(c->maximum, BOUNCE_BUFFER_SIZE); > > For me the code is less clear with this change, and in addition it > slightly changes the behaviour. Before, the write was done only when > the value was changing. Now you rewrite the value always, even when it > doesn't change. In both cases the compiler can decide to either write it more often than strictly needed, depending on what it thinks best (and it usually has better estimates than the programmer). The behaviour is identical (and the generated machine code is as well, in my testing). The field name "maximum" is not the best choice, which makes the code read a bit funny ("the min of max"), but the comment makes things pretty clear. Segher