Browse Source

Fix clippy and rustfmt errors

Davide Della Giustina 2 years ago
parent
commit
aec718a08f

+ 3 - 1
examples/benchmark.rs

@@ -94,7 +94,9 @@ fn main() {
 
     let ethernet_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x01]);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
+        .unwrap();
     let medium = device.capabilities().medium;
     let mut builder = InterfaceBuilder::new().ip_addrs(ip_addrs);
     if medium == Medium::Ethernet {

+ 3 - 1
examples/client.rs

@@ -43,7 +43,9 @@ fn main() {
 
     let ethernet_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x02]);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(IpAddress::v4(192, 168, 69, 2), 24)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(192, 168, 69, 2), 24))
+        .unwrap();
     let default_v4_gw = Ipv4Address::new(192, 168, 69, 100);
     let mut routes_storage = [None; 1];
     let mut routes = Routes::new(&mut routes_storage[..]);

+ 3 - 1
examples/dhcp_client.rs

@@ -31,7 +31,9 @@ fn main() {
     let neighbor_cache = NeighborCache::new(BTreeMap::new());
     let ethernet_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x01]);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(Ipv4Address::UNSPECIFIED.into(), 0)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(Ipv4Address::UNSPECIFIED.into(), 0))
+        .unwrap();
     let mut routes_storage = [None; 1];
     let routes = Routes::new(&mut routes_storage[..]);
 

+ 6 - 2
examples/dns.rs

@@ -44,9 +44,13 @@ fn main() {
     let ethernet_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x02]);
     let src_ipv6 = IpAddress::v6(0xfdaa, 0, 0, 0, 0, 0, 0, 1);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
+        .unwrap();
     ip_addrs.push(IpCidr::new(src_ipv6, 64)).unwrap();
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
     let default_v4_gw = Ipv4Address::new(192, 168, 69, 100);
     let default_v6_gw = Ipv6Address::new(0xfe80, 0, 0, 0, 0, 0, 0, 0x100);
     let mut routes_storage = [None; 2];

+ 9 - 3
examples/httpclient.rs

@@ -37,9 +37,15 @@ fn main() {
 
     let ethernet_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x02]);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24)).unwrap();
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfdaa, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
+        .unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfdaa, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
     let default_v4_gw = Ipv4Address::new(192, 168, 69, 100);
     let default_v6_gw = Ipv6Address::new(0xfe80, 0, 0, 0, 0, 0, 0, 0x100);
     let mut routes_storage = [None; 2];

+ 3 - 1
examples/loopback.rs

@@ -86,7 +86,9 @@ fn main() {
     let mut neighbor_cache = NeighborCache::new(&mut neighbor_cache_entries[..]);
 
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8))
+        .unwrap();
     let mut iface = InterfaceBuilder::new()
         .hardware_addr(EthernetAddress::default().into())
         .neighbor_cache(neighbor_cache)

+ 6 - 2
examples/ping.rs

@@ -117,9 +117,13 @@ fn main() {
     let ethernet_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x02]);
     let src_ipv6 = IpAddress::v6(0xfdaa, 0, 0, 0, 0, 0, 0, 1);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
+        .unwrap();
     ip_addrs.push(IpCidr::new(src_ipv6, 64)).unwrap();
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
     let default_v4_gw = Ipv4Address::new(192, 168, 69, 100);
     let default_v6_gw = Ipv6Address::new(0xfe80, 0, 0, 0, 0, 0, 0, 0x100);
     let mut routes_storage = [None; 2];

+ 9 - 3
examples/server.rs

@@ -59,9 +59,15 @@ fn main() {
 
     let ethernet_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x01]);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24)).unwrap();
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfdaa, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
+        .unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfdaa, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
 
     let medium = device.capabilities().medium;
     let mut builder = InterfaceBuilder::new().ip_addrs(ip_addrs);

+ 6 - 4
examples/sixlowpan.rs

@@ -82,10 +82,12 @@ fn main() {
         0x1a, 0x0b, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
     ]);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(
-        IpAddress::v6(0xfe80, 0, 0, 0, 0x180b, 0x4242, 0x4242, 0x4242),
-        64,
-    )).unwrap();
+    ip_addrs
+        .push(IpCidr::new(
+            IpAddress::v6(0xfe80, 0, 0, 0, 0x180b, 0x4242, 0x4242, 0x4242),
+            64,
+        ))
+        .unwrap();
 
     let mut builder = InterfaceBuilder::new()
         .ip_addrs(ip_addrs)

+ 6 - 4
examples/sixlowpan_benchmark.rs

@@ -162,10 +162,12 @@ fn main() {
         0x1a, 0x0b, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
     ]);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
