public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, pawel@osciak.com,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [REVIEW PATCH for v3.15 1/4] v4l2-subdev.h: fix sparse error with v4l2_subdev_notify
Date: Mon, 17 Mar 2014 12:45:16 +0100	[thread overview]
Message-ID: <5326E04C.5050808@xs4all.nl> (raw)
In-Reply-To: <2510988.dElkAvpb7d@avalon>

On 03/17/2014 12:44 PM, Laurent Pinchart wrote:
> Hi Hans,
> 
> Thank you for the patch.
> 
> On Saturday 15 March 2014 14:08:00 Hans Verkuil wrote:
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> The notify function is a void function, yet the v4l2_subdev_notify
>> define uses it in a ? : construction, which causes sparse warnings.
>>
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>> ---
>>  include/media/v4l2-subdev.h | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>> index 28f4d8c..0fbf669 100644
>> --- a/include/media/v4l2-subdev.h
>> +++ b/include/media/v4l2-subdev.h
>> @@ -692,9 +692,11 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
>>  		(sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD))
>>
>>  /* Send a notification to v4l2_device. */
>> -#define v4l2_subdev_notify(sd, notification, arg)			   \
>> -	((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
>> -	 (sd)->v4l2_dev->notify((sd), (notification), (arg)))
>> +#define v4l2_subdev_notify(sd, notification, arg)				\
>> +	do {									\
>> +		if ((sd) && (sd)->v4l2_dev && (sd)->v4l2_dev->notify)		\
>> +			(sd)->v4l2_dev->notify((sd), (notification), (arg));	\
>> +	} while (0)
> 
> The construct would prevent using v4l2_subdev_notify() as an expression. What 
> about turning the macro into an inline function instead ?

How can you use a void function in an expression anyway? That was the whole point
of the sparse error.

Regards,

	Hans

> 
>>  #define v4l2_subdev_has_op(sd, o, f) \
>>  	((sd)->ops->o && (sd)->ops->o->f)
> 


  reply	other threads:[~2014-03-17 11:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-15 13:07 [REVIEW PATCH for v3.15 0/4] v4l2 core sparse error/warning fixes Hans Verkuil
2014-03-15 13:08 ` [REVIEW PATCH for v3.15 1/4] v4l2-subdev.h: fix sparse error with v4l2_subdev_notify Hans Verkuil
2014-03-17 11:44   ` Laurent Pinchart
2014-03-17 11:45     ` Hans Verkuil [this message]
2014-03-17 11:49       ` Laurent Pinchart
2014-03-15 13:08 ` [REVIEW PATCH for v3.15 2/4] videobuf2-core: fix sparse errors Hans Verkuil
2014-03-17 10:20   ` Pawel Osciak
2014-03-15 13:08 ` [REVIEW PATCH for v3.15 3/4] v4l2-common.h: remove __user annotation in struct v4l2_edid Hans Verkuil
2014-03-15 13:08 ` [REVIEW PATCH for v3.15 4/4] v4l2-ioctl.c: fix sparse __user-related warnings Hans Verkuil
2014-03-17 11:59   ` 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=5326E04C.5050808@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=hans.verkuil@cisco.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=pawel@osciak.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