@@ -142,30 +142,32 @@ impl SimpleNetwork {
142
142
status. to_result_with_val ( || mac_address)
143
143
}
144
144
145
- /// Perform read operations on the NVRAM device attached to
146
- /// a network interface .
147
- pub fn read_nv_data ( & self , offset : usize , buffer : & [ u8 ] ) -> Result {
145
+ /// Reads data from the NVRAM device attached to the network interface into
146
+ /// the provided `dst_buffer` .
147
+ pub fn read_nv_data ( & self , offset : usize , dst_buffer : & mut [ u8 ] ) -> Result {
148
148
unsafe {
149
149
( self . 0 . non_volatile_data ) (
150
150
& self . 0 ,
151
151
Boolean :: from ( true ) ,
152
152
offset,
153
- buffer . len ( ) ,
154
- buffer . as_ptr ( ) as * mut c_void ,
153
+ dst_buffer . len ( ) ,
154
+ dst_buffer . as_mut_ptr ( ) . cast ( ) ,
155
155
)
156
156
}
157
157
. to_result ( )
158
158
}
159
159
160
- /// Perform write operations on the NVRAM device attached to a network interface.
161
- pub fn write_nv_data ( & self , offset : usize , buffer : & mut [ u8 ] ) -> Result {
160
+ /// Writes data into the NVRAM device attached to the network interface from
161
+ /// the provided `src_buffer`.
162
+ pub fn write_nv_data ( & self , offset : usize , src_buffer : & [ u8 ] ) -> Result {
162
163
unsafe {
163
164
( self . 0 . non_volatile_data ) (
164
165
& self . 0 ,
165
166
Boolean :: from ( false ) ,
166
167
offset,
167
- buffer. len ( ) ,
168
- buffer. as_mut_ptr ( ) . cast ( ) ,
168
+ src_buffer. len ( ) ,
169
+ // SAFETY: The buffer is only used for reading.
170
+ src_buffer. as_ptr ( ) . cast :: < c_void > ( ) . cast_mut ( ) ,
169
171
)
170
172
}
171
173
. to_result ( )
0 commit comments