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} diff --git a/src/fat/volume.rs b/src/fat/volume.rs index 4f085acb..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. @@ -595,7 +603,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 +615,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,