]> www.infradead.org Git - users/willy/linux.git/commitdiff
drivers/usb/mon: refactor min with min_t
authorSabyrzhan Tasbolatov <snovitoll@gmail.com>
Tue, 12 Nov 2024 15:58:14 +0000 (20:58 +0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Nov 2024 14:09:51 +0000 (15:09 +0100)
Ensure type safety by using min_t() instead of casted min().

Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Link: https://lore.kernel.org/r/20241112155817.3512577-6-snovitoll@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/mon/mon_bin.c

index afb71c18415dd1781483210d27d049fa6ba52743..c93b43f5bc4614ad75568b601c47a1ae51f01fa5 100644 (file)
@@ -823,7 +823,7 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf,
        ep = MON_OFF2HDR(rp, rp->b_out);
 
        if (rp->b_read < hdrbytes) {
-               step_len = min(nbytes, (size_t)(hdrbytes - rp->b_read));
+               step_len = min_t(size_t, nbytes, hdrbytes - rp->b_read);
                ptr = ((char *)ep) + rp->b_read;
                if (step_len && copy_to_user(buf, ptr, step_len)) {
                        mutex_unlock(&rp->fetch_lock);