All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: v4l2-dev.c: Modified the macro SET_VALID_IOCTL
@ 2021-05-25  9:41 lijian_8010a29
  2021-05-25 15:22 ` Sakari Ailus
  0 siblings, 1 reply; 2+ messages in thread
From: lijian_8010a29 @ 2021-05-25  9:41 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, ezequiel, laurent.pinchart
  Cc: linux-media, linux-kernel, lijian

From: lijian <lijian@yulong.com>

Macros starting with if should be enclosed by a do - while loop
to avoid possible if/else logic defects.
So modified the macro SET_VALID_IOCTL with do - while loop.

Signed-off-by: lijian <lijian@yulong.com>
---
 drivers/media/v4l2-core/v4l2-dev.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 7d0edf3530be..15067843456e 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -520,9 +520,8 @@ static int get_index(struct video_device *vdev)
 	return find_first_zero_bit(used, VIDEO_NUM_DEVICES);
 }
 
-#define SET_VALID_IOCTL(ops, cmd, op)			\
-	if (ops->op)					\
-		set_bit(_IOC_NR(cmd), valid_ioctls)
+#define SET_VALID_IOCTL(ops, cmd, op) \
+	do { if (ops->op) set_bit(_IOC_NR(cmd), valid_ioctls); } while (0)
 
 /* This determines which ioctls are actually implemented in the driver.
    It's a one-time thing which simplifies video_ioctl2 as it can just do
-- 
2.25.1


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

* Re: [PATCH] media: v4l2-dev.c: Modified the macro SET_VALID_IOCTL
  2021-05-25  9:41 [PATCH] media: v4l2-dev.c: Modified the macro SET_VALID_IOCTL lijian_8010a29
@ 2021-05-25 15:22 ` Sakari Ailus
  0 siblings, 0 replies; 2+ messages in thread
From: Sakari Ailus @ 2021-05-25 15:22 UTC (permalink / raw)
  To: lijian_8010a29
  Cc: mchehab, hverkuil-cisco, ezequiel, laurent.pinchart, linux-media,
	linux-kernel, lijian

On Tue, May 25, 2021 at 05:41:48PM +0800, lijian_8010a29@163.com wrote:
> From: lijian <lijian@yulong.com>
> 
> Macros starting with if should be enclosed by a do - while loop
> to avoid possible if/else logic defects.
> So modified the macro SET_VALID_IOCTL with do - while loop.
> 
> Signed-off-by: lijian <lijian@yulong.com>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus

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

end of thread, other threads:[~2021-05-25 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25  9:41 [PATCH] media: v4l2-dev.c: Modified the macro SET_VALID_IOCTL lijian_8010a29
2021-05-25 15:22 ` Sakari Ailus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.