Fix clippy warnings (#37)
* fix some clippy warnings * add a actions job for linting * remove needless line * add `run-on` to build_and_test.yml
This commit is contained in:
parent
6e4c6a9b6b
commit
39d33ce7ff
21
.github/workflows/build_and_test.yml
vendored
21
.github/workflows/build_and_test.yml
vendored
@ -10,6 +10,27 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: clippy-cargo-${{ hashFiles('**/Cargo.toml') }}
|
||||
- name: Add clippy
|
||||
run: rustup component add clippy
|
||||
- name: Run clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --all
|
||||
ubuntu:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
|
@ -1018,7 +1018,7 @@ where
|
||||
/* We can reuse the map mem space, no need to free and calloc.
|
||||
However, the pageinfo points to the map we're about to unmap.
|
||||
Clone the contents first to be safe (probably fine in rust eitner way). */
|
||||
let pageinfo_cpy = (*pageinfo).clone();
|
||||
let pageinfo_cpy = *pageinfo;
|
||||
|
||||
// Mark the old page save to unmap, in case we didn't so earlier.
|
||||
ptr::write_volatile(&mut (*page).save_to_unmap, 1);
|
||||
@ -1434,7 +1434,7 @@ where
|
||||
// to read from the initial map id.
|
||||
|
||||
let client_out_map_mem = &self.llmp_out.out_maps.first().unwrap().shmem;
|
||||
let broadcast_str_initial = client_out_map_mem.shm_slice().clone();
|
||||
let broadcast_str_initial = *client_out_map_mem.shm_slice();
|
||||
|
||||
let llmp_tcp_id = self.llmp_clients.len() as u32;
|
||||
|
||||
|
@ -370,7 +370,7 @@ pub mod unix_shmem {
|
||||
// Not set or not initialized;
|
||||
return;
|
||||
}
|
||||
(*shm).shm_str[0 as usize] = 0u8;
|
||||
(*shm).shm_str[0_usize] = 0u8;
|
||||
shmctl((*shm).shm_id, 0 as c_int, ptr::null_mut());
|
||||
(*shm).map = ptr::null_mut();
|
||||
}
|
||||
|
@ -223,10 +223,7 @@ mod unix_signal_handler {
|
||||
use core::ptr;
|
||||
use libc::{c_void, siginfo_t};
|
||||
#[cfg(feature = "std")]
|
||||
use std::{
|
||||
fs,
|
||||
io::{stdout, Write},
|
||||
};
|
||||
use std::io::{stdout, Write};
|
||||
|
||||
use crate::{
|
||||
bolts::os::unix_signals::{Handler, Signal},
|
||||
@ -443,7 +440,7 @@ mod unix_signal_handler {
|
||||
}
|
||||
// let's yolo-cat the maps for debugging, if possible.
|
||||
#[cfg(all(target_os = "linux", feature = "std"))]
|
||||
match fs::read_to_string("/proc/self/maps") {
|
||||
match std::fs::read_to_string("/proc/self/maps") {
|
||||
Ok(maps) => println!("maps:\n{}", maps),
|
||||
Err(e) => println!("Couldn't load mappings: {:?}", e),
|
||||
};
|
||||
|
@ -752,13 +752,13 @@ where
|
||||
|
||||
// Converts a hex u8 to its u8 value: 'A' -> 10 etc.
|
||||
fn from_hex(hex: u8) -> Result<u8, Error> {
|
||||
if hex >= 48 && hex <= 57 {
|
||||
if (48..=57).contains(&hex) {
|
||||
return Ok(hex - 48);
|
||||
}
|
||||
if hex >= 65 && hex <= 70 {
|
||||
if (65..=70).contains(&hex) {
|
||||
return Ok(hex - 55);
|
||||
}
|
||||
if hex >= 97 && hex <= 102 {
|
||||
if (97..=102).contains(&hex) {
|
||||
return Ok(hex - 87);
|
||||
}
|
||||
Err(Error::IllegalArgument("".to_owned()))
|
||||
@ -781,17 +781,15 @@ pub fn str_decode(item: &str) -> Result<Vec<u8>, Error> {
|
||||
decoded += from_hex(c)?;
|
||||
token.push(decoded);
|
||||
take_next_two = 0;
|
||||
} else {
|
||||
if c != backslash || take_next {
|
||||
if take_next && (c == 120 || c == 88) {
|
||||
take_next_two = 1;
|
||||
} else {
|
||||
token.push(c);
|
||||
}
|
||||
take_next = false;
|
||||
} else if c != backslash || take_next {
|
||||
if take_next && (c == 120 || c == 88) {
|
||||
take_next_two = 1;
|
||||
} else {
|
||||
take_next = true;
|
||||
token.push(c);
|
||||
}
|
||||
take_next = false;
|
||||
} else {
|
||||
take_next = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user