File tree 2 files changed +4
-5
lines changed
2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,8 @@ macro_rules! offset_of {
220
220
#[ macro_export]
221
221
macro_rules! container_of {
222
222
( $ptr: expr, $type: ty, $( $f: tt) * ) => { {
223
+ let ptr = $ptr as * const _ as * const u8 ;
223
224
let offset = $crate:: offset_of!( $type, $( $f) * ) ;
224
- unsafe { ( $ ptr as * const _ as * const u8 ) . offset( -offset) as * const $type }
225
+ unsafe { ptr. offset( -offset) as * const $type }
225
226
} }
226
227
}
Original file line number Diff line number Diff line change @@ -85,10 +85,8 @@ impl<T: Sync> FileOpenAdapter for Registration<T> {
85
85
type Arg = T ;
86
86
87
87
unsafe fn convert ( _inode : * mut bindings:: inode , file : * mut bindings:: file ) -> * const Self :: Arg {
88
- // TODO: `SAFETY` comment required here even if `unsafe` is not present,
89
- // because `container_of!` hides it. Ideally we would not allow
90
- // `unsafe` code as parameters to macros.
91
- let reg = crate :: container_of!( ( * file) . private_data, Self , mdev) ;
88
+ // SAFETY: the caller must guarantee that `file` is valid.
89
+ let reg = crate :: container_of!( unsafe { ( * file) . private_data } , Self , mdev) ;
92
90
unsafe { & ( * reg) . context }
93
91
}
94
92
}
You can’t perform that action at this time.
0 commit comments