lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 3 Jul 2023 16:18:00 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     You Kangren <youkangren@...o.com>
Cc:     Giovanni Cabiddu <giovanni.cabiddu@...el.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>,
        Adam Guerin <adam.guerin@...el.com>,
        Srinivas Kerekare <srinivas.kerekare@...el.com>,
        Tom Zanussi <tom.zanussi@...ux.intel.com>,
        Damian Muszynski <damian.muszynski@...el.com>,
        "open list:QAT DRIVER" <qat-linux@...el.com>,
        "open list:CRYPTO API" <linux-crypto@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        opensource.kernel@...o.com
Subject: Re: [PATCH v3] crypto: qat - Replace the if statement with min()

On Mon, Jul 03, 2023 at 08:37:36PM +0800, You Kangren wrote:
> mark UWORD_CPYBUF_SIZE with U suffix to make the type the same with
> words_num and replace the if statement with min()

Makes code shorter,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>

> Signed-off-by: You Kangren <youkangren@...o.com>
> ---
>  drivers/crypto/intel/qat/qat_common/qat_uclo.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/crypto/intel/qat/qat_common/qat_uclo.c b/drivers/crypto/intel/qat/qat_common/qat_uclo.c
> index ce837bcc1cab..bad65f154777 100644
> --- a/drivers/crypto/intel/qat/qat_common/qat_uclo.c
> +++ b/drivers/crypto/intel/qat/qat_common/qat_uclo.c
> @@ -5,13 +5,14 @@
>  #include <linux/kernel.h>
>  #include <linux/delay.h>
>  #include <linux/pci_ids.h>
> +#include <linux/minmax.h>
>  #include "adf_accel_devices.h"
>  #include "adf_common_drv.h"
>  #include "icp_qat_uclo.h"
>  #include "icp_qat_hal.h"
>  #include "icp_qat_fw_loader_handle.h"
>  
> -#define UWORD_CPYBUF_SIZE 1024
> +#define UWORD_CPYBUF_SIZE 1024U
>  #define INVLD_UWORD 0xffffffffffull
>  #define PID_MINOR_REV 0xf
>  #define PID_MAJOR_REV (0xf << 4)
> @@ -1986,10 +1987,7 @@ static void qat_uclo_wr_uimage_raw_page(struct icp_qat_fw_loader_handle *handle,
>  	uw_relative_addr = 0;
>  	words_num = encap_page->micro_words_num;
>  	while (words_num) {
> -		if (words_num < UWORD_CPYBUF_SIZE)
> -			cpylen = words_num;
> -		else
> -			cpylen = UWORD_CPYBUF_SIZE;
> +		cpylen = min(words_num, UWORD_CPYBUF_SIZE);
>  
>  		/* load the buffer */
>  		for (i = 0; i < cpylen; i++)
> -- 
> 2.39.0
> 

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