From: Kent Gibson <warthog618@gmail.com>
To: Gary Guo <gary@garyguo.net>
Cc: "Bartosz Golaszewski" <brgl@bgdev.pl>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
linux-gpio@vger.kernel.org,
"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
stratos-dev@op-lists.linaro.org,
"Gerard Ryan" <g.m0n3y.2503@gmail.com>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
y86-dev <y86-dev@protonmail.com>
Subject: Re: [libgpiod][PATCH V9 0/8] libgpiod: Add Rust bindings
Date: Sat, 19 Nov 2022 01:24:48 +0800 [thread overview]
Message-ID: <Y3e/4Fu4kN1ved/C@sol> (raw)
In-Reply-To: <20221118164456.44f448e8@GaryWorkstation>
On Fri, Nov 18, 2022 at 04:44:56PM +0000, Gary Guo wrote:
> On Wed, 16 Nov 2022 09:12:01 +0800
> Kent Gibson <warthog618@gmail.com> wrote:
>
> > On Mon, Nov 14, 2022 at 10:49:36PM +0100, Bartosz Golaszewski wrote:
> > > On Mon, Nov 7, 2022 at 10:57 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > > >
> > > > Hello,
> > > >
> > > > Here is another version of the rust bindings, based of the master branch.
> > > >
> > > > Pushed here:
> > > >
> > > > https://github.com/vireshk/libgpiod v9
> > > >
> > > > V8->V9:
> > > > - Merged the last patch (supporting Events) with the other patches.
> > > > - Events implementation is simplified and made efficient. nth() is also
> > > > implemented for the iterator.
> > > > - Unnecessary comment removed from Cargo.toml files.
> > > > - Updated categories in libgpiod's Cargo.toml.
> > > > - Updated gpio_events example to show cloned events live past another
> > > > read_edge_events().
> > > > - Implement AsRawFd for Chip.
> > > > - Other minor changes.
> > > >
> > >
> > > Kent, Miguel: if you are ok with this version - can you add your review tags?
> > >
> > > Bart
> >
> > As mentioned elsewhere, I'm a bit iffy about the handling of non-UTF-8
> > names, which are treated as errors, but are valid in the C API.
> > But that is an extreme corner case that can be addressed later, so I have
> > no objection to this version being merged.
> >
> > Reviewed-by: Kent Gibson <warthog618@gmail.com>
> >
> > Cheers,
> > Kent.
>
> I have glanced through the code and I find no reason that the `str` used
> couldn't be replaced with `[u8]` or `OsStr`. The former might be a
> little bit difficult to use, but `OsStr` could be easily converted into
> `str` by just `.to_str().expect("name should be utf-8")` if the user
> don't care about non-UTF-8 or is certain that names are indeed UTF-8.
>
Or you can use `OsStr::to_string_lossy()` though that requires allocation.
str is preferable as it is easer to use, and 99.99% of the time will be
fine. I have toyed with using OsStr, but having to do the conversion
becomes really tedious really fast.
> I am not sure about whether this would be worthwhile though, because I
> doubt if anyone is actually using non-UTF-8 strings in those places.
> Non-ASCII usages should already be rare?
>
That is what I meant by "an extreme corner case".
The problem with the GPIO uAPI is that it limits names to 32 bytes,
and valid UTF-8 passed in may get truncated mid-codepoint, resulting in
invalid UTF-8 when read back.
Handling that case by truncating the string before the split codepoint
would at least ensure that the Rust API would round-trip.
Cheers,
Kent.
next prev parent reply other threads:[~2022-11-18 17:24 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 9:57 [libgpiod][PATCH V9 0/8] libgpiod: Add Rust bindings Viresh Kumar
2022-11-07 9:57 ` [libgpiod][PATCH V9 1/8] bindings: rust: Add libgpiod-sys rust crate Viresh Kumar
2022-11-09 9:07 ` Bartosz Golaszewski
2022-11-14 10:04 ` Viresh Kumar
2022-11-14 10:30 ` Bartosz Golaszewski
2022-11-07 9:57 ` [libgpiod][PATCH V9 2/8] bindings: rust: Add pre generated bindings for libgpiod-sys Viresh Kumar
2022-11-07 9:57 ` [libgpiod][PATCH V9 3/8] bindings: rust: Add gpiosim crate Viresh Kumar
2022-11-07 9:57 ` [libgpiod][PATCH V9 4/8] bindings: rust: Add pre generated bindings for gpiosim Viresh Kumar
2022-11-07 9:57 ` [libgpiod][PATCH V9 5/8] bindings: rust: Add libgpiod crate Viresh Kumar
2022-11-07 9:57 ` [libgpiod][PATCH V9 6/8] bindings: rust: Add examples to " Viresh Kumar
2022-11-10 18:26 ` Bartosz Golaszewski
2022-11-14 10:03 ` Viresh Kumar
2022-11-14 10:29 ` Bartosz Golaszewski
2022-11-14 10:42 ` Viresh Kumar
2022-11-07 9:57 ` [libgpiod][PATCH V9 7/8] bindings: rust: Add tests for " Viresh Kumar
2022-11-09 9:30 ` Bartosz Golaszewski
2022-11-09 9:50 ` Kent Gibson
2022-11-09 10:36 ` Kent Gibson
2022-11-09 9:54 ` Linus Walleij
2022-11-09 10:12 ` Björn Roy Baron
2022-11-07 9:57 ` [libgpiod][PATCH V9 8/8] bindings: rust: Integrate building of bindings with make Viresh Kumar
2022-11-14 21:49 ` [libgpiod][PATCH V9 0/8] libgpiod: Add Rust bindings Bartosz Golaszewski
2022-11-16 1:12 ` Kent Gibson
2022-11-18 16:44 ` Gary Guo
2022-11-18 17:24 ` Kent Gibson [this message]
2022-11-16 10:29 ` Bartosz Golaszewski
2022-11-17 7:31 ` Viresh Kumar
2022-11-17 9:06 ` Bartosz Golaszewski
2022-11-17 9:56 ` Viresh Kumar
2022-11-17 10:18 ` Bartosz Golaszewski
2022-11-17 10:40 ` Viresh Kumar
2022-11-17 10:48 ` Bartosz Golaszewski
2022-11-17 10:55 ` Viresh Kumar
2022-11-17 11:05 ` Bartosz Golaszewski
2022-11-17 11:15 ` Viresh Kumar
2022-11-17 12:32 ` Bartosz Golaszewski
2022-11-17 10:51 ` Miguel Ojeda
2022-11-17 11:04 ` Viresh Kumar
2022-11-17 11:07 ` Miguel Ojeda
2022-11-17 11:15 ` Bartosz Golaszewski
2022-11-17 11:25 ` Viresh Kumar
2022-11-17 12:18 ` Bartosz Golaszewski
2022-11-18 9:35 ` Viresh Kumar
2022-11-18 9:38 ` Bartosz Golaszewski
2022-11-18 9:41 ` Viresh Kumar
2022-11-18 9:42 ` Bartosz Golaszewski
2022-11-17 13:05 ` Kent Gibson
2022-11-17 8:12 ` Linus Walleij
2022-11-17 8:37 ` Bartosz Golaszewski
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=Y3e/4Fu4kN1ved/C@sol \
--to=warthog618@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=alex.gaynor@gmail.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brgl@bgdev.pl \
--cc=g.m0n3y.2503@gmail.com \
--cc=gary@garyguo.net \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=stratos-dev@op-lists.linaro.org \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
--cc=wedsonaf@gmail.com \
--cc=y86-dev@protonmail.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).