public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: "Nuno Sá" <nuno.sa@analog.com>, linux-iio@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [RFC PATCH 1/1] iio: buffer: Sanity check buffer callback
Date: Thu, 12 Nov 2020 17:15:57 +0100	[thread overview]
Message-ID: <e8da8110-d029-fa1d-1732-e147e30e2850@metafoo.de> (raw)
In-Reply-To: <20201112151334.32167-2-nuno.sa@analog.com>

On 11/12/20 4:13 PM, Nuno Sá wrote:
> Make sure that a callback is actually present before trying to call
> it...
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>   drivers/iio/buffer/industrialio-buffer-cb.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
> index 47c96f7f4976..b4385f59399d 100644
> --- a/drivers/iio/buffer/industrialio-buffer-cb.c
> +++ b/drivers/iio/buffer/industrialio-buffer-cb.c
> @@ -27,6 +27,10 @@ static struct iio_cb_buffer *buffer_to_cb_buffer(struct iio_buffer *buffer)
>   static int iio_buffer_cb_store_to(struct iio_buffer *buffer, const void *data)
>   {
>   	struct iio_cb_buffer *cb_buff = buffer_to_cb_buffer(buffer);
> +
> +	if (!cb_buff->cb)
> +		return 0;
> +
I think it makes more sense to check this once when the buffer is 
registered instead of every time we want to call the function.

  reply	other threads:[~2020-11-12 16:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 15:13 [RFC PATCH 0/1] Sanity check buffer callback Nuno Sá
2020-11-12 15:13 ` [RFC PATCH 1/1] iio: buffer: " Nuno Sá
2020-11-12 16:15   ` Lars-Peter Clausen [this message]
2020-11-12 16:20     ` Lars-Peter Clausen
2020-11-14 16:33 ` [RFC PATCH 0/1] " Jonathan Cameron
2020-11-16 16:49   ` Olivier MOYSAN

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=e8da8110-d029-fa1d-1732-e147e30e2850@metafoo.de \
    --to=lars@metafoo.de \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=pmeerw@pmeerw.net \
    /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