Skip to content

Commit 28ecabc

Browse files
committed
Fix cargo clippy
Signed-off-by: Gris Ge <[email protected]>
1 parent 7d61129 commit 28ecabc

File tree

18 files changed

+39
-47
lines changed

18 files changed

+39
-47
lines changed

examples/dump_neighbours.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn main() {
3030
let mut buf = vec![0; req.header.length as usize];
3131
req.serialize(&mut buf[..]);
3232

33-
println!(">>> {:?}", req);
33+
println!(">>> {req:?}");
3434
socket.send(&buf[..], 0).unwrap();
3535

3636
let mut receive_buffer = vec![0; 4096];
@@ -56,7 +56,7 @@ fn main() {
5656
}
5757
}
5858
NetlinkPayload::Error(err) => {
59-
eprintln!("Received a netlink error message: {:?}", err);
59+
eprintln!("Received a netlink error message: {err:?}");
6060
return;
6161
}
6262
_ => {}
@@ -129,5 +129,5 @@ fn print_entry(entry: NeighbourMessage) {
129129
})
130130
.unwrap();
131131

132-
println!("{:<30} {:<20} ({})", dest, lladdr, state);
132+
println!("{dest:<30} {lladdr:<20} ({state})");
133133
}

examples/dump_packet_link_bridge_vlan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn main() {
3333
assert!(buf.len() == packet.buffer_len());
3434
packet.serialize(&mut buf[..]);
3535

36-
println!(">>> {:?}", packet);
36+
println!(">>> {packet:?}");
3737
socket.send(&buf[..], 0).unwrap();
3838

3939
let mut receive_buffer = vec![0; 4096];
@@ -63,7 +63,7 @@ fn main() {
6363
let rx_packet: NetlinkMessage<RtnlMessage> =
6464
NetlinkMessage::deserialize(bytes).unwrap();
6565

66-
println!("<<< {:?}", rx_packet);
66+
println!("<<< {rx_packet:?}");
6767

6868
if rx_packet.payload == NetlinkPayload::Done {
6969
println!("Done!");

examples/dump_packet_links.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
assert!(buf.len() == packet.buffer_len());
3030
packet.serialize(&mut buf[..]);
3131

32-
println!(">>> {:?}", packet);
32+
println!(">>> {packet:?}");
3333
socket.send(&buf[..], 0).unwrap();
3434

3535
let mut receive_buffer = vec![0; 4096];
@@ -59,7 +59,7 @@ fn main() {
5959
let rx_packet: NetlinkMessage<RtnlMessage> =
6060
NetlinkMessage::deserialize(bytes).unwrap();
6161

62-
println!("<<< {:?}", rx_packet);
62+
println!("<<< {rx_packet:?}");
6363

6464
if rx_packet.payload == NetlinkPayload::Done {
6565
println!("Done!");

examples/dump_rules.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ fn main() {
3333

3434
packet.serialize(&mut buf[..]);
3535

36-
println!(">>> {:?}", packet);
36+
println!(">>> {packet:?}");
3737
if let Err(e) = socket.send(&buf[..], 0) {
38-
println!("SEND ERROR {}", e);
38+
println!("SEND ERROR {e}");
3939
}
4040

4141
let mut receive_buffer = vec![0; 4096];
@@ -48,7 +48,7 @@ fn main() {
4848
let bytes = &receive_buffer[offset..];
4949
let rx_packet =
5050
<NetlinkMessage<RtnlMessage>>::deserialize(bytes).unwrap();
51-
println!("<<< {:?}", rx_packet);
51+
println!("<<< {rx_packet:?}");
5252

5353
if rx_packet.payload == NetlinkPayload::Done {
5454
println!("Done!");

examples/new_rule.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() {
3737

3838
msg.serialize(&mut buf[..msg.buffer_len()]);
3939

40-
println!(">>> {:?}", msg);
40+
println!(">>> {msg:?}");
4141

4242
socket
4343
.send(&buf, 0)
@@ -48,10 +48,10 @@ fn main() {
4848
while let Ok(_size) = socket.recv(&mut receive_buffer, 0) {
4949
let bytes = &receive_buffer[..];
5050
let rx_packet = <NetlinkMessage<RtnlMessage>>::deserialize(bytes);
51-
println!("<<< {:?}", rx_packet);
51+
println!("<<< {rx_packet:?}");
5252
if let Ok(rx_packet) = rx_packet {
5353
if let NetlinkPayload::Error(e) = rx_packet.payload {
54-
eprintln!("{:?}", e);
54+
eprintln!("{e:?}");
5555
} else {
5656
return;
5757
}

src/rtnl/address/nlas/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for Nla {
122122
}
123123
kind => Other(
124124
DefaultNla::parse(buf)
125-
.context(format!("unknown NLA type {}", kind))?,
125+
.context(format!("unknown NLA type {kind}"))?,
126126
),
127127
})
128128
}

src/rtnl/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized>
174174
}
175175
}
176176

177-
_ => return Err(format!("Unknown message type: {}", message_type).into()),
177+
_ => return Err(format!("Unknown message type: {message_type}").into()),
178178
};
179179
Ok(message)
180180
}

src/rtnl/link/nlas/af_spec_bridge.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for AfSpecBridge {
6868
),
6969
kind => Other(
7070
DefaultNla::parse(buf)
71-
.context(format!("Unknown NLA type {}", kind))?,
71+
.context(format!("Unknown NLA type {kind}"))?,
7272
),
7373
})
7474
}
@@ -95,18 +95,15 @@ impl TryFrom<&[u8]> for BridgeVlanInfo {
9595
if raw.len() == 4 {
9696
Ok(Self {
9797
flags: parse_u16(&raw[0..2]).context(format!(
98-
"Invalid IFLA_BRIDGE_VLAN_INFO value: {:?}",
99-
raw
98+
"Invalid IFLA_BRIDGE_VLAN_INFO value: {raw:?}"
10099
))?,
101100
vid: parse_u16(&raw[2..4]).context(format!(
102-
"Invalid IFLA_BRIDGE_VLAN_INFO value: {:?}",
103-
raw
101+
"Invalid IFLA_BRIDGE_VLAN_INFO value: {raw:?}"
104102
))?,
105103
})
106104
} else {
107105
Err(DecodeError::from(format!(
108-
"Invalid IFLA_BRIDGE_VLAN_INFO value, expecting [u8;4], but got {:?}",
109-
raw
106+
"Invalid IFLA_BRIDGE_VLAN_INFO value, expecting [u8;4], but got {raw:?}"
110107
)))
111108
}
112109
}

src/rtnl/link/nlas/af_spec_inet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for AfSpecInet {
255255
AF_ALG => Alg(payload.to_vec()),
256256
kind => Other(
257257
DefaultNla::parse(buf)
258-
.context(format!("Unknown NLA type {}", kind))?,
258+
.context(format!("Unknown NLA type {kind}"))?,
259259
),
260260
})
261261
}

