]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: v4l2-subdev.h: v4l2_subdev_call: use temp __sd variable
authorHans Verkuil <hverkuil@xs4all.nl>
Fri, 8 Feb 2019 08:49:23 +0000 (03:49 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 18 Feb 2019 15:58:59 +0000 (10:58 -0500)
The sd argument of this macro can be a more complex expression. Since it
is used 5 times in the macro it can be evaluated that many times as well.

So assign it to a temp variable in the beginning and use that instead.

This also avoids any potential side-effects of evaluating sd.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
include/media/v4l2-subdev.h

index 47af609dc8f10764a9ced6bc608b587e473a5a9b..34da094a3f40573719a6456036b9739bf70104fd 100644 (file)
@@ -1093,13 +1093,14 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
  */
 #define v4l2_subdev_call(sd, o, f, args...)                            \
        ({                                                              \
+               struct v4l2_subdev *__sd = (sd);                        \
                int __result;                                           \
-               if (!(sd))                                              \
+               if (!__sd)                                              \
                        __result = -ENODEV;                             \
-               else if (!((sd)->ops->o && (sd)->ops->o->f))            \
+               else if (!(__sd->ops->o && __sd->ops->o->f))            \
                        __result = -ENOIOCTLCMD;                        \
                else                                                    \
-                       __result = (sd)->ops->o->f((sd), ##args);       \
+                       __result = __sd->ops->o->f(__sd, ##args);       \
                __result;                                               \
        })