Skip to content

Commit

Permalink
chore: bump boringtun to Edition 2021 and fix clippy warnings (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger authored Dec 2, 2024
1 parent 6a6c087 commit e0f74ae
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion boringtun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
license = "BSD-3-Clause"
repository = "https://github.com/cloudflare/boringtun"
documentation = "https://docs.rs/boringtun/0.5.2/boringtun/"
edition = "2018"
edition = "2021"

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions boringtun/src/device/dev_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct LockReadGuard<'a, T: 'a + ?Sized> {
inner: RwLockReadGuard<'a, T>,
}

impl<'a, T: ?Sized> LockReadGuard<'a, T> {
impl<T: ?Sized> LockReadGuard<'_, T> {
/// Perform a closure on a mutable reference of the inner locked value.
///
/// # Parameters
Expand Down Expand Up @@ -99,7 +99,7 @@ impl<'a, T: ?Sized> LockReadGuard<'a, T> {
}
}

impl<'a, T: ?Sized> Deref for LockReadGuard<'a, T> {
impl<T: ?Sized> Deref for LockReadGuard<'_, T> {
type Target = T;

fn deref(&self) -> &T {
Expand Down
6 changes: 3 additions & 3 deletions boringtun/src/device/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ impl<H> EventPoll<H> {
}
}

impl<'a, H> Deref for EventGuard<'a, H> {
impl<H> Deref for EventGuard<'_, H> {
type Target = H;
fn deref(&self) -> &H {
&self.event.handler
}
}

impl<'a, H> Drop for EventGuard<'a, H> {
impl<H> Drop for EventGuard<'_, H> {
fn drop(&mut self) {
if self.event.needs_read {
// Must read from the event to reset it before we enable it
Expand All @@ -373,7 +373,7 @@ impl<'a, H> Drop for EventGuard<'a, H> {
}
}

impl<'a, H> EventGuard<'a, H> {
impl<H> EventGuard<'_, H> {
/// Get a mutable reference to the stored value
#[allow(dead_code)]
pub fn get_mut(&mut self) -> &mut H {
Expand Down
6 changes: 3 additions & 3 deletions boringtun/src/device/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,14 @@ impl<H> EventPoll<H> {
}
}

impl<'a, H> Deref for EventGuard<'a, H> {
impl<H> Deref for EventGuard<'_, H> {
type Target = H;
fn deref(&self) -> &H {
&self.event.handler
}
}

impl<'a, H> Drop for EventGuard<'a, H> {
impl<H> Drop for EventGuard<'_, H> {
fn drop(&mut self) {
unsafe {
// Re-enable the event once EventGuard goes out of scope
Expand All @@ -325,7 +325,7 @@ impl<'a, H> Drop for EventGuard<'a, H> {
}
}

impl<'a, H> EventGuard<'a, H> {
impl<H> EventGuard<'_, H> {
/// Cancel and remove the event represented by this guard
pub fn cancel(self) {
unsafe { self.poll.clear_event_by_fd(self.event.event.ident as RawFd) };
Expand Down
3 changes: 2 additions & 1 deletion boringtun/src/device/tun_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ union IfrIfru {
}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct ifreq {
ifr_name: [c_uchar; IFNAMSIZ],
ifr_ifru: IfrIfru,
Expand Down Expand Up @@ -72,7 +73,7 @@ impl TunSocket {
});
}

let fd = match unsafe { open(b"/dev/net/tun\0".as_ptr() as _, O_RDWR) } {
let fd = match unsafe { open(c"/dev/net/tun".as_ptr() as _, O_RDWR) } {
-1 => return Err(Error::Socket(io::Error::last_os_error())),
fd => fd,
};
Expand Down

0 comments on commit e0f74ae

Please sign in to comment.