Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Thorsten Blum and committed by
Greg Kroah-Hartman
f50d2dcd 47f1a2ac

+3 -3
+3 -3
drivers/char/adi.c
··· 80 80 bytes_read += ver_buf_sz; 81 81 ver_buf_idx = 0; 82 82 83 - ver_buf_sz = min(count - bytes_read, 84 - (size_t)MAX_BUF_SZ); 83 + ver_buf_sz = min_t(size_t, count - bytes_read, 84 + MAX_BUF_SZ); 85 85 } 86 86 } 87 87 ··· 157 157 } 158 158 159 159 bytes_written += ver_buf_sz; 160 - ver_buf_sz = min(count - bytes_written, (size_t)MAX_BUF_SZ); 160 + ver_buf_sz = min_t(size_t, count - bytes_written, MAX_BUF_SZ); 161 161 } while (bytes_written < count); 162 162 163 163 (*offp) += bytes_written;