Skip to content

Commit e122ad5

Browse files
committed
ci: run miri
1 parent 678bcc1 commit e122ad5

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.github/workflows/_build-rust.yml

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ on:
3333
required: false
3434
default: true
3535
description: Execute tests.
36+
do-miri:
37+
type: boolean
38+
required: false
39+
default: false
40+
description: Execute tests with miri.
3641

3742
jobs:
3843
check_rust:
@@ -80,3 +85,9 @@ jobs:
8085
curl -LsSf https://get.nexte.st/latest/linux | tar zxf -
8186
chmod u+x cargo-nextest
8287
./cargo-nextest nextest run --features ${{ inputs.features }}
88+
# Only works with nightly.
89+
- name: Unit Test with Miri
90+
if: ${{ inputs.do-miri }}
91+
run: |
92+
rustup component add miri
93+
cargo miri test --features ${{ inputs.features }}

.github/workflows/rust.yml

+11
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,14 @@ jobs:
9595
do-style-check: true
9696
do-test: false
9797
features: unstable
98+
99+
miri:
100+
name: tests with miri
101+
needs: build_nightly
102+
uses: ./.github/workflows/_build-rust.yml
103+
with:
104+
rust-version: nightly
105+
do-style-check: false
106+
do-test: false
107+
do-miri: true
108+
features: unstable

multiboot2/src/boot_loader_name.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ impl BootLoaderNameTag {
3131
use core::{mem, slice, str};
3232
// strlen without null byte
3333
let strlen = self.size as usize - mem::size_of::<BootLoaderNameTag>();
34-
let bytes = unsafe { slice::from_raw_parts((&self.string) as *const u8, strlen) };
34+
let cstring = core::ptr::addr_of!(self.string);
35+
let bytes = unsafe { slice::from_raw_parts(cstring, strlen) };
3536
str::from_utf8(bytes)
3637
}
3738
}

0 commit comments

Comments
 (0)