public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Haowen Bai' <baihaowen@meizu.com>,
	"freude@linux.ibm.com" <freude@linux.ibm.com>,
	"hca@linux.ibm.com" <hca@linux.ibm.com>,
	"gor@linux.ibm.com" <gor@linux.ibm.com>,
	"agordeev@linux.ibm.com" <agordeev@linux.ibm.com>
Cc: "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2] s390: crypto: Use min() instead of doing it manually
Date: Tue, 15 Mar 2022 10:05:24 +0000	[thread overview]
Message-ID: <cc26b079f808420592cfea19580e34f5@AcuMS.aculab.com> (raw)
In-Reply-To: <1647331264-13853-1-git-send-email-baihaowen@meizu.com>

From: Haowen Bai
> Sent: 15 March 2022 08:01
> 
> Fix following coccicheck warning:
> drivers/s390/crypto/zcrypt_ep11misc.c:1112:25-26: WARNING opportunity for min()
> 
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
>  drivers/s390/crypto/zcrypt_ep11misc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/crypto/zcrypt_ep11misc.c b/drivers/s390/crypto/zcrypt_ep11misc.c
> index 9ce5a71..bb2a527 100644
> --- a/drivers/s390/crypto/zcrypt_ep11misc.c
> +++ b/drivers/s390/crypto/zcrypt_ep11misc.c
> @@ -1109,7 +1109,7 @@ static int ep11_wrapkey(u16 card, u16 domain,
>  	if (kb->head.type == TOKTYPE_NON_CCA &&
>  	    kb->head.version == TOKVER_EP11_AES) {
>  		has_header = true;
> -		keysize = kb->head.len < keysize ? kb->head.len : keysize;
> +		keysize = min((size_t)kb->head.len, keysize);

I'm sure that would look better as:
		if (keysize > kb->head.len)
			keysize = kb->head.len;
which makes it much more obvious that the existing value
is being limited by a new bound.

	David

>  	}
> 
>  	/* request cprb and payload */
> --
> 2.7.4

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


  parent reply	other threads:[~2022-03-15 10:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15  8:01 [PATCH v2] s390: crypto: Use min() instead of doing it manually Haowen Bai
2022-03-15  9:15 ` Heiko Carstens
2022-03-15  9:25   ` 答复: " 白浩文
2022-03-15 10:05 ` David Laight [this message]
2022-03-16  1:48   ` 白浩文

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc26b079f808420592cfea19580e34f5@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=agordeev@linux.ibm.com \
    --cc=baihaowen@meizu.com \
    --cc=freude@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox