From 47ae47de3092cb9da98084ece77df549c9546d57 Mon Sep 17 00:00:00 2001 From: Robert Clipsham Date: Wed, 19 Jul 2023 20:01:33 +0100 Subject: [PATCH] Assorted cleanup * Deny warnings for all crates * Fix build warnings * Fix typo * Rename master -> main for CI * Upgrade dependencies --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 2 +- pnet_base/Cargo.toml | 4 ++-- pnet_base/src/lib.rs | 2 ++ pnet_datalink/Cargo.toml | 6 +++--- pnet_datalink/src/lib.rs | 2 ++ pnet_macros/Cargo.toml | 10 +++++----- pnet_macros/src/lib.rs | 4 +--- pnet_macros_support/src/lib.rs | 1 + pnet_macros_support/src/packet.rs | 4 ++-- pnet_packet/Cargo.toml | 2 +- pnet_packet/src/lib.rs | 1 + pnet_packet/src/sll2.rs | 2 +- pnet_sys/Cargo.toml | 2 +- pnet_sys/src/lib.rs | 1 + pnet_sys/src/windows.rs | 4 ++-- pnet_transport/Cargo.toml | 2 +- pnet_transport/src/lib.rs | 3 +++ src/lib.rs | 3 ++- 19 files changed, 34 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aedc71b7..f0fed4db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: Rust on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] env: CARGO_TERM_COLOR: always diff --git a/Cargo.toml b/Cargo.toml index b81a5a00..d2d683a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ pnet_transport = { path = "pnet_transport", version = "0.33.0", optional = true, pnet_packet = { path = "pnet_packet", version = "0.33.0", default-features = false } [dev-dependencies] -time = "0.3.17" +time = "0.3.23" [[example]] name = "arp_packet" diff --git a/pnet_base/Cargo.toml b/pnet_base/Cargo.toml index cbb7ba72..1cf02d15 100644 --- a/pnet_base/Cargo.toml +++ b/pnet_base/Cargo.toml @@ -13,10 +13,10 @@ edition = "2021" [dependencies] no-std-net = { version = "0.6.0", default-features = false } -serde = { version = "1.0.152", optional = true, default-features = false } +serde = { version = "1.0.171", optional = true, default-features = false } [dev-dependencies] -serde_test = "1.0.152" +serde_test = "1.0.171" [features] std = ["no-std-net/std"] diff --git a/pnet_base/src/lib.rs b/pnet_base/src/lib.rs index 31bfdc3d..ea29d48c 100644 --- a/pnet_base/src/lib.rs +++ b/pnet_base/src/lib.rs @@ -6,6 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(warnings)] + #![cfg_attr(all(not(test), not(feature = "std")), no_std)] #[cfg(feature = "serde")] diff --git a/pnet_datalink/Cargo.toml b/pnet_datalink/Cargo.toml index 8f7fe7db..127d7d33 100644 --- a/pnet_datalink/Cargo.toml +++ b/pnet_datalink/Cargo.toml @@ -17,14 +17,14 @@ std = ["pnet_base/std"] default = ["std"] [dependencies] -libc = "0.2.139" +libc = "0.2.147" ipnetwork = "0.20.0" pnet_base = { path = "../pnet_base", version = "0.33.0", default-features = false } pnet_sys = { path = "../pnet_sys", version = "0.33.0" } -pcap = { version = "1.0.0", optional = true } +pcap = { version = "1.1.0", optional = true } netmap_sys = { version = "0.1.4", optional = true, features = ["netmap_with_libs"] } -serde = { version = "1.0.152", optional = true, default-features = false, features = [ "derive" ] } +serde = { version = "1.0.171", optional = true, default-features = false, features = [ "derive" ] } [target.'cfg(windows)'.dependencies] winapi = "0.3.9" diff --git a/pnet_datalink/src/lib.rs b/pnet_datalink/src/lib.rs index 8f5c0a59..0a49f717 100644 --- a/pnet_datalink/src/lib.rs +++ b/pnet_datalink/src/lib.rs @@ -8,6 +8,8 @@ //! Support for sending and receiving data link layer packets. +#![deny(warnings)] + extern crate ipnetwork; extern crate libc; extern crate pnet_base; diff --git a/pnet_macros/Cargo.toml b/pnet_macros/Cargo.toml index 386c585a..0179c115 100644 --- a/pnet_macros/Cargo.toml +++ b/pnet_macros/Cargo.toml @@ -20,10 +20,10 @@ travis = [] [dev-dependencies] pnet_macros_support = { path = "../pnet_macros_support", version = "0.33.0" } -trybuild = "1.0.77" +trybuild = "1.0.81" [dependencies] -proc-macro2 = "1.0.50" -quote = "1.0.23" -syn = { version = "2.0.25", features = ["full"] } -regex = "1.7.1" +proc-macro2 = "1.0.66" +quote = "1.0.31" +syn = { version = "2.0.26", features = ["full"] } +regex = "1.9.1" diff --git a/pnet_macros/src/lib.rs b/pnet_macros/src/lib.rs index 3ea4b062..69c3ddb7 100644 --- a/pnet_macros/src/lib.rs +++ b/pnet_macros/src/lib.rs @@ -136,9 +136,7 @@ //! `#[construct_with(...)]` attribute, and in the `new` method. #![deny(missing_docs)] -// #![cfg_attr(feature = "clippy", feature(plugin))] -// #![cfg_attr(feature = "clippy", plugin(clippy))] -// #![cfg_attr(feature = "clippy", allow(let_and_return))] +#![deny(warnings)] use proc_macro::TokenStream; use quote::quote; diff --git a/pnet_macros_support/src/lib.rs b/pnet_macros_support/src/lib.rs index f7506a36..5e4b0950 100644 --- a/pnet_macros_support/src/lib.rs +++ b/pnet_macros_support/src/lib.rs @@ -11,6 +11,7 @@ //! This exists to remove the need for the plugin_as_library feature, and allow for static linking. #![deny(missing_docs)] +#![deny(warnings)] #![no_std] extern crate pnet_base; diff --git a/pnet_macros_support/src/packet.rs b/pnet_macros_support/src/packet.rs index fe8f12fc..cbdb6b6a 100644 --- a/pnet_macros_support/src/packet.rs +++ b/pnet_macros_support/src/packet.rs @@ -39,12 +39,12 @@ impl Packet for alloc::boxed::Box { impl Packet for &T { /// Retrieve the underlying buffer for the packet. fn packet(&self) -> &[u8] { - self.deref().packet() + (*self).packet() } /// Retrieve the payload for the packet. fn payload(&self) -> &[u8] { - self.deref().payload() + (*self).payload() } } diff --git a/pnet_packet/Cargo.toml b/pnet_packet/Cargo.toml index 4a60ac9c..6e172db9 100644 --- a/pnet_packet/Cargo.toml +++ b/pnet_packet/Cargo.toml @@ -22,7 +22,7 @@ default = ["std"] [dev-dependencies] hex = "0.4.3" -criterion = { version = "0.4.0", features = ["html_reports"] } #added HTML feature becuase of the annoying warnings when running the tests +criterion = { version = "0.5.1", features = ["html_reports"] } #added HTML feature becuase of the annoying warnings when running the tests [build-dependencies] glob = "0.3.1" diff --git a/pnet_packet/src/lib.rs b/pnet_packet/src/lib.rs index eff48b97..aa537ca7 100644 --- a/pnet_packet/src/lib.rs +++ b/pnet_packet/src/lib.rs @@ -8,6 +8,7 @@ //! Provides interfaces for interacting with packets and headers. #![allow(missing_docs)] +#![deny(warnings)] #![no_std] #![macro_use] diff --git a/pnet_packet/src/sll2.rs b/pnet_packet/src/sll2.rs index 50a0f487..cf87d4a5 100644 --- a/pnet_packet/src/sll2.rs +++ b/pnet_packet/src/sll2.rs @@ -15,7 +15,7 @@ pub struct SLL2 { pub protocol_type: EtherType, #[construct_with(u16)] - pub reserverd: u16be, + pub reserved: u16be, #[construct_with(u32)] pub interface_index: u32be, diff --git a/pnet_sys/Cargo.toml b/pnet_sys/Cargo.toml index ed41a905..372b7c7f 100644 --- a/pnet_sys/Cargo.toml +++ b/pnet_sys/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming"] edition = "2021" [dependencies] -libc = "0.2.139" +libc = "0.2.147" [target.'cfg(windows)'.dependencies] winapi = { version = "0.3.9", features = [ "winsock2", "ws2ipdef" ] } diff --git a/pnet_sys/src/lib.rs b/pnet_sys/src/lib.rs index 5582a67e..0a87d25a 100644 --- a/pnet_sys/src/lib.rs +++ b/pnet_sys/src/lib.rs @@ -6,6 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(warnings)] extern crate libc; use std::io; diff --git a/pnet_sys/src/windows.rs b/pnet_sys/src/windows.rs index 0421ab52..c27745b9 100644 --- a/pnet_sys/src/windows.rs +++ b/pnet_sys/src/windows.rs @@ -71,7 +71,7 @@ pub mod public { pub fn make_in6_addr(segments: [u16; 8]) -> In6Addr { unsafe { - let mut val: In6Addr = mem::MaybeUninit::uninit().assume_init(); + let mut val: In6Addr = mem::zeroed(); *val.u.Word_mut() = [ htons(segments[0]), htons(segments[1]), @@ -188,7 +188,7 @@ pub fn ipv4_addr(addr: InAddr) -> u32 { #[inline(always)] pub fn mk_inaddr(addr: u32) -> InAddr { unsafe { - let mut val: InAddr = mem::MaybeUninit::uninit().assume_init(); + let mut val: InAddr = mem::zeroed(); *val.S_un.S_addr_mut() = addr as minwindef::ULONG; val diff --git a/pnet_transport/Cargo.toml b/pnet_transport/Cargo.toml index 1a3bd708..43ec510d 100644 --- a/pnet_transport/Cargo.toml +++ b/pnet_transport/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming"] edition = "2021" [dependencies] -libc = "0.2.139" +libc = "0.2.147" pnet_base = { path = "../pnet_base", version = "0.33.0", default-features = false } pnet_sys = { path = "../pnet_sys", version = "0.33.0" } pnet_packet = { path = "../pnet_packet", version = "0.33.0" } diff --git a/pnet_transport/src/lib.rs b/pnet_transport/src/lib.rs index a2c974ff..7e0ad507 100644 --- a/pnet_transport/src/lib.rs +++ b/pnet_transport/src/lib.rs @@ -16,6 +16,7 @@ //! X and FreeBSD, it is impossible to implement protocols which are already //! implemented in the kernel such as TCP and UDP. +#![deny(warnings)] #![macro_use] extern crate libc; @@ -34,10 +35,12 @@ use pnet_packet::Packet; use std::io; use std::io::Error; +#[cfg(unix)] use std::io::ErrorKind; use std::mem; use std::net::{self, IpAddr}; use std::sync::Arc; +#[cfg(unix)] use std::time::Duration; /// Represents a transport layer protocol. diff --git a/src/lib.rs b/src/lib.rs index 8abff094..bf313220 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,8 @@ // except according to those terms. #![deny(missing_docs)] +#![deny(warnings)] + #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(feature = "nightly", feature(custom_attribute, plugin))] #![cfg_attr(feature = "nightly", plugin(pnet_macros_plugin))] @@ -15,7 +17,6 @@ #![cfg_attr(feature = "clippy", plugin(clippy))] // We can't implement Iterator since we use streaming iterators #![cfg_attr(feature = "clippy", allow(should_implement_trait))] -#![cfg_attr(any(feature = "appveyor", feature = "travis"), deny(warnings))] //! # libpnet //!