[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZJwPlLC7/sJP8U7u@smile.fi.intel.com>
Date:   Wed, 28 Jun 2023 13:46:44 +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>,
        Tom Zanussi <tom.zanussi@...ux.intel.com>,
        Damian Muszynski <damian.muszynski@...el.com>,
        Srinivas Kerekare <srinivas.kerekare@...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 v2] crypto: qat - Replace the if statement with min()
On Tue, Jun 27, 2023 at 03:17:24PM +0800, You Kangren wrote:
> Replace the if statement with min_t() to simplify the code
...
> -		if (words_num < UWORD_CPYBUF_SIZE)
> -			cpylen = words_num;
> -		else
> -			cpylen = UWORD_CPYBUF_SIZE;
> +		cpylen = min_t(unsigned int, words_num, UWORD_CPYBUF_SIZE);
min_t() can be dangerous some times.
To make it robust I would suggest to use min() and mark UWORD_CPYBUF_SIZE
with U suffix to make the type the same.
-- 
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists