Registry Mirror
Skip to content

Conversation

@dishendradeshmukh1986

Copy link
Copy Markdown
Collaborator

Summary

  • Clean up formatting and Clippy findings in handwritten Rust sources.
  • Make non-truncating lock-file creation explicit.
  • Replace needless borrows and matches, use slices, and clarify count
    conversions.
  • Limit dead-code allowances to retained internal representations and APIs.

Context

Running rustfmt and Clippy with warnings denied exposed several maintenance
issues in the main package. These changes address those findings without
changing the generated Thrift sources or intended runtime behavior.

Validation

  • cargo fmt --package uefisettings -- --check
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo test --locked --lib --bins
    • 71 library tests passed
    • 1 binary test passed
  • cargo build --release --locked

The generated Thrift dependencies still emit their existing unused-import
warnings, but the maintained uefisettings package passes Clippy with warnings
denied.

Dependency

This branch is based on #19. Merge #19 first; afterward this PR contains only
the formatting and lint-cleanup commit.

Validation found that setting a matched question without a supported
varstore returned success with an empty response and changed nothing.
This could make callers mistake an unsupported operation for success.

Return an explicit error naming the question when writable storage
cannot be resolved. Preserve the normal write path for supported
buffer and EFI varstores, and report success only after writing.

Add tests for unresolved storage and OneOf questions. Keep existing
question-not-found behaviour separate from this matched-question fix.

Signed-off-by: Dishendra Deshmukh <dishendra.deshmukh@arm.com>
Change-Id: I0861e2a8c7dca98c3b5edc965b494aaabc833286
Running rustfmt and Clippy with warnings denied exposed stale imports,
needless borrows and matches, Vec reference arguments, ambiguous file
creation options, and intentionally unused internal APIs.

Clean up the handwritten Rust sources, make non-truncating lock-file
creation explicit, use slices and infallible count conversions, and
limit dead-code allowances to internal representations retained for
parsing or future REST operations.

The changes preserve behavior while allowing the maintained package
to pass formatting and Clippy checks with warnings denied.

Signed-off-by: Dishendra Deshmukh <dishendra.deshmukh@arm.com>
Change-Id: I17146b9b95c12fc45e1816a8de475667ebf4cf7b
@xaionaro

xaionaro commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

On x86_64 it does not build for me:

$ cargo clippy --locked --all-targets -- -D warnings
    Checking memchr v2.7.1
    Checking futures-sink v0.3.30
    Checking cfg-if v1.0.0
    Checking futures-core v0.3.30
    Checking pin-project-lite v0.2.13
    Checking futures-task v0.3.30
    Checking futures-io v0.3.30
    Checking pin-utils v0.1.0
    Checking futures v0.1.31
    Checking libc v0.2.151
    Checking serde v1.0.194
    Checking slab v0.4.9
    Checking thiserror v1.0.56
    Checking bitflags v2.4.1
    Checking num-traits v0.2.17
    Checking regex-syntax v0.8.2
    Checking linux-raw-sys v0.3.8
    Checking ryu v1.0.16
    Checking bitflags v1.3.2
    Checking linux-raw-sys v0.4.12
    Checking itoa v1.0.10
    Checking anyhow v1.0.79
    Checking base64 v0.11.0
    Checking panic-message v0.3.0
    Checking futures-channel v0.3.30
    Checking value-bag v1.4.2
    Checking hashbrown v0.12.3
    Checking unicode-width v0.1.11
    Checking os_str_bytes v6.6.1
    Checking ppv-lite86 v0.2.17
    Checking once_cell v1.19.0
    Checking termcolor v1.4.0
    Checking partition-identity v0.3.0
    Checking unicase v2.7.0
    Checking array-init v2.1.0
    Checking strsim v0.10.0
    Checking fastrand v2.0.1
    Checking humantime v2.1.0
    Checking log v0.4.20
    Checking bytemuck v1.14.0
    Checking proc-mounts v0.3.0
    Checking clap_lex v0.2.4
    Checking httparse v1.8.0
    Checking libloading v0.8.1
    Checking rustix v0.38.28
    Checking aho-corasick v1.1.2
    Checking binrw v0.13.3
    Checking indexmap v1.9.3
    Checking futures-util v0.3.30
    Checking io-lifetimes v1.0.11
    Checking getrandom v0.2.11
    Checking atty v0.2.14
    Checking nix v0.27.1
    Checking rustix v0.37.27
    Checking rand_core v0.6.4
    Checking rand_chacha v0.3.1
    Checking rand v0.8.5
    Checking is-terminal v0.4.10
    Checking tempfile v3.9.0
    Checking regex-automata v0.4.3
    Checking terminal_size v0.2.6
    Checking textwrap v0.16.0
    Checking bytes v1.5.0
    Checking serde_json v1.0.110
    Checking ordered-float v1.1.1
    Checking bufsize v1.0.7
    Checking futures-executor v0.3.30
    Checking futures v0.3.30
    Checking fbthrift v0.0.3
    Checking regex v1.10.2
    Checking env_logger v0.10.1
    Checking clap v3.2.25
    Checking uefisettings_spellings_db_thrift v0.1.0 (/home/xaionaro/src/uefisettings/thrift/rust/uefisettings_spellings_db_thrift)
    Checking uefisettings_backend_thrift v0.1.0 (/home/xaionaro/src/uefisettings/thrift/rust/uefisettings_backend_thrift)
warning: unused import: `self::errors::*`
 --> thrift/rust/uefisettings_spellings_db_thrift/uefisettings_spellings_db.rs:8:9
  |
8 | pub use self::errors::*;
  |         ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

warning: unused import: `self::errors::*`
 --> thrift/rust/uefisettings_backend_thrift/uefisettings_backend.rs:7:9
  |
7 | pub use self::errors::*;
  |         ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

warning: `uefisettings_spellings_db_thrift` (lib) generated 1 warning (run `cargo clippy --fix --lib -p uefisettings_spellings_db_thrift` to apply 1 suggestion)
warning: `uefisettings_backend_thrift` (lib) generated 1 warning (run `cargo clippy --fix --lib -p uefisettings_backend_thrift` to apply 1 suggestion)
    Checking uefisettings v0.1.5 (/home/xaionaro/src/uefisettings)
error: unused import: `log::error`
  --> src/lib/hii/forms.rs:34:5
   |
34 | use log::error;
   |     ^^^^^^^^^^
   |
   = note: `-D unused-imports` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(unused_imports)]`

error: empty line after doc comment
  --> src/lib/ilorest/blobstore.rs:54:1
   |
54 | / /// ```
55 | |
   | |_^
56 |   pub struct Transport<'a> {
   |   -------------------- the comment documents this struct
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#empty_line_after_doc_comments
   = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]`
   = help: if the empty line is unintentional, remove it

error: struct `RedfishSettingsInfo` is never constructed
   --> src/lib/ilorest/requests.rs:402:12
    |
402 | pub struct RedfishSettingsInfo {
    |            ^^^^^^^^^^^^^^^^^^^
    |
    = note: `-D dead-code` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(dead_code)]`

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:307:17
    |
307 |                 response_key.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `response_key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast
    = note: `-D clippy::unnecessary-cast` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]`

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:308:17
    |
308 |                 namespace.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `namespace.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:326:17
    |
326 |                 request_key.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `request_key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:327:17
    |
327 |                 response_key.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `response_key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:328:17
    |
328 |                 namespace.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `namespace.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:349:17
    |
349 |                 request_key.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `request_key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:350:17
    |
350 |                 namespace.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `namespace.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:371:17
    |
371 |                 request_key.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `request_key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:372:17
    |
372 |                 namespace.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `namespace.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:390:17
    |
390 |                 response_key.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `response_key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:391:17
    |
391 |                 namespace.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `namespace.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:401:17
    |
401 |                 request_key.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `request_key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:402:17
    |
402 |                 namespace.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `namespace.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:423:17
    |
423 |                 response_key.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `response_key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:424:17
    |
424 |                 namespace.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `namespace.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:442:36
    |
442 |                 (self.delete_blob)(key.as_ptr() as *const i8, namespace.as_ptr() as *const i8);
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `key.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: casting raw pointers to the same type and constness is unnecessary (`*const i8` -> `*const i8`)
   --> src/lib/ilorest/chif.rs:442:63
    |
442 |                 (self.delete_blob)(key.as_ptr() as *const i8, namespace.as_ptr() as *const i8);
    |                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `namespace.as_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_cast

error: needless call to `as_bytes`
   --> src/lib/ilorest/rest.rs:195:13
    |
195 |             body.as_bytes().len().to_string(),
    |             ^^^^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `body.len()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#needless_as_bytes
    = note: `-D clippy::needless-as-bytes` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::needless_as_bytes)]`

error: could not compile `uefisettings` (lib) due to 21 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `uefisettings` (lib test) due to 21 previous errors
$ git log -1 | head -1
commit eaea984978d67303ae2eb5cc08db0588bc97fd16

@xaionaro xaionaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to ensure it builds both of x86 and arm64

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The reviewed changes are consistent with the stated lint-cleanup goals and introduce no unresolved correctness issues.

Review effort: Balanced
Findings: None

What changed in this PR

Cleans up handwritten Rust code to satisfy rustfmt and Clippy without intended runtime changes, while retaining the #19 write-safety dependency.

Changes:

  • Simplifies matches, borrows, indexing, conversions, and formatting.
  • Makes lock-file non-truncation explicit and narrows imports/dead-code allowances.
  • Includes #19’s unsupported-varstore error handling and tests.
File Description
src/​main.rs Removes a needless path borrow.
src/​lib/​ilorest/​rest.rs Allows retained unused REST methods.
src/​lib/​ilorest/​chif.rs Allows the retained internal interface.
src/​lib/​ilorest/​blobstore.rs Simplifies transport control flow and buffer handling.
src/​lib/​hii/​package.rs Cleans test imports, checks, and indexing.
src/​lib/​hii/​forms.rs Applies lint fixes and unsupported-varstore handling.
src/​lib/​file_lock.rs Explicitly preserves lock-file contents and simplifies matches.
src/​lib/​exports.rs Removes obsolete unsupported-storage behavior and imports.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dishendradeshmukh1986

Copy link
Copy Markdown
Collaborator Author

Thanks for sharing the log. I’ll rerun Clippy, tests, and the build on both x86_64 and Arm64 before updating the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants