Skip to content

Commit 2c10000

Browse files
authored
Merge pull request #480 from samueltardieu/invalid-reference-casting
Replace UB code by a legitimate pointer access
2 parents 773836d + 0514d12 commit 2c10000

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
- Move from bors/manual merge to GH merge queue
1111
- Add tools/check.py python script for local check
1212
- Add changelog check on PRs
13+
- Replace UB code by a legitimate pointer access
1314

1415
## [v0.10.0] - 2022-12-12
1516

src/spi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ where
355355

356356
fn write_data_reg(&mut self, data: FrameSize) {
357357
// NOTE(write_volatile) see note above
358-
unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut FrameSize, data) }
358+
unsafe { ptr::write_volatile(ptr::addr_of!(self.spi.dr) as *mut FrameSize, data) }
359359
}
360360

361361
// Implement write as per the "Transmit only procedure" page 712

0 commit comments

Comments
 (0)