mirror of https://github.com/torvalds/linux.git
usb: usblp: Use min_t() to improve usblp_read()
Use min_t() to improve usblp_read() and avoid calculating 'avail - usblp->readcount' twice. Use min_t(ssize_t,,) instead of min() to avoid a signedness error. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20250829173713.56222-1-thorsten.blum@linux.dev Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
91709d2ce5
commit
43ae982cd0
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/minmax.h>
|
||||
#include <linux/sched/signal.h>
|
||||
#include <linux/signal.h>
|
||||
#include <linux/poll.h>
|
||||
|
|
@ -871,7 +872,7 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
|
|||
goto done;
|
||||
}
|
||||
|
||||
count = len < avail - usblp->readcount ? len : avail - usblp->readcount;
|
||||
count = min_t(ssize_t, len, avail - usblp->readcount);
|
||||
if (count != 0 &&
|
||||
copy_to_user(buffer, usblp->readbuf + usblp->readcount, count)) {
|
||||
count = -EFAULT;
|
||||
|
|
|
|||
Loading…
Reference in New Issue