Skip to content

Commit 285300c

Browse files
committed
rust: clippy fixups for 1.97
Mostly provided by clippy --fix, and one `.to_string()` removal where not needed.
1 parent 842b14e commit 285300c

8 files changed

Lines changed: 19 additions & 23 deletions

File tree

rust/src/detect/requires.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ pub unsafe extern "C" fn SCDetectRequiresStatusLog(
410410
"rule was"
411411
},
412412
suricata_version,
413-
&min_version
413+
min_version
414414
);
415415
parts.push(msg);
416416
}
@@ -447,7 +447,7 @@ pub unsafe extern "C" fn SCDetectRequiresStatusLog(
447447
"rule was"
448448
},
449449
if status.feature_count > 1 { "s" } else { "" },
450-
&features
450+
features
451451
);
452452
parts.push(msg);
453453
}

rust/src/http2/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn log_http2_frames(frames: &[HTTP2Frame], js: &mut JsonBuilder) -> Result<bool,
128128
js.start_object()?;
129129
js.set_string(
130130
"settings_id",
131-
&format!("SETTINGS{}", &e.id.to_string().to_uppercase()),
131+
&format!("SETTINGS{}", e.id.to_string().to_uppercase()),
132132
)?;
133133
js.set_uint("settings_value", e.value as u64)?;
134134
js.close()?;

rust/src/jsonbuilder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl JsonBuilder {
172172
// Reset the builder to its initial state, without losing
173173
// the current capacity.
174174
pub fn reset(&mut self) {
175-
self.buf.truncate(0);
175+
self.buf.clear();
176176
self.state.clear();
177177
match self.init_type {
178178
Type::Array => {
@@ -1618,6 +1618,4 @@ static ESCAPED: [u8; 256] = [
16181618
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // F
16191619
];
16201620

1621-
pub static HEX: [u8; 16] = [
1622-
b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd', b'e', b'f',
1623-
];
1621+
pub static HEX: [u8; 16] = *b"0123456789abcdef";

rust/src/mime/mime.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,11 @@ pub fn mime_find_header_token<'a>(
117117
// check for initial section of a parameter
118118
current_section_slice.extend_from_slice(token);
119119
current_section_slice.extend_from_slice(b"*0");
120-
match t.tokens.get(&current_section_slice[..]) {
121-
Some(value) => {
122-
sections_values.extend_from_slice(value);
123-
let l = current_section_slice.len();
124-
current_section_slice[l - 1] = b'1';
125-
}
126-
None => return None,
120+
{
121+
let value = t.tokens.get(&current_section_slice[..])?;
122+
sections_values.extend_from_slice(value);
123+
let l = current_section_slice.len();
124+
current_section_slice[l - 1] = b'1';
127125
}
128126
}
129127
}

rust/src/sdp/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ fn parse_connection_data(i: &[u8]) -> IResult<&[u8], String> {
264264

265265
let mut connection_data = format!(
266266
"{} {} {}",
267-
&nettype,
268-
&addrtype,
269-
&connection_address.to_string()
267+
nettype,
268+
addrtype,
269+
connection_address
270270
);
271271
if let Some(ttl) = ttl {
272272
connection_data = format!("{}/{}", connection_data, ttl);
@@ -477,7 +477,7 @@ fn parse_media_description(i: &[u8]) -> IResult<&[u8], MediaDescription> {
477477
} else {
478478
format!("{}", port)
479479
};
480-
let mut media_str = format!("{} {} {}", &media, &port, &proto);
480+
let mut media_str = format!("{} {} {}", media, port, proto);
481481
if !fmt.is_empty() {
482482
let fmt: Vec<String> = fmt.into_iter().map(String::from).collect();
483483
media_str = format!("{} {}", media_str, fmt.join(" "));

rust/src/ssh/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub struct SshPacketKeyExchange<'a> {
162162
pub reserved: u32,
163163
}
164164

165-
const SSH_HASSH_STRING_DELIMITER_SLICE: [u8; 1] = [b';'];
165+
const SSH_HASSH_STRING_DELIMITER_SLICE: [u8; 1] = *b";";
166166

167167
impl SshPacketKeyExchange<'_> {
168168
pub fn generate_hassh(

rust/suricatasc/src/unix/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Client {
6262
{
6363
let mut encoded = serde_json::to_string(&msg)?;
6464
if self.verbose {
65-
println!("SND: {}", &encoded);
65+
println!("SND: {}", encoded);
6666
}
6767
encoded.push('\n');
6868
self.socket.write_all(encoded.as_bytes())?;

rust/suricatasc/src/unix/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
3939

4040
let verbose = args.verbose;
4141
if verbose {
42-
println!("Using Suricata command socket: {}", &socket_filename);
42+
println!("Using Suricata command socket: {}", socket_filename);
4343
}
4444

4545
let client = match Client::connect(&socket_filename, verbose) {
4646
Ok(client) => client,
4747
Err(err) => {
48-
eprintln!("Unable to connect socket to {}: {}", &socket_filename, err);
48+
eprintln!("Unable to connect socket to {}: {}", socket_filename, err);
4949
std::process::exit(1);
5050
}
5151
};
@@ -95,7 +95,7 @@ fn run_interactive(mut client: Client) -> Result<(), Box<dyn std::error::Error>>
9595
break;
9696
}
9797
if let Err(err) = client.reconnect() {
98-
println!("Error: {}", &err);
98+
println!("Error: {}", err);
9999
break;
100100
} else {
101101
retry = true;

0 commit comments

Comments
 (0)