From dc223a14c0c6897c770b8958751450e177a65bec Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Fri, 22 Nov 2024 18:06:57 +0200 Subject: [PATCH 1/3] chore Cargo - Set rust-version & add matrix for building and testing in MSRV Signed-off-by: Lachezar Lechev --- .github/workflows/rust.yml | 12 ++++++++++-- Cargo.toml | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 75b29b7a..64bcfde6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -6,7 +6,10 @@ jobs: formatting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt - name: Check formatting run: cargo fmt -- --check @@ -14,9 +17,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: + # Always run MSRV too! + rust: ["stable", "1.76"] features: ['log', 'defmt-log', '""'] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} - name: Build run: cargo build --no-default-features --features ${{matrix.features}} --verbose - name: Run Tests diff --git a/Cargo.toml b/Cargo.toml index 45276c1c..49b13171 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,9 @@ readme = "README.md" repository = "https://github.com/rust-embedded-community/embedded-sdmmc-rs" version = "0.8.0" +# Make sure to update the CI too! +rust-version = "1.76" + [dependencies] byteorder = {version = "1", default-features = false} defmt = {version = "0.3", optional = true} From c941b5a3224adcc6f25876885a8ad11607ecfa4c Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Sun, 24 Nov 2024 22:51:43 +0200 Subject: [PATCH 2/3] fix: MSRV - inclusive pattern matching Signed-off-by: Lachezar Lechev --- src/fat/volume.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fat/volume.rs b/src/fat/volume.rs index 4f085acb..60bb365e 100644 --- a/src/fat/volume.rs +++ b/src/fat/volume.rs @@ -595,7 +595,7 @@ impl FatVolume { lfn_buffer.push(&buffer); SeqState::Complete { csum } } - (true, 0x02..0x14, _) => { + (true, sequence, _) if sequence >= 0x02 && sequence < 0x14 => { lfn_buffer.clear(); lfn_buffer.push(&buffer); SeqState::Remaining { @@ -607,7 +607,9 @@ impl FatVolume { lfn_buffer.push(&buffer); SeqState::Complete { csum } } - (false, 0x01..0x13, SeqState::Remaining { csum, next }) if next == sequence => { + (false, sequence, SeqState::Remaining { csum, next }) + if sequence >= 0x01 && sequence < 0x13 && next == sequence => + { lfn_buffer.push(&buffer); SeqState::Remaining { csum, From fb8e5d25c751ef2cab0a1700c8c406d9ede4d441 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Tue, 26 Nov 2024 15:22:27 +0200 Subject: [PATCH 3/3] fix: volume - name - replace trim_ascii_end fn call Signed-off-by: Lachezar Lechev --- src/fat/volume.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fat/volume.rs b/src/fat/volume.rs index 60bb365e..78b88f7f 100644 --- a/src/fat/volume.rs +++ b/src/fat/volume.rs @@ -36,7 +36,15 @@ impl VolumeName { /// Get name pub fn name(&self) -> &[u8] { - self.contents.trim_ascii_end() + let mut bytes = &self.contents[..]; + while let [rest @ .., last] = bytes { + if last.is_ascii_whitespace() { + bytes = rest; + } else { + break; + } + } + bytes } /// Create a new MS-DOS volume label.