Skip to contentSkip to conversation

char/adi: Use min_t(size_t,,) in adi_read() + adi_write()

PATCH New Thorsten Blum 1 participant 1 message Sep 8, 2025 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/char/adi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/adi.c +3 -3
index f9bec10a6064..ca3a202dc2b2 100644
@@ -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;
Signature · 1 line
2.51.0