From: Hans Verkuil <hverkuil@xs4all.nl>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH] v4l2-subdev.h: v4l2_subdev_call: use temp __sd variable
Date: Fri, 8 Feb 2019 10:08:22 +0100 [thread overview]
Message-ID: <e958128c-cc9a-5c99-9871-91c192fb55fd@xs4all.nl> (raw)
In-Reply-To: <20190208090629.vta7rf2vvpzftgsp@paasikivi.fi.intel.com>
On 2/8/19 10:06 AM, Sakari Ailus wrote:
> On Fri, Feb 08, 2019 at 09:49:23AM +0100, Hans Verkuil wrote:
>> 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>
>
> Nice one!
>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>
> I wonder if this addresses some of the sparse issues related to using a
> macro to come up with sd?
It does solve those as well, in fact :-)
I rejected the omap3/4 patches in favor of this one, which is a much, much
cleaner solution.
Regards,
Hans
>
>> ---
>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>> index 47af609dc8f1..34da094a3f40 100644
>> --- a/include/media/v4l2-subdev.h
>> +++ b/include/media/v4l2-subdev.h
>> @@ -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; \
>> })
>>
>
next prev parent reply other threads:[~2019-02-08 9:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 8:49 [PATCH] v4l2-subdev.h: v4l2_subdev_call: use temp __sd variable Hans Verkuil
2019-02-08 9:06 ` Sakari Ailus
2019-02-08 9:08 ` Hans Verkuil [this message]
2019-02-08 10:37 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e958128c-cc9a-5c99-9871-91c192fb55fd@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).