* [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings
@ 2025-07-21 7:53 Erik Wierich
2025-07-21 7:53 ` [PATCH libgpiod 1/2] bindings: rust: remove newline between attribute and attribute Erik Wierich
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Erik Wierich @ 2025-07-21 7:53 UTC (permalink / raw)
To: Linux-GPIO, Bartosz Golaszewski, Viresh Kumar; +Cc: Erik Wierich
This fixes warnings reported by clippy 0.1.88.
Signed-off-by: Erik Wierich <erik@riscstar.com>
---
Erik Wierich (2):
bindings: rust: remove newline between attribute and attribute
bindings: rust: simplify format statements
bindings/rust/libgpiod-sys/src/lib.rs | 1 -
bindings/rust/libgpiod/examples/find_line_by_name.rs | 2 +-
bindings/rust/libgpiod/examples/get_line_info.rs | 3 +--
bindings/rust/libgpiod/examples/get_line_value.rs | 2 +-
bindings/rust/libgpiod/examples/get_multiple_line_values.rs | 2 +-
bindings/rust/libgpiod/examples/reconfigure_input_to_output.rs | 4 ++--
bindings/rust/libgpiod/examples/toggle_line_value.rs | 2 +-
bindings/rust/libgpiod/src/lib.rs | 4 ++--
8 files changed, 9 insertions(+), 11 deletions(-)
---
base-commit: e4427590d9d63a7104dd5df564dd6b7b0c784547
change-id: 20250721-rust-clippy-df73580f6624
Best regards,
--
Erik Wierich <erik@riscstar.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH libgpiod 1/2] bindings: rust: remove newline between attribute and attribute
2025-07-21 7:53 [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings Erik Wierich
@ 2025-07-21 7:53 ` Erik Wierich
2025-07-21 7:53 ` [PATCH libgpiod 2/2] bindings: rust: simplify format statements Erik Wierich
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Erik Wierich @ 2025-07-21 7:53 UTC (permalink / raw)
To: Linux-GPIO, Bartosz Golaszewski, Viresh Kumar; +Cc: Erik Wierich
These are block attributes, but the newline in between suggests that
they are for the whole module.
Fixes clippy warning:
warning: empty line after outer attribute
--> libgpiod-sys/src/lib.rs:6:1
|
6 | / #[cfg_attr(test, allow(deref_nullptr, non_snake_case))]
7 | |
| |_^
8 | mod bindings_raw {
| ---------------- the attribute applies to this module
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
= note: `#[warn(clippy::empty_line_after_outer_attr)]` on by default
= help: if the empty line is unintentional, remove it
help: if the attribute should apply to the crate use an inner attribute
|
5 ~ #![allow(non_camel_case_types, non_upper_case_globals)]
6 ~ #![cfg_attr(test, allow(deref_nullptr, non_snake_case))]
|
Signed-off-by: Erik Wierich <erik@riscstar.com>
---
bindings/rust/libgpiod-sys/src/lib.rs | 1 -
1 file changed, 1 deletion(-)
diff --git a/bindings/rust/libgpiod-sys/src/lib.rs b/bindings/rust/libgpiod-sys/src/lib.rs
index 06f1a50c2753048a22617c480396a156af801321..93b1e7683b0518b5777500d675c68db7184221aa 100644
--- a/bindings/rust/libgpiod-sys/src/lib.rs
+++ b/bindings/rust/libgpiod-sys/src/lib.rs
@@ -1,11 +1,10 @@
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
// SPDX-FileCopyrightText: 2022 Linaro Ltd.
// SPDX-FileCopyrightText: 2022 Viresh Kumar <viresh.kumar@linaro.org>
#[allow(non_camel_case_types, non_upper_case_globals)]
#[cfg_attr(test, allow(deref_nullptr, non_snake_case))]
-
mod bindings_raw {
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
pub use bindings_raw::*;
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH libgpiod 2/2] bindings: rust: simplify format statements
2025-07-21 7:53 [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings Erik Wierich
2025-07-21 7:53 ` [PATCH libgpiod 1/2] bindings: rust: remove newline between attribute and attribute Erik Wierich
@ 2025-07-21 7:53 ` Erik Wierich
2025-07-21 7:55 ` [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings Viresh Kumar
2025-07-21 13:20 ` Bartosz Golaszewski
3 siblings, 0 replies; 5+ messages in thread
From: Erik Wierich @ 2025-07-21 7:53 UTC (permalink / raw)
To: Linux-GPIO, Bartosz Golaszewski, Viresh Kumar; +Cc: Erik Wierich
clippy suggested these:
warning: variables can be used directly in the `format!` string
--> libgpiod/src/lib.rs:113:9
|
113 | write!(f, "{:?}", self)
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
= note: `#[warn(clippy::uninlined_format_args)]` on by default
help: change this to
|
113 - write!(f, "{:?}", self)
113 + write!(f, "{self:?}")
|
Generated with `cargo clippy --fix`.
The suggestions look like an improvement to me.
Signed-off-by: Erik Wierich <erik@riscstar.com>
---
bindings/rust/libgpiod/examples/find_line_by_name.rs | 2 +-
bindings/rust/libgpiod/examples/get_line_info.rs | 3 +--
bindings/rust/libgpiod/examples/get_line_value.rs | 2 +-
bindings/rust/libgpiod/examples/get_multiple_line_values.rs | 2 +-
bindings/rust/libgpiod/examples/reconfigure_input_to_output.rs | 4 ++--
bindings/rust/libgpiod/examples/toggle_line_value.rs | 2 +-
bindings/rust/libgpiod/src/lib.rs | 4 ++--
7 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/bindings/rust/libgpiod/examples/find_line_by_name.rs b/bindings/rust/libgpiod/examples/find_line_by_name.rs
index f7b991933b44c8bd107507a9a5322e4cf8bdc312..6d6a37b083efce4c61ecfb8c57292c4ee299466c 100644
--- a/bindings/rust/libgpiod/examples/find_line_by_name.rs
+++ b/bindings/rust/libgpiod/examples/find_line_by_name.rs
@@ -20,10 +20,10 @@ fn main() -> libgpiod::Result<()> {
info.name()?,
offset?
);
return Ok(());
}
}
- println!("line '{}' not found", line_name);
+ println!("line '{line_name}' not found");
Ok(())
}
diff --git a/bindings/rust/libgpiod/examples/get_line_info.rs b/bindings/rust/libgpiod/examples/get_line_info.rs
index 086db90dbc1af97203ac54f3aa3abc108216cd19..7fb91a0cffaf5d7419722e9c503ab75cef44488a 100644
--- a/bindings/rust/libgpiod/examples/get_line_info.rs
+++ b/bindings/rust/libgpiod/examples/get_line_info.rs
@@ -25,13 +25,12 @@ fn main() -> libgpiod::Result<()> {
let low = if info.is_active_low() {
"active-low"
} else {
"active-high"
};
println!(
- "line {:>3}: {:>12} {:>12} {:>8} {:>10}",
- line_offset, name, consumer, dir, low
+ "line {line_offset:>3}: {name:>12} {consumer:>12} {dir:>8} {low:>10}"
);
Ok(())
}
diff --git a/bindings/rust/libgpiod/examples/get_line_value.rs b/bindings/rust/libgpiod/examples/get_line_value.rs
index 39141e23363d6a026c0e5f748f72b1b8e5c583c6..e1ef6c7896c3671667119a256d14e930a291d532 100644
--- a/bindings/rust/libgpiod/examples/get_line_value.rs
+++ b/bindings/rust/libgpiod/examples/get_line_value.rs
@@ -19,10 +19,10 @@ fn main() -> libgpiod::Result<()> {
let mut rconfig = libgpiod::request::Config::new()?;
rconfig.set_consumer("get-line-value")?;
let chip = libgpiod::chip::Chip::open(&chip_path)?;
let request = chip.request_lines(Some(&rconfig), &lconfig)?;
let value = request.value(line_offset)?;
- println!("{}={:?}", line_offset, value);
+ println!("{line_offset}={value:?}");
Ok(())
}
diff --git a/bindings/rust/libgpiod/examples/get_multiple_line_values.rs b/bindings/rust/libgpiod/examples/get_multiple_line_values.rs
index a1be5a6e670b41534a65f7435d99185d832a894d..b09f3be033246c61cda43bd0e947ba34bb421642 100644
--- a/bindings/rust/libgpiod/examples/get_multiple_line_values.rs
+++ b/bindings/rust/libgpiod/examples/get_multiple_line_values.rs
@@ -20,10 +20,10 @@ fn main() -> libgpiod::Result<()> {
let mut rconfig = libgpiod::request::Config::new()?;
rconfig.set_consumer("get-multiple-line-values")?;
let request = chip.request_lines(Some(&rconfig), &lconfig)?;
let values = request.values()?;
- println!("{:?}", values);
+ println!("{values:?}");
Ok(())
}
diff --git a/bindings/rust/libgpiod/examples/reconfigure_input_to_output.rs b/bindings/rust/libgpiod/examples/reconfigure_input_to_output.rs
index fb5402bf88bf56c28f1c43f0e54ced22ed64f39e..b872d7709f3ecc651cf6d372cb46d6fbdfed77b1 100644
--- a/bindings/rust/libgpiod/examples/reconfigure_input_to_output.rs
+++ b/bindings/rust/libgpiod/examples/reconfigure_input_to_output.rs
@@ -21,22 +21,22 @@ fn main() -> libgpiod::Result<()> {
let chip = libgpiod::chip::Chip::open(&chip_path)?;
// request the line initially as an input
let mut request = chip.request_lines(Some(&rconfig), &lconfig)?;
// read the current line value
let value = request.value(line_offset)?;
- println!("{}={:?} (input)", line_offset, value);
+ println!("{line_offset}={value:?} (input)");
// switch the line to an output and drive it low
let mut lsettings = line::Settings::new()?;
lsettings.set_direction(line::Direction::Output)?;
lsettings.set_output_value(line::Value::InActive)?;
lconfig.add_line_settings(&[line_offset], lsettings)?;
request.reconfigure_lines(&lconfig)?;
// report the current driven value
let value = request.value(line_offset)?;
- println!("{}={:?} (output)", line_offset, value);
+ println!("{line_offset}={value:?} (output)");
Ok(())
}
diff --git a/bindings/rust/libgpiod/examples/toggle_line_value.rs b/bindings/rust/libgpiod/examples/toggle_line_value.rs
index 6d5f697310e9977677975ab3202cad3975ffdc6f..bf87222acc87f559af1467c59b1b98b299755759 100644
--- a/bindings/rust/libgpiod/examples/toggle_line_value.rs
+++ b/bindings/rust/libgpiod/examples/toggle_line_value.rs
@@ -30,13 +30,13 @@ fn main() -> libgpiod::Result<()> {
let mut rconfig = libgpiod::request::Config::new()?;
rconfig.set_consumer("toggle-line-value")?;
let chip = libgpiod::chip::Chip::open(&chip_path)?;
let mut req = chip.request_lines(Some(&rconfig), &lconfig)?;
loop {
- println!("{}={:?}", line_offset, value);
+ println!("{line_offset}={value:?}");
std::thread::sleep(Duration::from_secs(1));
value = toggle_value(value);
req.set_value(line_offset, value)?;
}
}
diff --git a/bindings/rust/libgpiod/src/lib.rs b/bindings/rust/libgpiod/src/lib.rs
index c03831bce62b287c08804e2d9d96aea7320dec7c..f4e511d535b70fbc01f91fa059921545b405656a 100644
--- a/bindings/rust/libgpiod/src/lib.rs
+++ b/bindings/rust/libgpiod/src/lib.rs
@@ -106,15 +106,15 @@ pub enum OperationType {
SimDevNew,
SimDevEnable,
SimDevDisable,
}
impl fmt::Display for OperationType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{:?}", self)
+ write!(f, "{self:?}")
}
}
/// Result of libgpiod operations.
pub type Result<T> = std::result::Result<T, Error>;
/// Error codes for libgpiod operations.
@@ -378,15 +378,15 @@ pub mod line {
EventClock(EventClock),
/// Output value.
OutputValue(Value),
}
impl fmt::Display for SettingVal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{:?}", self)
+ write!(f, "{self:?}")
}
}
/// Event clock settings.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum EventClock {
/// Line uses the monotonic clock for edge event timestamps.
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings
2025-07-21 7:53 [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings Erik Wierich
2025-07-21 7:53 ` [PATCH libgpiod 1/2] bindings: rust: remove newline between attribute and attribute Erik Wierich
2025-07-21 7:53 ` [PATCH libgpiod 2/2] bindings: rust: simplify format statements Erik Wierich
@ 2025-07-21 7:55 ` Viresh Kumar
2025-07-21 13:20 ` Bartosz Golaszewski
3 siblings, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2025-07-21 7:55 UTC (permalink / raw)
To: Erik Wierich; +Cc: Linux-GPIO, Bartosz Golaszewski
On 21-07-25, 09:53, Erik Wierich wrote:
> This fixes warnings reported by clippy 0.1.88.
>
> Signed-off-by: Erik Wierich <erik@riscstar.com>
> ---
> Erik Wierich (2):
> bindings: rust: remove newline between attribute and attribute
> bindings: rust: simplify format statements
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings
2025-07-21 7:53 [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings Erik Wierich
` (2 preceding siblings ...)
2025-07-21 7:55 ` [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings Viresh Kumar
@ 2025-07-21 13:20 ` Bartosz Golaszewski
3 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2025-07-21 13:20 UTC (permalink / raw)
To: Linux-GPIO, Bartosz Golaszewski, Viresh Kumar, Erik Wierich
Cc: Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Mon, 21 Jul 2025 09:53:06 +0200, Erik Wierich wrote:
> This fixes warnings reported by clippy 0.1.88.
>
>
Applied, thanks!
[1/2] bindings: rust: remove newline between attribute and attribute
commit: b20401360ce35fabc123c379ab3fddb394ee467e
[2/2] bindings: rust: simplify format statements
commit: 6263abf3abb6fcdb4b85745664a7bb3c1d3c4f8c
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-21 13:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 7:53 [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings Erik Wierich
2025-07-21 7:53 ` [PATCH libgpiod 1/2] bindings: rust: remove newline between attribute and attribute Erik Wierich
2025-07-21 7:53 ` [PATCH libgpiod 2/2] bindings: rust: simplify format statements Erik Wierich
2025-07-21 7:55 ` [PATCH libgpiod 0/2] bindings: rust: fix clippy warnings Viresh Kumar
2025-07-21 13:20 ` Bartosz Golaszewski
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).