All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Greg KH <gregkh@suse.de>
Cc: Greg KH <greg@kroah.com>, Jonathan Cameron <jic23@kernel.org>,
	devel@driverdev.osuosl.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH] staging:iio: Add wrapper functions around buffer access ops
Date: Wed, 14 Dec 2011 18:35:25 +0100	[thread overview]
Message-ID: <4EE8DE5D.3080504@metafoo.de> (raw)
In-Reply-To: <20111214154932.GA24002@suse.de>

On 12/14/2011 04:49 PM, Greg KH wrote:
> On Wed, Dec 14, 2011 at 11:15:49AM +0100, Lars-Peter Clausen wrote:
>> On 12/14/2011 12:59 AM, Greg KH wrote:
>>>
>>>>>> +static inline int buffer_get_length(struct iio_buffer *buffer)
>>>>>> +{
>>>>>> +	if (buffer->access->get_length)
>>>>>> +		return buffer->access->get_length(buffer);
>>>>>> +
>>>>>> +	return -ENOSYS;
>>>>>
>>>>> Here you return an error, but why ENOSYS?
>>>>>
>>>>> Consistancy is key, and you don't have it here at all.  Or if you do, I
>>>>> sure don't understand it...
>>>>
>>>> Well, different types of functions require different semantics. While the
>>>> previous ones did either return 0 in case of success or a error value in case
>>>> of an error, buffer_get_length returns an integer value where 0 is a valid
>>>> value. Since we can't make any meaningful assumptions about the buffer size if
>>>> the callback is not implemented we return an error value. Why ENOSYS? Because
>>>> it is the code for 'function not implemented' and is used throughout the kernel
>>>> in similar situations.
>>>
>>> Is the caller always supposed to check this?  If so, please mark the
>>> function as such so the compiler will complain if it isn't.
>>
>> Marking the function as __must_check doesn't make much sense here. Since it
>> will either return an error or the buffer length. So you'll always use the
>> returned result one way or the other.
> 
> That's exactly the point, you must use it, so mark it as such.
> 
So by that logic all functions without side effects should be marked as
__must_check?

- Lars

      reply	other threads:[~2011-12-14 17:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-12 10:08 [PATCH] staging:iio: Add wrapper functions around buffer access ops Lars-Peter Clausen
2011-12-13  0:45 ` Greg KH
2011-12-13  9:01   ` Lars-Peter Clausen
2011-12-13 23:59     ` Greg KH
2011-12-14  7:19       ` Jonathan Cameron
2011-12-14 10:15       ` Lars-Peter Clausen
2011-12-14 14:31         ` Dan Carpenter
2011-12-14 15:05           ` Lars-Peter Clausen
2011-12-14 16:42             ` Dan Carpenter
2011-12-14 15:49         ` Greg KH
2011-12-14 17:35           ` Lars-Peter Clausen [this message]

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=4EE8DE5D.3080504@metafoo.de \
    --to=lars@metafoo.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.