-    ip_addrs.push(IpCidr::new(
-        IpAddress::v6(0xfe80, 0, 0, 0, 0x180b, 0x4242, 0x4242, 0x4242),
-        64,
-    )).unwrap();
+    ip_addrs
+        .push(IpCidr::new(
+            IpAddress::v6(0xfe80, 0, 0, 0, 0x180b, 0x4242, 0x4242, 0x4242),
+            64,
+        ))
+        .unwrap();
 
     let cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
 

+ 3 - 2
src/iface/interface/mod.rs

@@ -1559,7 +1559,7 @@ impl<'a> InterfaceInner<'a> {
             },
             now: Instant::from_millis_const(0),
 
-            ip_addrs: Vec::from_slice(&vec![
+            ip_addrs: Vec::from_slice(&[
                 #[cfg(feature = "proto-ipv4")]
                 IpCidr::Ipv4(Ipv4Cidr::new(Ipv4Address::new(192, 168, 1, 1), 24)),
                 #[cfg(feature = "proto-ipv6")]
@@ -1567,7 +1567,8 @@ impl<'a> InterfaceInner<'a> {
                     Ipv6Address([0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
                     64,
                 )),
-            ]).unwrap(),
+            ])
+            .unwrap(),
             rand: Rand::new(1234),
             routes: Routes::new(&mut [][..]),
 

+ 33 - 10
src/iface/interface/tests.rs

@@ -44,11 +44,17 @@ fn create_ip<'a>() -> (Interface<'a>, SocketSet<'a>, Loopback) {
     let mut device = Loopback::new(Medium::Ip);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
     #[cfg(feature = "proto-ipv4")]
-    ip_addrs.push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8))
+        .unwrap();
     #[cfg(feature = "proto-ipv6")]
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0, 0, 0, 0, 0, 0, 0, 1), 128)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0, 0, 0, 0, 0, 0, 0, 1), 128))
+        .unwrap();
     #[cfg(feature = "proto-ipv6")]
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfdbe, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfdbe, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
 
     let iface_builder = InterfaceBuilder::new().ip_addrs(ip_addrs);
 
@@ -70,11 +76,17 @@ fn create_ethernet<'a>() -> (Interface<'a>, SocketSet<'a>, Loopback) {
     let mut device = Loopback::new(Medium::Ethernet);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
     #[cfg(feature = "proto-ipv4")]
-    ip_addrs.push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8))
+        .unwrap();
     #[cfg(feature = "proto-ipv6")]
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0, 0, 0, 0, 0, 0, 0, 1), 128)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0, 0, 0, 0, 0, 0, 0, 1), 128))
+        .unwrap();
     #[cfg(feature = "proto-ipv6")]
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfdbe, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfdbe, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
 
     let iface_builder = InterfaceBuilder::new()
         .hardware_addr(EthernetAddress::default().into())
@@ -104,9 +116,13 @@ fn create_ieee802154<'a>() -> (Interface<'a>, SocketSet<'a>, Loopback) {
     let mut device = Loopback::new(Medium::Ieee802154);
     let mut ip_addrs = heapless::Vec::<IpCidr, 4>::new();
     #[cfg(feature = "proto-ipv6")]
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0, 0, 0, 0, 0, 0, 0, 1), 128)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0, 0, 0, 0, 0, 0, 0, 1), 128))
+        .unwrap();
     #[cfg(feature = "proto-ipv6")]
-    ip_addrs.push(IpCidr::new(IpAddress::v6(0xfdbe, 0, 0, 0, 0, 0, 0, 1), 64)).unwrap();
+    ip_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfdbe, 0, 0, 0, 0, 0, 0, 1), 64))
+        .unwrap();
 
     let iface_builder = InterfaceBuilder::new()
         .hardware_addr(Ieee802154Address::default().into())
@@ -1048,8 +1064,15 @@ fn test_icmpv4_socket() {
 fn test_solicited_node_addrs() {
     let (mut iface, _, _device) = create(MEDIUM);
     let mut new_addrs = heapless::Vec::<IpCidr, 4>::new();
-    new_addrs.push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 1, 2, 0, 2), 64)).unwrap();
-    new_addrs.push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 3, 4, 0, 0xffff), 64)).unwrap();
+    new_addrs
+        .push(IpCidr::new(IpAddress::v6(0xfe80, 0, 0, 0, 1, 2, 0, 2), 64))
+        .unwrap();
+    new_addrs
+        .push(IpCidr::new(
+            IpAddress::v6(0xfe80, 0, 0, 0, 3, 4, 0, 0xffff),
+            64,
+        ))
+        .unwrap();
     iface.update_ip_addrs(|addrs| {
         new_addrs.extend(addrs.to_vec());
         *addrs = new_addrs;