linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] s390: crypto: Use min() instead of doing it manually
@ 2022-03-15  8:01 Haowen Bai
  2022-03-15  9:15 ` Heiko Carstens
  2022-03-15 10:05 ` David Laight
  0 siblings, 2 replies; 5+ messages in thread
From: Haowen Bai @ 2022-03-15  8:01 UTC (permalink / raw)
  To: freude, hca, gor, agordeev; +Cc: linux-s390, linux-kernel, Haowen Bai

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);
 	}
 
 	/* request cprb and payload */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] s390: crypto: Use min() instead of doing it manually
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Heiko Carstens @ 2022-03-15  9:15 UTC (permalink / raw)
  To: Haowen Bai; +Cc: freude, gor, agordeev, linux-s390, linux-kernel

On Tue, Mar 15, 2022 at 04:01:04PM +0800, Haowen Bai wrote:
> 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 would assume that checkpatch will now warn that this is an
opportunity to use min_t()...
Anyway, it is up to Harald to decide what do with this.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* 答复: [PATCH v2] s390: crypto: Use min() instead of doing it manually
  2022-03-15  9:15 ` Heiko Carstens
@ 2022-03-15  9:25   ` 白浩文
  0 siblings, 0 replies; 5+ messages in thread
From: 白浩文 @ 2022-03-15  9:25 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: freude, gor, agordeev, linux-s390, linux-kernel

hi, Heiko

Thank you for your reply and suggestion.
________________________________________
发件人: Heiko Carstens <hca@linux.ibm.com>
发送时间: 2022年3月15日 17:15:51
收件人: 白浩文
抄送: freude@linux.ibm.com; gor@linux.ibm.com; agordeev@linux.ibm.com; linux-s390@vger.kernel.org; linux-kernel@vger.kernel.org
主题: Re: [PATCH v2] s390: crypto: Use min() instead of doing it manually

On Tue, Mar 15, 2022 at 04:01:04PM +0800, Haowen Bai wrote:
> 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 would assume that checkpatch will now warn that this is an
opportunity to use min_t()...
Anyway, it is up to Harald to decide what do with this.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH v2] s390: crypto: Use min() instead of doing it manually
  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 10:05 ` David Laight
  2022-03-16  1:48   ` 答复: " 白浩文
  1 sibling, 1 reply; 5+ messages in thread
From: David Laight @ 2022-03-15 10:05 UTC (permalink / raw)
  To: 'Haowen Bai', freude, hca, gor, agordeev; +Cc: linux-s390, linux-kernel

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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* 答复: [PATCH v2] s390: crypto: Use min() instead of doing it manually
  2022-03-15 10:05 ` David Laight
@ 2022-03-16  1:48   ` 白浩文
  0 siblings, 0 replies; 5+ messages in thread
From: 白浩文 @ 2022-03-16  1:48 UTC (permalink / raw)
  To: David Laight, freude, hca, gor, agordeev; +Cc: linux-s390, linux-kernel

hi, David

Thank you for your reply, all is ok, just a coding style.
Ignore my patch.
________________________________________
发件人: David Laight <David.Laight@ACULAB.COM>
发送时间: 2022年3月15日 18:05:24
收件人: 白浩文; freude@linux.ibm.com; hca@linux.ibm.com; gor@linux.ibm.com; agordeev@linux.ibm.com
抄送: linux-s390@vger.kernel.org; linux-kernel@vger.kernel.org
主题: RE: [PATCH v2] s390: crypto: Use min() instead of doing it manually

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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-16  1:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-03-16  1:48   ` 答复: " 白浩文

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).