aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schilling <erik.schilling@linaro.org>2023-06-30 13:18:44 +0200
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-06-30 14:10:20 +0200
commit901104ec2fa5f4c60f157ccb236a9b967fa7fa6b (patch)
tree116b0decf245a7b58de777f18b8d914c2fb5291c
parent72cd9898edbdd6838dce8e84f7a35db2d637e0ae (diff)
downloadlibgpiod-901104ec2fa5f4c60f157ccb236a9b967fa7fa6b.tar.gz
bindings: rust: clippy: drop unnecessary casts
Fixes clippy warnings on these lines. Applied the suggested fix using: cargo clippy --fix clippy version: clippy 0.1.70 (90c5418 2023-05-31). Reported-by: Kent Gibson <warthog618@gmail.com> Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com Signed-off-by: Erik Schilling <erik.schilling@linaro.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-rw-r--r--bindings/rust/gpiosim-sys/src/lib.rs2
-rw-r--r--bindings/rust/gpiosim-sys/src/sim.rs2
-rw-r--r--bindings/rust/libgpiod/src/chip.rs2
-rw-r--r--bindings/rust/libgpiod/src/edge_event.rs2
-rw-r--r--bindings/rust/libgpiod/src/event_buffer.rs2
-rw-r--r--bindings/rust/libgpiod/src/info_event.rs2
-rw-r--r--bindings/rust/libgpiod/src/lib.rs2
-rw-r--r--bindings/rust/libgpiod/src/line_config.rs4
-rw-r--r--bindings/rust/libgpiod/src/line_request.rs8
-rw-r--r--bindings/rust/libgpiod/src/line_settings.rs2
-rw-r--r--bindings/rust/libgpiod/src/request_config.rs2
-rw-r--r--bindings/rust/libgpiod/tests/chip.rs2
12 files changed, 16 insertions, 16 deletions
diff --git a/bindings/rust/gpiosim-sys/src/lib.rs b/bindings/rust/gpiosim-sys/src/lib.rs
index eed2a425..bf9ae32e 100644
--- a/bindings/rust/gpiosim-sys/src/lib.rs
+++ b/bindings/rust/gpiosim-sys/src/lib.rs
@@ -46,7 +46,7 @@ impl Value {
errno::errno(),
))
}
- _ => return Err(Error::InvalidEnumValue("Value", val as i32)),
+ _ => return Err(Error::InvalidEnumValue("Value", val)),
})
}
}
diff --git a/bindings/rust/gpiosim-sys/src/sim.rs b/bindings/rust/gpiosim-sys/src/sim.rs
index 896596f0..16c2b3ed 100644
--- a/bindings/rust/gpiosim-sys/src/sim.rs
+++ b/bindings/rust/gpiosim-sys/src/sim.rs
@@ -164,7 +164,7 @@ impl SimBank {
errno::errno(),
))
} else {
- Value::new(ret as i32)
+ Value::new(ret)
}
}
diff --git a/bindings/rust/libgpiod/src/chip.rs b/bindings/rust/libgpiod/src/chip.rs
index f4de008b..81e1be6b 100644
--- a/bindings/rust/libgpiod/src/chip.rs
+++ b/bindings/rust/libgpiod/src/chip.rs
@@ -279,7 +279,7 @@ impl Info {
/// Get the number of GPIO lines exposed by the chip.
pub fn num_lines(&self) -> usize {
// SAFETY: `gpiod_chip` is guaranteed to be valid here.
- unsafe { gpiod::gpiod_chip_info_get_num_lines(self.info) as usize }
+ unsafe { gpiod::gpiod_chip_info_get_num_lines(self.info) }
}
}
diff --git a/bindings/rust/libgpiod/src/edge_event.rs b/bindings/rust/libgpiod/src/edge_event.rs
index d324ce67..0c0cfbcf 100644
--- a/bindings/rust/libgpiod/src/edge_event.rs
+++ b/bindings/rust/libgpiod/src/edge_event.rs
@@ -41,7 +41,7 @@ impl Event {
/// Get the event type.
pub fn event_type(&self) -> Result<EdgeKind> {
// SAFETY: `gpiod_edge_event` is guaranteed to be valid here.
- EdgeKind::new(unsafe { gpiod::gpiod_edge_event_get_event_type(self.0) } as u32)
+ EdgeKind::new(unsafe { gpiod::gpiod_edge_event_get_event_type(self.0) })
}
/// Get the timestamp of the event.
diff --git a/bindings/rust/libgpiod/src/event_buffer.rs b/bindings/rust/libgpiod/src/event_buffer.rs
index 1deaf2bc..520eb2aa 100644
--- a/bindings/rust/libgpiod/src/event_buffer.rs
+++ b/bindings/rust/libgpiod/src/event_buffer.rs
@@ -82,7 +82,7 @@ impl Buffer {
}
// SAFETY: `gpiod_edge_event_buffer` is guaranteed to be valid here.
- let capacity = unsafe { gpiod::gpiod_edge_event_buffer_get_capacity(buffer) as usize };
+ let capacity = unsafe { gpiod::gpiod_edge_event_buffer_get_capacity(buffer) };
Ok(Self {
buffer,
diff --git a/bindings/rust/libgpiod/src/info_event.rs b/bindings/rust/libgpiod/src/info_event.rs
index b0ceb3b2..db606004 100644
--- a/bindings/rust/libgpiod/src/info_event.rs
+++ b/bindings/rust/libgpiod/src/info_event.rs
@@ -34,7 +34,7 @@ impl Event {
/// Get the event type of the status change event.
pub fn event_type(&self) -> Result<InfoChangeKind> {
// SAFETY: `gpiod_info_event` is guaranteed to be valid here.
- InfoChangeKind::new(unsafe { gpiod::gpiod_info_event_get_event_type(self.event) } as u32)
+ InfoChangeKind::new(unsafe { gpiod::gpiod_info_event_get_event_type(self.event) })
}
/// Get the timestamp of the event, read from the monotonic clock.
diff --git a/bindings/rust/libgpiod/src/lib.rs b/bindings/rust/libgpiod/src/lib.rs
index 26354e5b..3acc98cd 100644
--- a/bindings/rust/libgpiod/src/lib.rs
+++ b/bindings/rust/libgpiod/src/lib.rs
@@ -193,7 +193,7 @@ pub mod line {
errno::errno(),
))
}
- _ => return Err(Error::InvalidEnumValue("Value", val as i32)),
+ _ => return Err(Error::InvalidEnumValue("Value", val)),
})
}
diff --git a/bindings/rust/libgpiod/src/line_config.rs b/bindings/rust/libgpiod/src/line_config.rs
index e973cde4..f4f03f1a 100644
--- a/bindings/rust/libgpiod/src/line_config.rs
+++ b/bindings/rust/libgpiod/src/line_config.rs
@@ -108,7 +108,7 @@ impl Config {
let mut map = SettingsMap::new();
// SAFETY: gpiod_line_config is guaranteed to be valid here
let num_lines = unsafe { gpiod::gpiod_line_config_get_num_configured_offsets(self.config) };
- let mut offsets = vec![0; num_lines as usize];
+ let mut offsets = vec![0; num_lines];
// SAFETY: gpiod_line_config is guaranteed to be valid here.
let num_stored = unsafe {
@@ -119,7 +119,7 @@ impl Config {
)
};
- for offset in &offsets[0..num_stored as usize] {
+ for offset in &offsets[0..num_stored] {
// SAFETY: `gpiod_line_config` is guaranteed to be valid here.
let settings =
unsafe { gpiod::gpiod_line_config_get_line_settings(self.config, *offset) };
diff --git a/bindings/rust/libgpiod/src/line_request.rs b/bindings/rust/libgpiod/src/line_request.rs
index b175eea3..1140aa9f 100644
--- a/bindings/rust/libgpiod/src/line_request.rs
+++ b/bindings/rust/libgpiod/src/line_request.rs
@@ -28,12 +28,12 @@ impl Request {
/// Get the number of lines in the request.
pub fn num_lines(&self) -> usize {
// SAFETY: `gpiod_line_request` is guaranteed to be valid here.
- unsafe { gpiod::gpiod_line_request_get_num_requested_lines(self.request) as usize }
+ unsafe { gpiod::gpiod_line_request_get_num_requested_lines(self.request) }
}
/// Get the offsets of lines in the request.
pub fn offsets(&self) -> Vec<Offset> {
- let mut offsets = vec![0; self.num_lines() as usize];
+ let mut offsets = vec![0; self.num_lines()];
// SAFETY: `gpiod_line_request` is guaranteed to be valid here.
let num_offsets = unsafe {
@@ -43,7 +43,7 @@ impl Request {
self.num_lines(),
)
};
- offsets.shrink_to(num_offsets as usize);
+ offsets.shrink_to(num_offsets);
offsets
}
@@ -145,7 +145,7 @@ impl Request {
/// Set values of all lines associated with the request.
pub fn set_values(&mut self, values: &[Value]) -> Result<&mut Self> {
- if values.len() != self.num_lines() as usize {
+ if values.len() != self.num_lines() {
return Err(Error::InvalidArguments);
}
diff --git a/bindings/rust/libgpiod/src/line_settings.rs b/bindings/rust/libgpiod/src/line_settings.rs
index 918d6c26..79ee2f59 100644
--- a/bindings/rust/libgpiod/src/line_settings.rs
+++ b/bindings/rust/libgpiod/src/line_settings.rs
@@ -244,7 +244,7 @@ impl Settings {
/// Get the event clock setting.
pub fn event_clock(&self) -> Result<EventClock> {
// SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
- EventClock::new(unsafe { gpiod::gpiod_line_settings_get_event_clock(self.settings) } as u32)
+ EventClock::new(unsafe { gpiod::gpiod_line_settings_get_event_clock(self.settings) })
}
/// Set the output value setting.
diff --git a/bindings/rust/libgpiod/src/request_config.rs b/bindings/rust/libgpiod/src/request_config.rs
index 0c6c5c1d..5bde7c68 100644
--- a/bindings/rust/libgpiod/src/request_config.rs
+++ b/bindings/rust/libgpiod/src/request_config.rs
@@ -83,7 +83,7 @@ impl Config {
/// Get the edge event buffer size setting for the request config.
pub fn event_buffer_size(&self) -> usize {
// SAFETY: `gpiod_request_config` is guaranteed to be valid here.
- unsafe { gpiod::gpiod_request_config_get_event_buffer_size(self.config) as usize }
+ unsafe { gpiod::gpiod_request_config_get_event_buffer_size(self.config) }
}
}
diff --git a/bindings/rust/libgpiod/tests/chip.rs b/bindings/rust/libgpiod/tests/chip.rs
index f2647084..60b4ecc4 100644
--- a/bindings/rust/libgpiod/tests/chip.rs
+++ b/bindings/rust/libgpiod/tests/chip.rs
@@ -59,7 +59,7 @@ mod chip {
assert_eq!(info.label().unwrap(), LABEL);
assert_eq!(info.name().unwrap(), sim.chip_name());
assert_eq!(chip.path().unwrap(), sim.dev_path().to_str().unwrap());
- assert_eq!(info.num_lines(), NGPIO as usize);
+ assert_eq!(info.num_lines(), NGPIO);
}
#[test]