lkml.org 
[lkml]   [2023]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [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


    \
     
     \ /
      Last update: 2023-06-28 12:49    [W:5.096 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site