Re: [libgpiod][PATCH] bindings: rust: fix clippy lint warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, got distracted while sorting out the MSRV mess that I sent a
separate patch for [4].

On Wed Jun 14, 2023 at 10:29 AM CEST, Kent Gibson wrote:
> On Wed, Jun 14, 2023 at 10:14:08AM +0200, Erik Schilling wrote:
> > On Mon Jun 12, 2023 at 5:40 PM CEST, Kent Gibson wrote:
> > > clippy from Rust 1.70 reports a host of warnings due to casting and type
> > > conversions across the FFI interface to libgpiod.
> > > These casts and conversions are required to support old versions of Rust
> > > that do not support recent Rust FFI extensions.
> > 
> > Could you elaborate which extensions are relevant here? Would it be
> > realistic to just update the minimum Rust version instead of needing
> > to include these suppression directives?
> > 
>
> Types were added in core::ffi[1] in 1.64 for just this purpose.
> e.g. c_uint[2]
> Though c_size_t[3] still remains in Experimental.
>
> [1] https://doc.rust-lang.org/stable/core/ffi/index.html
> [2] https://doc.rust-lang.org/stable/core/ffi/type.c_uint.html
> [3] https://doc.rust-lang.org/stable/core/ffi/type.c_size_t.html

I do not think that this is the reason why we need the casts...
bindgen generates bindings using std::os::raw::c_uint [5] which is
stable since 1.1.0 (and was previously defined as u32 [6]). I think we
can just drop the casts entirely? I can run cargo clippy --fix on latest
stable (1.70.0), then go back to 1.60 and everything is still building.
I am having trouble to execute the tests in that version due to some
linkage errors, but that should not be the fault of the casts.

Did I got this correct or am I misunderstanding your reasoning?

Note: One needs to fix a bug that cargo clippy --fix introduces since
it replaces nth(0) with next() in event_buffers.rs and introduces a
unconditional recursion.

[4] https://lore.kernel.org/r/20230616-msrv-v1-1-1f0ca25b8222@xxxxxxxxxx/
[5] https://doc.rust-lang.org/stable/std/os/raw/type.c_uint.html
[6] https://doc.rust-lang.org/1.60.0/std/os/raw/type.c_uint.html

- Erik





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux