Skip to content

Commit a8369e0

Browse files
authored
Merge pull request #219 from tatref/fix-warning
Fix doc and clippy warnings
2 parents 18be498 + bdb334e commit a8369e0

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

src/diskstats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub fn diskstats() -> ProcResult<Vec<DiskStat>> {
103103

104104
impl DiskStat {
105105
pub fn from_line(line: &str) -> ProcResult<DiskStat> {
106-
let mut s = line.trim().split_whitespace();
106+
let mut s = line.split_whitespace();
107107

108108
let major = from_str!(i32, expect!(s.next()));
109109
let minor = from_str!(i32, expect!(s.next()));

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ struct FileWrapper {
369369
impl FileWrapper {
370370
fn open<P: AsRef<Path>>(path: P) -> Result<FileWrapper, io::Error> {
371371
let p = path.as_ref();
372-
let f = wrap_io_error!(p, File::open(&p))?;
372+
let f = wrap_io_error!(p, File::open(p))?;
373373
Ok(FileWrapper {
374374
inner: f,
375375
path: p.to_owned(),
@@ -671,7 +671,7 @@ pub fn page_size() -> std::io::Result<u64> {
671671
}
672672

673673
/// Possible values for a kernel config option
674-
#[derive(Debug, Clone, PartialEq)]
674+
#[derive(Debug, Clone, PartialEq, Eq)]
675675
pub enum ConfigSetting {
676676
Yes,
677677
Module,

src/locks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub struct Lock {
150150

151151
impl Lock {
152152
fn from_line(line: &str) -> ProcResult<Lock> {
153-
let mut s = line.trim().split_whitespace();
153+
let mut s = line.split_whitespace();
154154

155155
let _ = expect!(s.next());
156156
let typ = {

src/net.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use std::{path::PathBuf, str::FromStr};
6363
#[cfg(feature = "serde1")]
6464
use serde::{Deserialize, Serialize};
6565

66-
#[derive(Debug, Clone, PartialEq)]
66+
#[derive(Debug, Clone, PartialEq, Eq)]
6767
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
6868
pub enum TcpState {
6969
Established = 1,
@@ -117,7 +117,7 @@ impl TcpState {
117117
}
118118
}
119119

120-
#[derive(Debug, Clone, PartialEq)]
120+
#[derive(Debug, Clone, PartialEq, Eq)]
121121
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
122122
pub enum UdpState {
123123
Established = 1,
@@ -141,7 +141,7 @@ impl UdpState {
141141
}
142142
}
143143

144-
#[derive(Debug, Clone, PartialEq)]
144+
#[derive(Debug, Clone, PartialEq, Eq)]
145145
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
146146
pub enum UnixState {
147147
UNCONNECTED = 1,
@@ -227,7 +227,7 @@ fn parse_addressport_str(s: &str) -> ProcResult<SocketAddr> {
227227
let port = from_str!(u16, port, 16);
228228

229229
if ip_part.len() == 8 {
230-
let bytes = expect!(hex::decode(&ip_part));
230+
let bytes = expect!(hex::decode(ip_part));
231231
let ip_u32 = NetworkEndian::read_u32(&bytes);
232232

233233
let ip = Ipv4Addr::new(
@@ -239,7 +239,7 @@ fn parse_addressport_str(s: &str) -> ProcResult<SocketAddr> {
239239

240240
Ok(SocketAddr::V4(SocketAddrV4::new(ip, port)))
241241
} else if ip_part.len() == 32 {
242-
let bytes = expect!(hex::decode(&ip_part));
242+
let bytes = expect!(hex::decode(ip_part));
243243

244244
let ip_a = NativeEndian::read_u32(&bytes[0..]);
245245
let ip_b = NativeEndian::read_u32(&bytes[4..]);
@@ -581,7 +581,7 @@ pub struct DeviceStatus {
581581

582582
impl DeviceStatus {
583583
fn from_str(s: &str) -> ProcResult<DeviceStatus> {
584-
let mut split = s.trim().split_whitespace();
584+
let mut split = s.split_whitespace();
585585
let name: String = expect!(from_iter(&mut split));
586586
let recv_bytes = expect!(from_iter(&mut split));
587587
let recv_packets = expect!(from_iter(&mut split));

src/pressure.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Pressure stall information retreived from `/proc/pressure/cpu`,
22
//! `/proc/pressure/memory` and `/proc/pressure/io`
33
//! may not be available on kernels older than 4.20.0
4-
//! For reference: https://lwn.net/Articles/759781/
4+
//! For reference: <https://lwn.net/Articles/759781/>
55
//!
6-
//! See also: https://www.kernel.org/doc/Documentation/accounting/psi.txt
6+
//! See also: <https://www.kernel.org/doc/Documentation/accounting/psi.txt>
77
88
use crate::{ProcError, ProcResult};
99
use std::collections::HashMap;
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
1313

1414
/// Pressure stall information for either CPU, memory, or IO.
1515
///
16-
/// See also: https://www.kernel.org/doc/Documentation/accounting/psi.txt
16+
/// See also: <https://www.kernel.org/doc/Documentation/accounting/psi.txt>
1717
#[derive(Debug, Clone)]
1818
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
1919
pub struct PressureRecord {

src/process/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use super::*;
6060
use crate::from_iter;
6161
use crate::net::{read_tcp_table, read_udp_table, TcpNetEntry, UdpNetEntry};
6262

63-
use rustix::fd::{AsFd, BorrowedFd, RawFd, OwnedFd};
63+
use rustix::fd::{AsFd, BorrowedFd, OwnedFd, RawFd};
6464
use rustix::fs::{AtFlags, Mode, OFlags, RawMode};
6565
#[cfg(feature = "serde1")]
6666
use serde::{Deserialize, Serialize};
@@ -806,7 +806,7 @@ impl Process {
806806
let file = wrap_io_error!(
807807
root,
808808
rustix::fs::openat(
809-
&rustix::fs::cwd(),
809+
rustix::fs::cwd(),
810810
&root,
811811
OFlags::PATH | OFlags::DIRECTORY | OFlags::CLOEXEC,
812812
Mode::empty()
@@ -823,7 +823,7 @@ impl Process {
823823
})
824824
.and_then(|s| s.to_string_lossy().parse::<i32>().ok())
825825
.or_else(|| {
826-
rustix::fs::readlinkat(&rustix::fs::cwd(), &root, Vec::new())
826+
rustix::fs::readlinkat(rustix::fs::cwd(), &root, Vec::new())
827827
.ok()
828828
.and_then(|s| s.to_string_lossy().parse::<i32>().ok())
829829
});
@@ -1521,7 +1521,7 @@ pub fn all_processes_with_root(root: impl AsRef<Path>) -> ProcResult<ProcessesIt
15211521
let dir = wrap_io_error!(
15221522
root,
15231523
rustix::fs::openat(
1524-
&rustix::fs::cwd(),
1524+
rustix::fs::cwd(),
15251525
root,
15261526
OFlags::RDONLY | OFlags::DIRECTORY | OFlags::CLOEXEC,
15271527
Mode::empty()

src/process/namespaces.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::Process;
1010

1111
impl Process {
1212
/// Describes namespaces to which the process with the corresponding PID belongs.
13-
/// Doc reference: https://man7.org/linux/man-pages/man7/namespaces.7.html
13+
/// Doc reference: <https://man7.org/linux/man-pages/man7/namespaces.7.html>
1414
/// The namespace type is the key for the HashMap, i.e 'net', 'user', etc.
1515
pub fn namespaces(&self) -> ProcResult<HashMap<OsString, Namespace>> {
1616
let mut namespaces = HashMap::new();

src/sys/kernel/random.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mod tests {
7272
fn test_poolsize() {
7373
// The kernel support section in the root lib.rs file says that we only aim to support >= 2.6 kernels,
7474
// so only test that case
75-
let poolsize = poolsize().unwrap();
75+
let _poolsize = poolsize().unwrap();
7676
}
7777

7878
#[test]

src/sys/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn compact_memory() -> ProcResult<()> {
3838
}
3939

4040
/// drop clean caches, dentries, and inodes from memory, causing that memory to become free.
41-
#[derive(Clone, Copy, Debug, PartialEq)]
41+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
4242
pub enum DropCache {
4343
/// default
4444
Default = 0,

0 commit comments

Comments
 (0)