@@ -22,8 +22,7 @@ type FwFunc =
22
22
///
23
23
/// The pointer is valid, and has ownership over the instance of `struct firmware`.
24
24
///
25
- /// Once requested, the `Firmware` backing buffer is not modified until it is freed when `Firmware`
26
- /// is dropped.
25
+ /// The `Firmware`'s backing buffer is not modified.
27
26
///
28
27
/// # Examples
29
28
///
@@ -72,22 +71,22 @@ impl Firmware {
72
71
73
72
/// Returns the size of the requested firmware in bytes.
74
73
pub fn size ( & self ) -> usize {
75
- // SAFETY: Safe by the type invariant.
74
+ // SAFETY: `self.as_raw()` is valid by the type invariant.
76
75
unsafe { ( * self . as_raw ( ) ) . size }
77
76
}
78
77
79
78
/// Returns the requested firmware as `&[u8]`.
80
79
pub fn data ( & self ) -> & [ u8 ] {
81
- // SAFETY: Safe by the type invariant. Additionally, `bindings::firmware` guarantees, if
82
- // successfully requested, that `bindings::firmware::data` has a size of
83
- // `bindings::firmware::size` bytes.
80
+ // SAFETY: `self.as_raw()` is valid by the type invariant. Additionally,
81
+ // `bindings::firmware` guarantees, if successfully requested, that
82
+ // `bindings::firmware::data` has a size of `bindings::firmware:: size` bytes.
84
83
unsafe { core:: slice:: from_raw_parts ( ( * self . as_raw ( ) ) . data , self . size ( ) ) }
85
84
}
86
85
}
87
86
88
87
impl Drop for Firmware {
89
88
fn drop ( & mut self ) {
90
- // SAFETY: Safe by the type invariant.
89
+ // SAFETY: `self.as_raw()` is valid by the type invariant.
91
90
unsafe { bindings:: release_firmware ( self . as_raw ( ) ) } ;
92
91
}
93
92
}
0 commit comments