File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,8 @@ impl Transaction {
78
78
let mut_tr = Arc :: get_mut ( & mut tr) . ok_or ( Error :: EINVAL ) ?;
79
79
80
80
// SAFETY: `inner` is pinned behind `Arc`.
81
- kernel:: spinlock_init!( Pin :: new_unchecked( & mut_tr. inner) , "Transaction::inner" ) ;
81
+ let pinned = unsafe { Pin :: new_unchecked ( & mut_tr. inner ) } ;
82
+ kernel:: spinlock_init!( pinned, "Transaction::inner" ) ;
82
83
Ok ( tr)
83
84
}
84
85
@@ -111,7 +112,8 @@ impl Transaction {
111
112
let mut_tr = Arc :: get_mut ( & mut tr) . ok_or ( Error :: EINVAL ) ?;
112
113
113
114
// SAFETY: `inner` is pinned behind `Arc`.
114
- kernel:: spinlock_init!( Pin :: new_unchecked( & mut_tr. inner) , "Transaction::inner" ) ;
115
+ let pinned = unsafe { Pin :: new_unchecked ( & mut_tr. inner ) } ;
116
+ kernel:: spinlock_init!( pinned, "Transaction::inner" ) ;
115
117
Ok ( tr)
116
118
}
117
119
Original file line number Diff line number Diff line change @@ -50,10 +50,12 @@ macro_rules! init_with_lockdep {
50
50
( $obj: expr, $name: literal) => { {
51
51
static mut CLASS : core:: mem:: MaybeUninit <$crate:: bindings:: lock_class_key> =
52
52
core:: mem:: MaybeUninit :: uninit( ) ;
53
+ let obj = $obj;
54
+ let name = $crate:: c_str!( $name) ;
53
55
// SAFETY: `CLASS` is never used by Rust code directly; the kernel may change it though.
54
56
#[ allow( unused_unsafe) ]
55
57
unsafe {
56
- $crate:: sync:: NeedsLockClass :: init( $ obj, $crate :: c_str! ( $ name) , CLASS . as_mut_ptr( ) )
58
+ $crate:: sync:: NeedsLockClass :: init( obj, name, CLASS . as_mut_ptr( ) )
57
59
} ;
58
60
} } ;
59
61
}
Original file line number Diff line number Diff line change @@ -133,10 +133,12 @@ impl KernelModule for RustSemaphore {
133
133
} ,
134
134
|sema| {
135
135
// SAFETY: `changed` is pinned when `sema` is.
136
- condvar_init ! ( Pin :: new_unchecked( & sema. changed) , "Semaphore::changed" ) ;
136
+ let pinned = unsafe { Pin :: new_unchecked ( & sema. changed ) } ;
137
+ condvar_init ! ( pinned, "Semaphore::changed" ) ;
137
138
138
139
// SAFETY: `inner` is pinned when `sema` is.
139
- mutex_init ! ( Pin :: new_unchecked( & sema. inner) , "Semaphore::inner" ) ;
140
+ let pinned = unsafe { Pin :: new_unchecked ( & sema. inner ) } ;
141
+ mutex_init ! ( pinned, "Semaphore::inner" ) ;
140
142
} ,
141
143
) ?;
142
144
You can’t perform that action at this time.
0 commit comments