On 18-10-22, 11:27, Kent Gibson wrote: > One more thing - I overlooked trying to build on 32-bit while reviewing. > (in this case on a Raspberry Pi 4) I missed running this :( cargo build --target arm-unknown-linux-gnueabi I have these changes on the top and yet I have an error which I am not sure how to fix here without special if/else code per target. diff --git a/bindings/rust/gpiosim/src/sim.rs b/bindings/rust/gpiosim/src/sim.rs index 4dd4adfa0d3f..dfa22fbec94b 100644 --- a/bindings/rust/gpiosim/src/sim.rs +++ b/bindings/rust/gpiosim/src/sim.rs @@ -186,7 +186,7 @@ impl SimBank { fn set_num_lines(&self, num: u64) -> Result<()> { // SAFETY: `gpiosim_bank` is guaranteed to be valid here. - let ret = unsafe { gpiosim_bank_set_num_lines(self.bank, num) }; + let ret = unsafe { gpiosim_bank_set_num_lines(self.bank, num.try_into().unwrap()) }; if ret == -1 { Err(Error::OperationFailed( OperationType::SimBankSetNumLines, diff --git a/bindings/rust/libgpiod/src/edge_event.rs b/bindings/rust/libgpiod/src/edge_event.rs index 0d328ebb2b03..87c5af228e2b 100644 --- a/bindings/rust/libgpiod/src/edge_event.rs +++ b/bindings/rust/libgpiod/src/edge_event.rs @@ -76,7 +76,7 @@ impl<'b> Event<'b> { /// associated line request. pub fn global_seqno(&self) -> u64 { // SAFETY: `gpiod_edge_event` is guaranteed to be valid here. - unsafe { gpiod::gpiod_edge_event_get_global_seqno(self.event) } + unsafe { gpiod::gpiod_edge_event_get_global_seqno(self.event) as u64 } } /// Get the event sequence number specific to concerned line. @@ -85,7 +85,7 @@ impl<'b> Event<'b> { /// lifetime of the associated line request. pub fn line_seqno(&self) -> u64 { // SAFETY: `gpiod_edge_event` is guaranteed to be valid here. - unsafe { gpiod::gpiod_edge_event_get_line_seqno(self.event) } + unsafe { gpiod::gpiod_edge_event_get_line_seqno(self.event) as u64 } } } diff --git a/bindings/rust/libgpiod/src/line_info.rs b/bindings/rust/libgpiod/src/line_info.rs index a458e72e0b12..aa1824cf3e80 100644 --- a/bindings/rust/libgpiod/src/line_info.rs +++ b/bindings/rust/libgpiod/src/line_info.rs @@ -144,7 +144,9 @@ impl Info { /// Get the debounce period of the line. pub fn debounce_period(&self) -> Duration { // SAFETY: `gpiod_line_info` is guaranteed to be valid here. - Duration::from_micros(unsafe { gpiod::gpiod_line_info_get_debounce_period_us(self.info) }) + Duration::from_micros(unsafe { + gpiod::gpiod_line_info_get_debounce_period_us(self.info).into() + }) } } diff --git a/bindings/rust/libgpiod/src/line_settings.rs b/bindings/rust/libgpiod/src/line_settings.rs index d422ad1ea68f..4df3efb1a93f 100644 --- a/bindings/rust/libgpiod/src/line_settings.rs +++ b/bindings/rust/libgpiod/src/line_settings.rs @@ -220,7 +220,7 @@ impl Settings { unsafe { gpiod::gpiod_line_settings_set_debounce_period_us( self.settings, - period.as_micros() as u64, + (period.as_micros() as usize).try_into().unwrap(), ); } @@ -231,7 +231,7 @@ impl Settings { pub fn debounce_period(&self) -> Result<Duration> { // SAFETY: `gpiod_line_settings` is guaranteed to be valid here. Ok(Duration::from_micros(unsafe { - gpiod::gpiod_line_settings_get_debounce_period_us(self.settings) + gpiod::gpiod_line_settings_get_debounce_period_us(self.settings).into() })) } diff --git a/bindings/rust/libgpiod/tests/chip.rs b/bindings/rust/libgpiod/tests/chip.rs index aaee910e457f..a7fdaadf4da1 100644 --- a/bindings/rust/libgpiod/tests/chip.rs +++ b/bindings/rust/libgpiod/tests/chip.rs @@ -90,7 +90,10 @@ mod chip { // Failure assert_eq!( chip.line_offset_from_name("nonexistent").unwrap_err(), - ChipError::OperationFailed(OperationType::ChipGetLineOffsetFromName, Errno::new(ENOENT)) + ChipError::OperationFailed( + OperationType::ChipGetLineOffsetFromName, + Errno::new(ENOENT), + ) ); } } $ -------------------------8<------------------------- Current failures: error[E0308]: mismatched types --> libgpiod/src/line_config.rs:105:78 | 105 | let ret = unsafe { gpiod::gpiod_line_config_get_offsets(self.config, &mut num, &mut ptr) }; | ------------------------------------ ^^^^^^^^ expected `u32`, found `u64` | | | arguments to this function are incorrect | = note: expected raw pointer `*mut u32` found mutable reference `&mut u64` note: function defined here --> /mnt/ssd/all/work/repos/virtio/rust/libgpiod/bindings/rust/libgpiod-sys/src/bindings.rs:847:12 | 847 | pub fn gpiod_line_config_get_offsets( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For more information about this error, try `rustc --explain E0308`. error: could not compile `libgpiod` due to previous error -- viresh