[PATCH] staging: most: video: Use min_t() macro for type safety

From: Vojtěch Krátký

Date: Wed Jun 03 2026 - 09:36:50 EST


Replace the open-coded ternary operator matching a minimum calculation
with the standard kernel min_t() macro. Because 'count' is a size_t
and 'rem' is a signed integer, comparing them directly introduces a
signed/unsigned comparison risk. Forcing both to size_t via min_t()
ensures safely typed comparison and fixes a build-time macro assertion.

Signed-off-by: Vojtěch Krátký <vo.kratky@xxxxxxxxx>
---
drivers/staging/most/video/video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index 04351f8ccccf..709f61ed0322 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -178,7 +178,7 @@ static ssize_t comp_vdev_read(struct file *filp, char __user *buf,
while (count > 0 && data_ready(mdev)) {
struct mbo *const mbo = get_top_mbo(mdev);
int const rem = mbo->processed_length - fh->offs;
- int const cnt = rem < count ? rem : count;
+ int const cnt = min_t(size_t, rem, count);

if (copy_to_user(buf, mbo->virt_address + fh->offs, cnt)) {
v4l2_err(&mdev->v4l2_dev, "read: copy_to_user failed\n");
--
2.54.0