linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>
Subject: Re: [libgpiod][RFC v2] core: implement v2.0 API
Date: Sat, 29 May 2021 13:10:24 +0800	[thread overview]
Message-ID: <20210529051024.GA18025@sol> (raw)
In-Reply-To: <20210528232320.GA5165@sol>

On Sat, May 29, 2021 at 07:23:20AM +0800, Kent Gibson wrote:
> On Fri, May 28, 2021 at 03:51:03PM +0200, Bartosz Golaszewski wrote:
> > On Thu, May 27, 2021 at 1:27 PM Kent Gibson <warthog618@gmail.com> wrote:
> > >

<snip>

> > > >  /**
> > > > - * @brief Get the handle to the GPIO chip controlling this line.
> > > > - * @param line The GPIO line object.
> > > > - * @return Pointer to the GPIO chip handle controlling this line.
> > > > + * @brief Get the pointer to the line-info object associated with this event.
> > > > + * @param event Line info event object.
> > > > + * @return Returns a pointer to the line-info object associated with this event
> > > > + *         whose lifetime is tied to the event object. It must not be freed by
> > > > + *         the caller.
> > > >   */
> > > > -struct gpiod_chip *gpiod_line_get_chip(struct gpiod_line *line);
> > > > +struct gpiod_line_info *
> > > > +gpiod_info_event_peek_line_info(struct gpiod_info_event *event);
> > > > +
> > >
> > > Rather than the peek/copy you use here, I would rename the peek to
> > > get...
> > 
> > Ha! I think we'll disagree here again. In most cases in low-level
> > linux C libraries, a "get" for complex objects returns a copy (or a
> > new reference if we're using shared objects). I would like to stay
> > consistent with that pattern. To me "peek" is a good way to
> > distinguish those functions that allow you to look into the internals
> > of the parent object. If anything - I'd go with the get/peek pattern
> > where the former returns a new object over whose lifetime the caller
> > takes responsibility and the latter returns a pointer to an object
> > stored in the parent. I went with copy/peek because it hints at a
> > different behavior than regular get but I can live with get/peek.
> > 
> 

I forgot to ask about where gpiod_line_info_get_name() and others that
return char * fit wrt that pattern.
So a string isn't a complex object?
Maybe they should be _peek_ as well?
Either way, it would be nice for their commentary to describe the lifetime
of the returned pointer.

Cheers,
Kent.

  reply	other threads:[~2021-05-29  5:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 19:18 [libgpiod][RFC v2] core: implement v2.0 API Bartosz Golaszewski
2021-05-27 11:27 ` Kent Gibson
2021-05-28 13:51   ` Bartosz Golaszewski
2021-05-28 23:23     ` Kent Gibson
2021-05-29  5:10       ` Kent Gibson [this message]
2021-05-29 18:19       ` Bartosz Golaszewski
2021-05-30  0:45         ` Kent Gibson
2021-06-01 19:57           ` Bartosz Golaszewski
2021-06-02  3:12             ` Kent Gibson
2021-06-02  8:36               ` Bartosz Golaszewski
2021-06-02 10:43                 ` Kent Gibson
2021-05-30  1:27         ` Kent Gibson

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=20210529051024.GA18025@sol \
    --to=warthog618@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@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 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).