src/rtnl/link/nlas/bridge.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,14 +559,12 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
559559
Ok(v) => {
560560
return Err(DecodeError::from(format!(
561561
"Invalid BRIDGE_QUERIER_IP_ADDRESS, \
562-
expecting IPv4 address, but got {}",
563-
v
562+
expecting IPv4 address, but got {v}"
564563
)))
565564
}
566565
Err(e) => {
567566
return Err(DecodeError::from(format!(
568-
"Invalid BRIDGE_QUERIER_IP_ADDRESS {}",
569-
e
567+
"Invalid BRIDGE_QUERIER_IP_ADDRESS {e}"
570568
)))
571569
}
572570
},
@@ -575,14 +573,12 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
575573
Ok(v) => {
576574
return Err(DecodeError::from(format!(
577575
"Invalid BRIDGE_QUERIER_IPV6_ADDRESS, \
578-
expecting IPv6 address, but got {}",
579-
v
576+
expecting IPv6 address, but got {v}"
580577
)));
581578
}
582579
Err(e) => {
583580
return Err(DecodeError::from(format!(
584-
"Invalid BRIDGE_QUERIER_IPV6_ADDRESS {}",
585-
e
581+
"Invalid BRIDGE_QUERIER_IPV6_ADDRESS {e}"
586582
)));
587583
}
588584
},
@@ -605,7 +601,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
605601

606602
kind => Other(
607603
DefaultNla::parse(buf)
608-
.context(format!("unknown NLA type {}", kind))?,
604+
.context(format!("unknown NLA type {kind}"))?,
609605
),
610606
})
611607
}

0 commit comments

Comments
 (0)