Skip to content

Commit

Permalink
fix rust warnings. (#82)
Browse files Browse the repository at this point in the history
* Update derive_more requirement from 0.15 to 0.99
* fix rust warnings.
  • Loading branch information
spinpx authored Dec 16, 2019
1 parent e343f04 commit cd5439f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 33 deletions.
2 changes: 1 addition & 1 deletion fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ byteorder = "1.2"
chrono = "0.4"
priority-queue = "0.6"
num_cpus = "1.0"
derive_more = "0.15"
derive_more = "0.99"
colored = "1.6"
serde="1.0"
serde_derive = "1.0"
Expand Down
3 changes: 1 addition & 2 deletions fuzzer/src/bind_cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ pub fn bind_thread_to_cpu_core(_cid: usize) {

#[cfg(target_os = "linux")]
pub fn bind_thread_to_cpu_core(cid: usize) {
// let tid = unsafe { libc::pthread_self() };
unsafe {
let mut c: libc::cpu_set_t = mem::uninitialized();
let mut c: libc::cpu_set_t = mem::zeroed();
libc::CPU_ZERO(&mut c);
libc::CPU_SET(cid, &mut c);
if libc::sched_setaffinity(0, mem::size_of_val(&c), &c as *const libc::cpu_set_t) != 0 {
Expand Down
6 changes: 3 additions & 3 deletions fuzzer/src/executor/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl SetLimit for Command {
Ok(())
};

self.before_exec(func)
unsafe { self.pre_exec(func) }
}

fn setsid(&mut self) -> &mut Self {
Expand All @@ -50,7 +50,7 @@ impl SetLimit for Command {
};
Ok(())
};
self.before_exec(func)
unsafe { self.pre_exec(func) }
}

fn pipe_stdin(&mut self, fd: RawFd, is_stdin: bool) -> &mut Self {
Expand All @@ -65,7 +65,7 @@ impl SetLimit for Command {
}
Ok(())
};
self.before_exec(func)
unsafe { self.pre_exec(func) }
} else {
self
}
Expand Down
38 changes: 13 additions & 25 deletions fuzzer/src/track/load_pin_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,26 @@ use angora_common::tag::TagSeg;
use std::fs::File;
use std::io::{self, Read};
use std::{collections::HashMap, path::Path};
use std::mem::MaybeUninit;
use std;

fn read_struct<T, R: Read>(mut read: R) -> io::Result<T> {
let num_bytes = ::std::mem::size_of::<T>();
unsafe {
let mut s = ::std::mem::uninitialized();
let buffer = ::std::slice::from_raw_parts_mut(&mut s as *mut T as *mut u8, num_bytes);
match read.read_exact(buffer) {
Ok(()) => Ok(s),
Err(e) => {
::std::mem::forget(s);
Err(e)
}
}
}
let mut obj = MaybeUninit::<T>::uninit();
let num_bytes = std::mem::size_of::<T>();
let buffer = unsafe{ std::slice::from_raw_parts_mut(obj.as_mut_ptr() as *mut u8, num_bytes) };
read.read_exact(buffer)?;
Ok(unsafe { obj.assume_init() })
}

fn read_vector<T, R: Read>(mut read: R, size: usize) -> io::Result<Vec<T>> {
let mut vec = Vec::<T>::with_capacity(size);
if size > 0 {
unsafe {
vec.set_len(size);
let num_bytes = ::std::mem::size_of::<T>() * size;
let buffer =
::std::slice::from_raw_parts_mut((&mut vec[..]).as_ptr() as *mut u8, num_bytes);
match read.read_exact(buffer) {
Ok(()) => Ok(vec),
Err(e) => Err(e),
}
}
} else {
Ok(vec)
}
let num_bytes = std::mem::size_of::<T>() * size;
unsafe { vec.set_len(size) };
let buffer = unsafe {std::slice::from_raw_parts_mut((&mut vec[..]).as_mut_ptr() as *mut u8, num_bytes) } ;
read.read_exact(buffer)?;
}
Ok(vec)
}

pub fn get_log_data_pin(out_f: &Path) -> io::Result<LogData> {
Expand Down
5 changes: 3 additions & 2 deletions runtime_fast/src/fast.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use super::{shm_conds, forkcli, shm_branches};
use std::ops::DerefMut;

use std::sync::{Once, ONCE_INIT};
static START: Once = ONCE_INIT;
use std::sync::Once;

static START: Once = Once::new();

#[ctor]
fn fast_init() {
Expand Down

0 comments on commit cd5439f

Please sign in to comment.