diff options
| author | Thorsten Blum <thorsten.blum@linux.dev> | 2025-09-08 20:13:54 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-10-22 07:53:49 +0200 |
| commit | f50d2dcd1a2a0a8c959f9d6fd1dafa78954086f4 (patch) | |
| tree | 5c96bef446464f94de4ce396972860b7890ee662 | |
| parent | 47f1a2acee55a116dfd1daff7ee37cc4ff5fa5ed (diff) | |
| download | lwn-f50d2dcd1a2a0a8c959f9d6fd1dafa78954086f4.tar.gz lwn-f50d2dcd1a2a0a8c959f9d6fd1dafa78954086f4.zip | |
char/adi: Use min_t(size_t,,) in adi_read() + adi_write()
Replace min() and manual casting of MAX_BUF_SZ with min_t(size_t,,) in
both adi_read() and adi_write().
This matches the initial buffer size calculation:
ver_buf_sz = min_t(size_t, count, MAX_BUF_SZ);
and makes the code more consistent. No functional changes intended.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250908181354.436680-2-thorsten.blum@linux.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/char/adi.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/char/adi.c b/drivers/char/adi.c index 4312b0cc391c..0849d933a2d5 100644 --- a/drivers/char/adi.c +++ b/drivers/char/adi.c @@ -80,8 +80,8 @@ static ssize_t adi_read(struct file *file, char __user *buf, bytes_read += ver_buf_sz; ver_buf_idx = 0; - ver_buf_sz = min(count - bytes_read, - (size_t)MAX_BUF_SZ); + ver_buf_sz = min_t(size_t, count - bytes_read, + MAX_BUF_SZ); } } @@ -157,7 +157,7 @@ static ssize_t adi_write(struct file *file, const char __user *buf, } bytes_written += ver_buf_sz; - ver_buf_sz = min(count - bytes_written, (size_t)MAX_BUF_SZ); + ver_buf_sz = min_t(size_t, count - bytes_written, MAX_BUF_SZ); } while (bytes_written < count); (*offp) += bytes_written; |
