dns: fix clippy lint warnings

Fix vector lint issues:
- same_item_push
- vec_init_then_push
pull/12287/head
Shivani Bhardwaj 10 months ago committed by Victor Julien
parent 89c9cec0bb
commit 2c0d3b83c4

@ -1089,11 +1089,10 @@ mod tests {
fn test_dns_parse_name_truncated() { fn test_dns_parse_name_truncated() {
// Generate a non-compressed hostname over our maximum of 1024. // Generate a non-compressed hostname over our maximum of 1024.
let mut buf: Vec<u8> = vec![]; let mut buf: Vec<u8> = vec![];
for _ in 0..17 {
for i in 1..18 {
buf.push(0b0011_1111); buf.push(0b0011_1111);
for _ in 0..63 { buf.resize(i * 64, b'a');
buf.push(b'a');
}
} }
let mut flags = DNSNameFlags::default(); let mut flags = DNSNameFlags::default();
@ -1120,20 +1119,21 @@ mod tests {
#[test] #[test]
fn test_dns_parse_name_truncated_max_segments_with_pointer() { fn test_dns_parse_name_truncated_max_segments_with_pointer() {
let mut buf: Vec<u8> = vec![]; #[rustfmt::skip]
let buf: Vec<u8> = vec![
// "a" at the beginning of the buffer. // "a" at the beginning of the buffer.
buf.push(0b0000_0001); 0b0000_0001,
buf.push(b'a'); b'a',
// Followed by a pointer back to the beginning. // Followed by a pointer back to the beginning.
buf.push(0b1100_0000); 0b1100_0000,
buf.push(0b0000_0000); 0b0000_0000,
// The start of the name, which is pointer to the beginning of // The start of the name, which is pointer to the beginning of
// the buffer. // the buffer.
buf.push(0b1100_0000); 0b1100_0000,
buf.push(0b000_0000); 0b000_0000
];
let mut flags = DNSNameFlags::default(); let mut flags = DNSNameFlags::default();
let (_rem, name) = dns_parse_name(&buf[4..], &buf, &mut flags).unwrap(); let (_rem, name) = dns_parse_name(&buf[4..], &buf, &mut flags).unwrap();
@ -1143,9 +1143,7 @@ mod tests {
#[test] #[test]
fn test_dns_parse_name_self_reference() { fn test_dns_parse_name_self_reference() {
let mut buf = vec![]; let buf = vec![0b1100_0000, 0b0000_0000];
buf.push(0b1100_0000);
buf.push(0b0000_0000);
let mut flags = DNSNameFlags::default(); let mut flags = DNSNameFlags::default();
assert!(dns_parse_name(&buf, &buf, &mut flags).is_err()); assert!(dns_parse_name(&buf, &buf, &mut flags).is_err());
} }

Loading…
Cancel
Save