Skip to content

Commit ba5d63e

Browse files
committed
fix lint and fmt
1 parent ccabda3 commit ba5d63e

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

examples/mutex.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ fn increment_value(shmem_flink: &str, thread_num: usize) {
5858

5959
let mut raw_ptr = shmem.as_ptr();
6060
let is_init: &mut AtomicU8;
61-
let mutex: Box<dyn LockImpl>;
6261

6362
unsafe {
6463
is_init = &mut *(raw_ptr as *mut u8 as *mut AtomicU8);
6564
raw_ptr = raw_ptr.add(8);
6665
};
6766

6867
// Initialize or wait for initialized mutex
69-
if shmem.is_owner() {
68+
let mutex = if shmem.is_owner() {
7069
is_init.store(0, Ordering::Relaxed);
7170
// Initialize the mutex
7271
let (lock, _bytes_used) = unsafe {
@@ -77,7 +76,7 @@ fn increment_value(shmem_flink: &str, thread_num: usize) {
7776
.unwrap()
7877
};
7978
is_init.store(1, Ordering::Relaxed);
80-
mutex = lock;
79+
lock
8180
} else {
8281
// wait until mutex is initialized
8382
while is_init.load(Ordering::Relaxed) != 1 {}
@@ -89,8 +88,8 @@ fn increment_value(shmem_flink: &str, thread_num: usize) {
8988
)
9089
.unwrap()
9190
};
92-
mutex = lock;
93-
}
91+
lock
92+
};
9493

9594
// Loop until mutex data reaches 10
9695
loop {

src/unix.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ pub fn create_mapping(unique_id: &str, map_size: usize) -> Result<MapData, Shmem
148148
}
149149

150150
/// Opens an existing mapping specified by its uid
151-
pub fn open_mapping(unique_id: &str, _map_size: usize, _ext: &ShmemConfExt) -> Result<MapData, ShmemError> {
151+
pub fn open_mapping(
152+
unique_id: &str,
153+
_map_size: usize,
154+
_ext: &ShmemConfExt,
155+
) -> Result<MapData, ShmemError> {
152156
//Open shared memory
153157
debug!("Openning persistent mapping at {}", unique_id);
154158
let shmem_fd = match shm_open(

0 commit comments

Comments
 (0)