Skip to content

Commit

Permalink
Defmt, Clippy, Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ committed Aug 30, 2024
1 parent 33ced62 commit 0fb7b21
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
2 changes: 2 additions & 0 deletions esp-wifi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added support for WPA2-ENTERPRISE (#2004)

### Changed

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions esp-wifi/src/compat/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn sem_create(max: u32, init: u32) -> *mut c_void {
let ptr = malloc(4) as *mut u32;
ptr.write_volatile(init);

trace!("sem created res = {:p}", ptr);
trace!("sem created res = {:?}", ptr);
ptr.cast()
})
}
Expand Down Expand Up @@ -258,13 +258,13 @@ pub fn create_queue(queue_len: c_int, item_size: c_int) -> *mut c_void {
ptr.write(queue);
}

trace!("created queue @{:p}", ptr);
trace!("created queue @{:?}", ptr);

ptr.cast()
}

pub fn delete_queue(queue: *mut c_void) {
trace!("delete_queue {:p}", queue);
trace!("delete_queue {:?}", queue);

let queue: *mut RawQueue = queue.cast();
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/compat/malloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub unsafe extern "C" fn calloc(number: u32, size: usize) -> *mut u8 {

#[no_mangle]
unsafe extern "C" fn realloc(ptr: *mut u8, new_size: usize) -> *mut u8 {
trace!("realloc {:p} {}", ptr, new_size);
trace!("realloc {:?} {}", ptr, new_size);

extern "C" {
fn memcpy(d: *mut u8, s: *const u8, l: usize);
Expand Down
28 changes: 14 additions & 14 deletions esp-wifi/src/compat/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ use crate::compat::malloc::*;

#[no_mangle]
unsafe extern "C" fn fwrite(ptr: *const (), size: usize, count: usize, stream: *const ()) -> usize {
todo!("fwrite {:p} {} {} {:p}", ptr, size, count, stream)
todo!("fwrite {:?} {} {} {:?}", ptr, size, count, stream)
}

#[no_mangle]
unsafe extern "C" fn fopen(filename: *const u8, mode: *const u8) -> *const () {
todo!("fopen {:p} {:p}", filename, mode)
todo!("fopen {:?} {:?}", filename, mode)
}

#[no_mangle]
unsafe extern "C" fn fgets(str: *const u8, count: u32, file: *const ()) -> *const u8 {
todo!("fgets {:p} {} {:p}", str, count, file)
todo!("fgets {:?} {} {:?}", str, count, file)
}

#[no_mangle]
unsafe extern "C" fn fclose(stream: *const ()) -> i32 {
todo!("fclose {:p}", stream);
todo!("fclose {:?}", stream);
}

#[no_mangle]
unsafe extern "C" fn strcat(destination: *mut u8, source: *const u8) -> *const u8 {
trace!("strcat {:p} {:p}", destination, source);
trace!("strcat {:?} {:?}", destination, source);

let dst: *mut u8 = strchr(destination.cast(), 0) as *mut u8;
let len = strchr(source.cast(), 0) as usize - source as usize;
Expand All @@ -32,7 +32,7 @@ unsafe extern "C" fn strcat(destination: *mut u8, source: *const u8) -> *const u

#[no_mangle]
unsafe extern "C" fn strcmp(str1: *const i8, str2: *const i8) -> i32 {
trace!("strcmp {:p} {:p}", str1, str2);
trace!("strcmp {:?} {:?}", str1, str2);

let s1 = core::ffi::CStr::from_ptr(str1).to_str().unwrap();
let s2 = core::ffi::CStr::from_ptr(str2).to_str().unwrap();
Expand All @@ -48,7 +48,7 @@ unsafe extern "C" fn strcmp(str1: *const i8, str2: *const i8) -> i32 {

#[no_mangle]
unsafe extern "C" fn strchr(str: *const i8, c: i32) -> *const i8 {
trace!("strchr {:p} {}", str, c);
trace!("strchr {:?} {}", str, c);

unsafe {
let mut p = str;
Expand All @@ -68,7 +68,7 @@ unsafe extern "C" fn strchr(str: *const i8, c: i32) -> *const i8 {

#[no_mangle]
unsafe extern "C" fn strlcpy(dst: *mut u8, src: *const u8, size: usize) -> usize {
trace!("strlcpy {:p} {:p} {}", dst, src, size);
trace!("strlcpy {:?} {:?} {}", dst, src, size);

let mut dst = dst;
let mut src = src;
Expand All @@ -93,7 +93,7 @@ unsafe extern "C" fn strlcpy(dst: *mut u8, src: *const u8, size: usize) -> usize

#[no_mangle]
unsafe extern "C" fn strstr(str1: *const i8, str2: *const i8) -> *const i8 {
trace!("strstr {:p} {:p}", str1, str2);
trace!("strstr {:?} {:?}", str1, str2);

let s1 = core::ffi::CStr::from_ptr(str1).to_str().unwrap();
let s2 = core::ffi::CStr::from_ptr(str2).to_str().unwrap();
Expand All @@ -108,7 +108,7 @@ unsafe extern "C" fn strstr(str1: *const i8, str2: *const i8) -> *const i8 {

#[no_mangle]
unsafe extern "C" fn strcasecmp(str1: *const u8, str2: *const u8) -> i32 {
trace!("strcasecmp {:p} {:p}", str1, str2);
trace!("strcasecmp {:?} {:?}", str1, str2);

let mut str1 = str1;
let mut str2 = str2;
Expand All @@ -131,12 +131,12 @@ unsafe extern "C" fn strcasecmp(str1: *const u8, str2: *const u8) -> i32 {
c2 = *str2 as char;
}

return c1 as i32 - c2 as i32;
c1 as i32 - c2 as i32
}

#[no_mangle]
unsafe extern "C" fn strdup(str: *const i8) -> *const u8 {
trace!("strdup {:p}", str);
trace!("strdup {:?}", str);

unsafe {
let s = core::ffi::CStr::from_ptr(str);
Expand All @@ -150,7 +150,7 @@ unsafe extern "C" fn strdup(str: *const i8) -> *const u8 {

#[no_mangle]
unsafe extern "C" fn atoi(str: *const i8) -> i32 {
trace!("atoi {:p}", str);
trace!("atoi {:?}", str);

unsafe {
let s = core::ffi::CStr::from_ptr(str);
Expand All @@ -175,7 +175,7 @@ struct Tm {

#[no_mangle]
unsafe extern "C" fn mktime(time: *const Tm) -> i64 {
trace!("mktime {:p}", time);
trace!("mktime {:?}", time);
let time = *time;

// Simplified implementation, ignoring time zones, leap seconds, and other
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/src/compat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ unsafe extern "C" fn _putchar(c: u8) {
if c == 0 || c == b'\n' || IDX == BUFFER.len() - 1 {
if c != 0 {
BUFFER[IDX] = c;
} else if IDX > 0 {
IDX -= 1;
} else {
IDX = IDX.saturating_sub(1);
}

info!("{}", core::str::from_utf8_unchecked(&BUFFER[..IDX]));
Expand Down
6 changes: 4 additions & 2 deletions esp-wifi/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ pub struct EapClientConfiguration {
pub pac_file: Option<&'static [u8]>,
pub time_check: bool,
pub ca_cert: Option<&'static [u8]>,
#[allow(clippy::type_complexity)]
pub certificate_and_key: Option<(&'static [u8], &'static [u8], Option<&'static [u8]>)>,
pub ttls_phase2_method: Option<TtlsPhase2Method>,

Expand Down Expand Up @@ -374,6 +375,7 @@ pub enum Capability {
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Default)]
#[allow(clippy::large_enum_variant)]
pub enum Configuration {
#[default]
None,
Expand Down Expand Up @@ -2565,7 +2567,7 @@ fn apply_sta_eap_config(config: &EapClientConfiguration) -> Result<(), WifiError
))?;
}

if let Some(ca_cert) = *&config.ca_cert {
if let Some(ca_cert) = config.ca_cert {
esp_wifi_result!(esp_eap_client_set_ca_cert(
ca_cert.as_ptr(),
ca_cert.len() as i32
Expand All @@ -2574,7 +2576,7 @@ fn apply_sta_eap_config(config: &EapClientConfiguration) -> Result<(), WifiError
esp_eap_client_clear_ca_cert();
}

if let Some((cert, key, password)) = *&config.certificate_and_key {
if let Some((cert, key, password)) = config.certificate_and_key {
let (pwd, pwd_len) = if let Some(pwd) = password {
(pwd.as_ptr(), pwd.len() as i32)
} else {
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/wifi/os_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ pub unsafe extern "C" fn task_create(
///
/// *************************************************************************
pub unsafe extern "C" fn task_delete(task_handle: *mut crate::binary::c_types::c_void) {
trace!("task delete called for {:p}", task_handle);
trace!("task delete called for {:?}", task_handle);

let task = if task_handle.is_null() {
crate::preempt::current_task()
Expand Down

0 comments on commit 0fb7b21

Please sign in to comment.