Skip to content

Commit

Permalink
Merge pull request #480 from samueltardieu/invalid-reference-casting
Browse files Browse the repository at this point in the history
Replace UB code by a legitimate pointer access
  • Loading branch information
burrbull authored Jan 30, 2024
2 parents 773836d + 0514d12 commit 2c10000
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Move from bors/manual merge to GH merge queue
- Add tools/check.py python script for local check
- Add changelog check on PRs
- Replace UB code by a legitimate pointer access

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

Expand Down
2 changes: 1 addition & 1 deletion src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ where

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

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

0 comments on commit 2c10000

Please sign in to comment.