Skip to content

Commit

Permalink
Fix nightly clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebraham committed Feb 10, 2025
1 parent ec37c49 commit 48c43b2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion esp-hal/src/soc/efuse_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Efuse {
}

// get data length in bytes (ceil)
let byte_len = (word_bit_len + 7) / 8;
let byte_len = word_bit_len.div_ceil(8);
// represent word as a byte slice
let word_bytes =
unsafe { core::slice::from_raw_parts(&word as *const u32 as *const u8, byte_len) };
Expand Down
2 changes: 1 addition & 1 deletion esp-ieee802154/src/hal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub(crate) fn set_multipan_enable_mask(mask: u8) {
// apparently the REGS are garbage and the struct is right?
IEEE802154::regs()
.ctrl_cfg()
.modify(|r, w| unsafe { w.bits(r.bits() & !(0b1111 << 29) | (mask as u32) << 29) });
.modify(|r, w| unsafe { w.bits(r.bits() & !(0b1111 << 29) | ((mask as u32) << 29)) });
}

#[inline(always)]
Expand Down
4 changes: 2 additions & 2 deletions esp-lp-hal/src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct Input<const PIN: u8>;
impl<const PIN: u8> Input<PIN> {
/// Read the input state/level of the pin.
pub fn input_state(&self) -> bool {
unsafe { &*LpIo::PTR }.in_().read().bits() >> PIN & 0x1 != 0
(unsafe { &*LpIo::PTR }.in_().read().bits() >> PIN) & 0x1 != 0
}
}

Expand All @@ -49,7 +49,7 @@ pub struct Output<const PIN: u8>;
impl<const PIN: u8> Output<PIN> {
/// Read the output state/level of the pin.
pub fn output_state(&self) -> bool {
unsafe { &*LpIo::PTR }.out().read().bits() >> PIN & 0x1 != 0
(unsafe { &*LpIo::PTR }.out().read().bits() >> PIN) & 0x1 != 0
}

/// Set the output state/level of the pin.
Expand Down
6 changes: 3 additions & 3 deletions esp-lp-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl LpI2c {
self.add_cmd_lp(&mut cmd_iterator, Command::Start)?;

// Load device address and R/W bit into FIFO
self.write_fifo(addr << 1 | OperationType::Write as u8);
self.write_fifo((addr << 1) | OperationType::Write as u8);

self.add_cmd_lp(
&mut cmd_iterator,
Expand Down Expand Up @@ -285,7 +285,7 @@ impl LpI2c {
self.add_cmd_lp(&mut cmd_iterator, Command::Start)?;

// Load device address
self.write_fifo(addr << 1 | OperationType::Read as u8);
self.write_fifo((addr << 1) | OperationType::Read as u8);

self.add_cmd_lp(
&mut cmd_iterator,
Expand All @@ -297,7 +297,7 @@ impl LpI2c {
)?;

self.enable_interrupts(
1 << LP_I2C_TRANS_COMPLETE_INT_ST_S | 1 << LP_I2C_END_DETECT_INT_ST_S,
(1 << LP_I2C_TRANS_COMPLETE_INT_ST_S) | (1 << LP_I2C_END_DETECT_INT_ST_S),
);

let mut remaining_bytes = buffer.len();
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/ble/npl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ unsafe extern "C" fn task_create(
task_handle: *const c_void,
core_id: u32,
) -> i32 {
let name_str = str_from_c(name as *const u8);
let name_str = str_from_c(name as *const _);
trace!(
"task_create {:?} {} {} {:?} {} {:?} {}",
task_func,
Expand Down
1 change: 1 addition & 0 deletions esp-wifi/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,7 @@ pub(crate) fn wifi_start() -> Result<(), WifiError> {
.copy_from_slice(crate::CONFIG.country_code.as_bytes());
cntry_code[2] = crate::CONFIG.country_code_operating_class;

#[allow(clippy::useless_transmute)]
let country = wifi_country_t {
cc: core::mem::transmute::<[u8; 3], [core::ffi::c_char; 3]>(cntry_code),
schan: 1,
Expand Down
7 changes: 4 additions & 3 deletions esp-wifi/src/wifi/os_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ pub unsafe extern "C" fn task_create_pinned_to_core(
) -> i32 {
trace!("task_create_pinned_to_core task_func {:?} name {} stack_depth {} param {:?} prio {}, task_handle {:?} core_id {}",
task_func,
str_from_c(name as *const u8),
str_from_c(name as *const _),
stack_depth,
param,
prio,
Expand Down Expand Up @@ -1024,6 +1024,7 @@ pub unsafe extern "C" fn phy_enable() {
/// Don't support
///
/// *************************************************************************
#[allow(clippy::unnecessary_cast)]
pub unsafe extern "C" fn phy_update_country_info(
country: *const crate::binary::c_types::c_char,
) -> crate::binary::c_types::c_int {
Expand Down Expand Up @@ -1455,7 +1456,7 @@ pub unsafe extern "C" fn log_write(
format: *const crate::binary::c_types::c_char,
args: ...
) {
crate::binary::log::syslog(level, format as *const u8, args);
crate::binary::log::syslog(level, format as *const _, args);
}

/// **************************************************************************
Expand Down Expand Up @@ -1484,7 +1485,7 @@ pub unsafe extern "C" fn log_writev(
) {
crate::binary::log::syslog(
level,
format as *const u8,
format as *const _,
core::mem::transmute::<crate::binary::include::va_list, core::ffi::VaListImpl<'_>>(args),
);
}
Expand Down

0 comments on commit 48c43b2

Please sign in to comment.