public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2] staging: most: video: use min_t() for comparison and assignment
@ 2022-11-07  4:20 Deepak R Varma
  2022-11-07 13:20 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Deepak R Varma @ 2022-11-07  4:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-staging, linux-kernel

Simplify code by using min_t helper macro for logical evaluation
and value assignment. Use the _t variant of min macro since the
variable types are not same.
This issue is identified by coccicheck using the minmax.cocci file.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---

Changes in v2:
   1. Revise patch description. No functional change.

 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 ffa97ef21ea5..d5cc7eea3b52 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -173,7 +173,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(int, 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.34.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-07 17:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-07  4:20 [PATCH v2] staging: most: video: use min_t() for comparison and assignment Deepak R Varma
2022-11-07 13:20 ` Dan Carpenter
2022-11-07 15:10   ` Deepak R Varma
2022-11-07 15:21     ` Dan Carpenter
2022-11-07 17:52       ` Deepak R Varma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox