* [PATCH 2/2] bindings: rust: Update bindgen's version
2023-02-14 6:45 [PATCH 1/2] bindings: rust: Align formatting to what's suggested by 'cargo fmt' Viresh Kumar
@ 2023-02-14 6:45 ` Viresh Kumar
2023-02-14 8:48 ` [PATCH 1/2] bindings: rust: Align formatting to what's suggested by 'cargo fmt' Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2023-02-14 6:45 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski
Cc: Viresh Kumar, Vincent Guittot, linux-gpio, Alex Bennée
The currently selected version of bindgen has a unmaintained dependency
and generates the following build warning while building vhost-device
crate:
Crate: ansi_term
Version: 0.12.1
Warning: unmaintained
Title: ansi_term is Unmaintained
Date: 2021-08-18
ID: RUSTSEC-2021-0139
URL: https://rustsec.org/advisories/RUSTSEC-2021-0139
Dependency tree:
ansi_term 0.12.1
└── clap 2.34.0
└── bindgen 0.59.2
└── libgpiod-sys 0.1.0
└── libgpiod 0.1.0
└── vhost-device-gpio 0.1.0
error: 1 denied warning found!
Fix it by moving to a later version of bindgen, which updates the types
of few of the arguments to the FFI helpers and so required changes to
few of explicit type conversions.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
bindings/rust/gpiosim-sys/Cargo.toml | 2 +-
bindings/rust/libgpiod-sys/Cargo.toml | 2 +-
bindings/rust/libgpiod/src/event_buffer.rs | 3 +--
bindings/rust/libgpiod/src/line_config.rs | 6 ++----
bindings/rust/libgpiod/src/line_request.rs | 8 ++++----
bindings/rust/libgpiod/src/request_config.rs | 4 ++--
6 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/bindings/rust/gpiosim-sys/Cargo.toml b/bindings/rust/gpiosim-sys/Cargo.toml
index c3571d2cf48e..9aa047feba82 100644
--- a/bindings/rust/gpiosim-sys/Cargo.toml
+++ b/bindings/rust/gpiosim-sys/Cargo.toml
@@ -19,5 +19,5 @@ errno = "0.2.8"
libgpiod = { path = "../libgpiod" }
[build-dependencies]
-bindgen = "0.59.1"
+bindgen = "0.63"
cc = "1.0.46"
diff --git a/bindings/rust/libgpiod-sys/Cargo.toml b/bindings/rust/libgpiod-sys/Cargo.toml
index 479184da3f7b..3bc3525aedca 100644
--- a/bindings/rust/libgpiod-sys/Cargo.toml
+++ b/bindings/rust/libgpiod-sys/Cargo.toml
@@ -17,5 +17,5 @@ edition = "2021"
[dependencies]
[build-dependencies]
-bindgen = "0.59.1"
+bindgen = "0.63"
cc = "1.0.46"
diff --git a/bindings/rust/libgpiod/src/event_buffer.rs b/bindings/rust/libgpiod/src/event_buffer.rs
index 5a72ddb197ac..0675ea6c5181 100644
--- a/bindings/rust/libgpiod/src/event_buffer.rs
+++ b/bindings/rust/libgpiod/src/event_buffer.rs
@@ -2,7 +2,6 @@
// SPDX-FileCopyrightText: 2022 Linaro Ltd.
// SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org>
-use std::os::raw::c_ulong;
use std::ptr;
use super::{
@@ -74,7 +73,7 @@ impl Buffer {
pub fn new(capacity: usize) -> Result<Self> {
// SAFETY: The `gpiod_edge_event_buffer` returned by libgpiod is guaranteed to live as long
// as the `struct Buffer`.
- let buffer = unsafe { gpiod::gpiod_edge_event_buffer_new(capacity as c_ulong) };
+ let buffer = unsafe { gpiod::gpiod_edge_event_buffer_new(capacity) };
if buffer.is_null() {
return Err(Error::OperationFailed(
OperationType::EdgeEventBufferNew,
diff --git a/bindings/rust/libgpiod/src/line_config.rs b/bindings/rust/libgpiod/src/line_config.rs
index 3848a3a68304..a2721a20e4fa 100644
--- a/bindings/rust/libgpiod/src/line_config.rs
+++ b/bindings/rust/libgpiod/src/line_config.rs
@@ -2,8 +2,6 @@
// SPDX-FileCopyrightText: 2022 Linaro Ltd.
// SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org>
-use std::os::raw::c_ulong;
-
use super::{
gpiod,
line::{Offset, Settings, SettingsMap, Value},
@@ -65,7 +63,7 @@ impl Config {
gpiod::gpiod_line_config_add_line_settings(
self.config,
offsets.as_ptr(),
- offsets.len() as c_ulong,
+ offsets.len(),
settings.settings,
)
};
@@ -91,7 +89,7 @@ impl Config {
gpiod::gpiod_line_config_set_output_values(
self.config,
mapped_values.as_ptr(),
- values.len() as u64,
+ values.len(),
)
};
diff --git a/bindings/rust/libgpiod/src/line_request.rs b/bindings/rust/libgpiod/src/line_request.rs
index a77c95deb1e3..ebf41f240ae2 100644
--- a/bindings/rust/libgpiod/src/line_request.rs
+++ b/bindings/rust/libgpiod/src/line_request.rs
@@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: 2022 Linaro Ltd.
// SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org>
-use std::os::{raw::c_ulong, unix::prelude::AsRawFd};
+use std::os::unix::prelude::AsRawFd;
use std::time::Duration;
use super::{
@@ -40,7 +40,7 @@ impl Request {
gpiod::gpiod_line_request_get_requested_offsets(
self.request,
offsets.as_mut_ptr(),
- self.num_lines() as u64,
+ self.num_lines(),
)
};
offsets.shrink_to(num_offsets as usize);
@@ -70,7 +70,7 @@ impl Request {
let ret = unsafe {
gpiod::gpiod_line_request_get_values_subset(
self.request,
- offsets.len() as c_ulong,
+ offsets.len(),
offsets.as_ptr(),
values.as_mut_ptr(),
)
@@ -127,7 +127,7 @@ impl Request {
let ret = unsafe {
gpiod::gpiod_line_request_set_values_subset(
self.request,
- offsets.len() as c_ulong,
+ offsets.len(),
offsets.as_ptr(),
values.as_ptr(),
)
diff --git a/bindings/rust/libgpiod/src/request_config.rs b/bindings/rust/libgpiod/src/request_config.rs
index 939838cbed2f..2ad68efdd12a 100644
--- a/bindings/rust/libgpiod/src/request_config.rs
+++ b/bindings/rust/libgpiod/src/request_config.rs
@@ -3,7 +3,7 @@
// SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org>
use std::ffi::{CStr, CString};
-use std::os::raw::{c_char, c_ulong};
+use std::os::raw::c_char;
use std::str;
use super::{gpiod, Error, OperationType, Result};
@@ -75,7 +75,7 @@ impl Config {
/// Set the size of the kernel event buffer for the request.
pub fn set_event_buffer_size(&mut self, size: usize) -> &mut Self {
// SAFETY: `gpiod_request_config` is guaranteed to be valid here.
- unsafe { gpiod::gpiod_request_config_set_event_buffer_size(self.config, size as c_ulong) }
+ unsafe { gpiod::gpiod_request_config_set_event_buffer_size(self.config, size) }
self
}
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] bindings: rust: Align formatting to what's suggested by 'cargo fmt'
2023-02-14 6:45 [PATCH 1/2] bindings: rust: Align formatting to what's suggested by 'cargo fmt' Viresh Kumar
2023-02-14 6:45 ` [PATCH 2/2] bindings: rust: Update bindgen's version Viresh Kumar
@ 2023-02-14 8:48 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2023-02-14 8:48 UTC (permalink / raw)
To: Viresh Kumar; +Cc: Linus Walleij, Vincent Guittot, linux-gpio, Alex Bennée
On Tue, Feb 14, 2023 at 7:45 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> Align code to follow what 'cargo fmt' suggests.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> bindings/rust/libgpiod/src/line_config.rs | 13 ++++++++++---
> bindings/rust/libgpiod/tests/line_config.rs | 4 ++--
> bindings/rust/libgpiod/tests/line_request.rs | 6 ++++--
> 3 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/bindings/rust/libgpiod/src/line_config.rs b/bindings/rust/libgpiod/src/line_config.rs
> index 6ddcec336da2..3848a3a68304 100644
> --- a/bindings/rust/libgpiod/src/line_config.rs
> +++ b/bindings/rust/libgpiod/src/line_config.rs
> @@ -55,7 +55,11 @@ impl Config {
> }
>
> /// Add line settings for a set of offsets.
> - pub fn add_line_settings(&mut self, offsets: &[Offset], settings: Settings) -> Result<&mut Self> {
> + pub fn add_line_settings(
> + &mut self,
> + offsets: &[Offset],
> + settings: Settings,
> + ) -> Result<&mut Self> {
> // SAFETY: `gpiod_line_config` is guaranteed to be valid here.
> let ret = unsafe {
> gpiod::gpiod_line_config_add_line_settings(
> @@ -84,8 +88,11 @@ impl Config {
> }
>
> let ret = unsafe {
> - gpiod::gpiod_line_config_set_output_values(self.config, mapped_values.as_ptr(),
> - values.len() as u64)
> + gpiod::gpiod_line_config_set_output_values(
> + self.config,
> + mapped_values.as_ptr(),
> + values.len() as u64,
> + )
> };
>
> if ret == -1 {
> diff --git a/bindings/rust/libgpiod/tests/line_config.rs b/bindings/rust/libgpiod/tests/line_config.rs
> index 6e8962cf686c..b5a04ef8949a 100644
> --- a/bindings/rust/libgpiod/tests/line_config.rs
> +++ b/bindings/rust/libgpiod/tests/line_config.rs
> @@ -5,11 +5,11 @@
> mod common;
>
> mod line_config {
> + use gpiosim_sys::Sim;
> use libgpiod::chip::Chip;
> use libgpiod::line::{
> self, Bias, Direction, Drive, Edge, EventClock, SettingKind, SettingVal, Value,
> };
> - use gpiosim_sys::Sim;
>
> #[test]
> fn settings() {
> @@ -93,7 +93,7 @@ mod line_config {
> Value::Active,
> Value::InActive,
> Value::Active,
> - Value::InActive
> + Value::InActive,
> ])
> .unwrap();
>
> diff --git a/bindings/rust/libgpiod/tests/line_request.rs b/bindings/rust/libgpiod/tests/line_request.rs
> index 8ec497f83406..d60e15a7a106 100644
> --- a/bindings/rust/libgpiod/tests/line_request.rs
> +++ b/bindings/rust/libgpiod/tests/line_request.rs
> @@ -181,7 +181,8 @@ mod line_request {
> assert_eq!(config.sim_val(4).unwrap(), SimValue::InActive);
>
> // Set all values
> - config.request()
> + config
> + .request()
> .set_values(&[
> Value::Active,
> Value::InActive,
> @@ -193,7 +194,8 @@ mod line_request {
> assert_eq!(config.sim_val(1).unwrap(), SimValue::InActive);
> assert_eq!(config.sim_val(3).unwrap(), SimValue::Active);
> assert_eq!(config.sim_val(4).unwrap(), SimValue::InActive);
> - config.request()
> + config
> + .request()
> .set_values(&[
> Value::InActive,
> Value::InActive,
> --
> 2.31.1.272.g89b43f80a514
>
Both patches applied, thanks!
Bart
^ permalink raw reply [flat|nested] 3+ messages in thread