properly shuts down server streams #176
clippy
32 warnings
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 0 |
Warning | 32 |
Note | 0 |
Help | 0 |
Versions
- rustc 1.81.0 (eeb90cda1 2024-09-04)
- cargo 1.81.0 (2dbb1af80 2024-08-20)
- clippy 0.1.81 (eeb90cd 2024-09-04)
Annotations
Check warning on line 93 in ex3_obc_fsw/dev_tools/ipc_dummy_client/src/main.rs
github-actions / clippy
this `if` statement can be collapsed
warning: this `if` statement can be collapsed
--> ex3_obc_fsw/dev_tools/ipc_dummy_client/src/main.rs:66:13
|
66 | / if poll_fd.revents != 0 {
67 | | if poll_fd.revents & libc::POLLIN != 0 {
68 | | if poll_fd.fd == tcp_fd {
69 | | let mut tcp_buf = vec![0u8; BUFFER_SIZE];
... |
92 | | }
93 | | }
| |_____________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
= note: `#[warn(clippy::collapsible_if)]` on by default
help: collapse nested if block
|
66 ~ if poll_fd.revents != 0 && poll_fd.revents & libc::POLLIN != 0 {
67 + if poll_fd.fd == tcp_fd {
68 + let mut tcp_buf = vec![0u8; BUFFER_SIZE];
69 + let ret = tcp_stream.read(&mut tcp_buf).unwrap();
70 +
71 + if ret == 0 {
72 + println!("TCP client disconnected. Exiting...");
73 + return;
74 + } else {
75 + write(data_socket_fd, &tcp_buf[..ret]).unwrap_or_else(|_| {
76 + eprintln!("write error");
77 + process::exit(1);
78 + });
79 + }
80 + } else if poll_fd.fd == data_socket_fd {
81 + let mut socket_buf = vec![0u8; BUFFER_SIZE];
82 + let ret = read(data_socket_fd, &mut socket_buf).unwrap();
83 +
84 + if ret == 0 {
85 + println!("Connection to Unix server dropped. Exiting...");
86 + process::exit(0);
87 + } else {
88 + println!("Received: {}", String::from_utf8_lossy(&socket_buf[..ret]));
89 + }
90 + }
91 + }
|
Check warning on line 347 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
the loop variable `index` is only used to index `response`
warning: the loop variable `index` is only used to index `response`
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:347:22
|
347 | for index in 0..packet_length {
| ^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
help: consider using an iterator
|
347 | for <item> in response.iter_mut().take(packet_length) {
| ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Check warning on line 340 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
the loop variable `index` is only used to index `packet_buffer`
warning: the loop variable `index` is only used to index `packet_buffer`
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:340:22
|
340 | for index in 0..temp_length { // Read the final partial packet
| ^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
help: consider using an iterator
|
340 | for <item> in packet_buffer.iter_mut().take(temp_length) { // Read the final partial packet
| ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Check warning on line 338 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
manual implementation of an assign operation
warning: manual implementation of an assign operation
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:338:13
|
338 | temp_length = temp_length - IRIS_INTERFACE_BUFFER_SIZE;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `temp_length -= IRIS_INTERFACE_BUFFER_SIZE`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
Check warning on line 318 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
manual implementation of an assign operation
warning: manual implementation of an assign operation
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:318:13
|
318 | flag_match = flag_match + 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `flag_match += 1`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
= note: `#[warn(clippy::assign_op_pattern)]` on by default
Check warning on line 354 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:354:5
|
354 | return Ok(packet_length);
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
|
354 - return Ok(packet_length);
354 + Ok(packet_length)
|
Check warning on line 289 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
unneeded late initialization
warning: unneeded late initialization
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:289:5
|
289 | let response: String;
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
help: move the declaration `response` here and remove the assignments from the `match` arms
|
289 ~
290 ~ let response: String = match status {
291 ~ Ok(result) => { result.trim_matches(char::from(0)).to_string() }
292 | Err(_) => { return Err(Error::new(ErrorKind::InvalidData, "image name improper")); }
293 ~ };
|
Check warning on line 276 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
unneeded late initialization
warning: unneeded late initialization
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:276:13
|
276 | let image: &str;
| ^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
= note: `#[warn(clippy::needless_late_init)]` on by default
help: move the declaration `image` here and remove the assignments from the `match` arms
|
276 ~
277 ~ let image: &str = match status {
278 ~ Ok(image_name) => { image_name.trim_matches(char::from(0)) }
279 | Err(_) => { return Err(Error::new(ErrorKind::InvalidData, "image name improper")); }
280 ~ };
|
Check warning on line 76 in ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs
github-actions / clippy
useless use of `vec!`
warning: useless use of `vec!`
--> ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs:76:33
|
76 | poll_ipc_server_sockets(&mut vec![&mut ipc_server]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [&mut ipc_server]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec
= note: `#[warn(clippy::useless_vec)]` on by default
Check warning on line 93 in ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs
github-actions / clippy
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs:85:9
|
85 | / match stdin_read_res {
86 | | Some(bytes_read) => {
87 | | if bytes_read > 0 {
88 | | println!("Received user input: {:?}", stdin_buf);
... |
92 | | None => (),
93 | | }
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
= note: `#[warn(clippy::single_match)]` on by default
help: try
|
85 ~ if let Some(bytes_read) = stdin_read_res {
86 + if bytes_read > 0 {
87 + println!("Received user input: {:?}", stdin_buf);
88 + handle_user_input(stdin_buf.as_slice(), &mut ipc_server);
89 + }
90 + }
|
Check warning on line 269 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
the loop variable `i` is only used to index `packet_content`
warning: the loop variable `i` is only used to index `packet_content`
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:269:18
|
269 | for i in 7..packet_len{
| ^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
= note: `#[warn(clippy::needless_range_loop)]` on by default
help: consider using an iterator
|
269 | for <item> in packet_content.iter().take(packet_len).skip(7){
| ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Check warning on line 56 in ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs:56:36
|
56 | match io::stdin().read(&mut buffer) {
| ^^^^^^^^^^^ help: change this to: `buffer`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 37 in ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs:37:43
|
37 | ipc_write(ipc_server.data_fd, &serialized_msg.as_slice())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `serialized_msg.as_slice()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 30 in ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> ex3_obc_fsw/dev_tools/ipc_server_dev_tool/src/main.rs:30:43
|
30 | ipc_write(ipc_server.data_fd, &serialized_msg.as_slice())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `serialized_msg.as_slice()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
Check warning on line 139 in ex3_obc_fsw/handlers/iris_handler/src/main.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> ex3_obc_fsw/handlers/iris_handler/src/main.rs:139:45
|
139 | let status = TcpInterface::send(&mut self.peripheral_interface.as_mut().unwrap(), command_msg.as_bytes());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.peripheral_interface.as_mut().unwrap()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
Check warning on line 11 in ex3_ground_station/dashboard/src/pages/command_history_page.rs
github-actions / clippy
redundant closure
warning: redundant closure
--> ex3_ground_station/dashboard/src/pages/command_history_page.rs:11:30
|
11 | let commands = use_state(|| Vec::new());
| ^^^^^^^^^^^^^ help: replace the closure with the function itself: `Vec::new`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
Check warning on line 119 in ex3_obc_fsw/handlers/dfgm_handler/src/main.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> ex3_obc_fsw/handlers/dfgm_handler/src/main.rs:119:49
|
119 | let status = TcpInterface::read(&mut self.peripheral_interface.as_mut().unwrap(), &mut tcp_buf);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.peripheral_interface.as_mut().unwrap()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
Check warning on line 117 in ex3_obc_fsw/handlers/dfgm_handler/src/main.rs
github-actions / clippy
equality checks against true are unnecessary
warning: equality checks against true are unnecessary
--> ex3_obc_fsw/handlers/dfgm_handler/src/main.rs:117:16
|
117 | if self.toggle_data_collection == true {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `self.toggle_data_collection`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_comparison
= note: `#[warn(clippy::bool_comparison)]` on by default
Check warning on line 35 in ex3_ground_station/dashboard/src/components/command_form.rs
github-actions / clippy
redundant closure
warning: redundant closure
--> ex3_ground_station/dashboard/src/components/command_form.rs:35:29
|
35 | let command = use_state(|| Command::default());
| ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `Command::default`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
= note: `#[warn(clippy::redundant_closure)]` on by default
Check warning on line 202 in ex3_obc_fsw/handlers/coms_handler/src/main.rs
github-actions / clippy
this let-binding has unit value
warning: this let-binding has unit value
--> ex3_obc_fsw/handlers/coms_handler/src/main.rs:202:25
|
202 | let _ = write_msg_to_uhf_for_downlink(&mut tcp_interface, deserialized_msg);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `write_msg_to_uhf_for_downlink(&mut tcp_interface, deserialized_msg);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
= note: `#[warn(clippy::let_unit_value)]` on by default
Check warning on line 118 in ex3_obc_fsw/handlers/coms_handler/src/main.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> ex3_obc_fsw/handlers/coms_handler/src/main.rs:118:17
|
118 | init_logger(&log_path);
| ^^^^^^^^^ help: change this to: `log_path`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
Check warning on line 30 in ex3_obc_fsw/handlers/coms_handler/src/main.rs
github-actions / clippy
writing `&Vec` instead of `&[_]` involves a new object where a slice will do
warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
--> ex3_obc_fsw/handlers/coms_handler/src/main.rs:30:43
|
30 | fn decrypt_bytes_from_gs(encrypted_bytes: &Vec<u8>) -> Result<Vec<u8>, std::io::Error> {
| ^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
= note: `#[warn(clippy::ptr_arg)]` on by default
help: change this to
|
30 ~ fn decrypt_bytes_from_gs(encrypted_bytes: &[u8]) -> Result<Vec<u8>, std::io::Error> {
31 | // TODO - Decrypt the message
32 ~ let decrypted_byte_vec = encrypted_bytes.to_owned();
|
Check warning on line 246 in ex3_ground_station/cli_ground_station/src/main.rs
github-actions / clippy
equality checks against true are unnecessary
warning: equality checks against true are unnecessary
--> ex3_ground_station/cli_ground_station/src/main.rs:246:27
|
246 | while *awaiting_ack.lock().await == true {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `*awaiting_ack.lock().await`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_comparison
Check warning on line 226 in ex3_ground_station/cli_ground_station/src/main.rs
github-actions / clippy
casting to the same type is unnecessary (`i16` -> `i16`)
warning: casting to the same type is unnecessary (`i16` -> `i16`)
--> ex3_ground_station/cli_ground_station/src/main.rs:226:40
|
226 | if ret > 0 && fds[0].revents & POLLIN as i16 != 0 {
| ^^^^^^^^^^^^^ help: try: `POLLIN`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
Check warning on line 220 in ex3_ground_station/cli_ground_station/src/main.rs
github-actions / clippy
casting to the same type is unnecessary (`i16` -> `i16`)
warning: casting to the same type is unnecessary (`i16` -> `i16`)
--> ex3_ground_station/cli_ground_station/src/main.rs:220:21
|
220 | events: POLLIN as i16,
| ^^^^^^^^^^^^^ help: try: `POLLIN`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
= note: `#[warn(clippy::unnecessary_cast)]` on by default