Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d8d5f5

Browse files
authored
Merge pull request#123 from jannic-dev-forks/transfer-in-place
Implement SpiOperation::TransferInPlace based on SpidevTransfer::read_write_in_place()
2 parents1ffb268 +88abb3c commit3d8d5f5

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
toolchain:${{ matrix.rust }}
3838
target:${{ matrix.target }}
3939

40+
-if:${{ matrix.rust=='1.65.0' }}
41+
run:cargo update --precise 2.0.106 --package syn
42+
4043
-name:Install armv7 libraries
4144
if:${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }}
4245
run:|

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Added async`DelayNs` implementation for`tokio`.
1313
- Added feature flag for`serial`.
1414

15+
###Fixed
16+
17+
- Fix UB (and remove unsafe block) in handling of SpiOperation::TransferInPlace
18+
1519
##[v0.4.0] - 2024-01-10
1620

1721
###Changed

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sysfs_gpio = { version = "0.6.1", optional = true }
3131
i2cdev = {version ="0.6.0",optional =true }
3232
nb ="1"
3333
serialport = {version ="4.2.0",default-features =false,optional =true }
34-
spidev = {version ="0.6.0",optional =true }
34+
spidev = {version ="0.6.1",optional =true }
3535
nix = {version ="0.27.1",optional =true }
3636
tokio = {version ="1",default-features =false,optional =true }
3737

‎src/spi.rs‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ mod embedded_hal_impl {
173173
}
174174

175175
fntransfer_in_place(&mutself,words:&mut[u8]) ->Result<(),Self::Error>{
176-
let tx = words.to_owned();
177176
self.0
178-
.transfer(&mutSpidevTransfer::read_write(&tx,words))
177+
.transfer(&mutSpidevTransfer::read_write_in_place(words))
179178
.map_err(|err|SPIError{ err})
180179
}
181180

@@ -214,11 +213,7 @@ mod embedded_hal_impl {
214213
}
215214
},
216215
SpiOperation::TransferInPlace(buf) =>{
217-
let tx =unsafe{
218-
let p = buf.as_ptr();
219-
std::slice::from_raw_parts(p, buf.len())
220-
};
221-
transfers.push(SpidevTransfer::read_write(tx, buf));
216+
transfers.push(SpidevTransfer::read_write_in_place(buf));
222217
}
223218
SpiOperation::DelayNs(ns) =>{
224219
let us ={

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp