Skip to content

Commit 3d769df

Browse files
Hans Verkuilmchehab
authored andcommitted
media: v4l2-subdev.h: v4l2_subdev_call: use temp __sd variable
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>
1 parent 5515e41 commit 3d769df

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎include/media/v4l2-subdev.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,13 +1093,14 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
10931093
*/
10941094
#define v4l2_subdev_call(sd, o, f, args...) \
10951095
({ \
1096+
struct v4l2_subdev *__sd = (sd); \
10961097
int __result; \
1097-
if (!(sd)) \
1098+
if (!__sd) \
10981099
__result = -ENODEV; \
1099-
else if (!((sd)->ops->o && (sd)->ops->o->f)) \
1100+
else if (!(__sd->ops->o && __sd->ops->o->f)) \
11001101
__result = -ENOIOCTLCMD; \
11011102
else \
1102-
__result = (sd)->ops->o->f((sd), ##args); \
1103+
__result = __sd->ops->o->f(__sd, ##args); \
11031104
__result; \
11041105
})
11051106

0 commit comments

Comments
 (0)