Skip to content

refactor(ironrdp-web): fix indexing_slicing clippy lint warnings#993

Open
RRRadicalEdward wants to merge 5 commits intomasterfrom
ironrdp-web-add-clippy-index-slicing-lint
Open

refactor(ironrdp-web): fix indexing_slicing clippy lint warnings#993
RRRadicalEdward wants to merge 5 commits intomasterfrom
ironrdp-web-add-clippy-index-slicing-lint

Conversation

@RRRadicalEdward
Copy link
Collaborator

This lint

Checks for usage of indexing or slicing that may panic at runtime.

This one is quite pedantic and changes the way we write the code, but on the other hand, it makes the code more panic-resistant. Fixed the lint warnings only for ironrdp-web to see early feedback on it.
If we agree on adding it, I will add this lint for each crate separately, because there are too many warnings to do in 1 PR:
image

@github-actions
Copy link

github-actions bot commented Sep 21, 2025

Coverage Report 🤖 ⚙️

Past:
Total lines: 35869
Covered lines: 22616 (63.05%)

New:
Total lines: 35869
Covered lines: 22616 (63.05%)

Diff: +0.00%

[this comment will be updated automatically]

@RRRadicalEdward RRRadicalEdward self-assigned this Oct 3, 2025
@RRRadicalEdward
Copy link
Collaborator Author

@CBenoit Does it look good? Should we proceed with adding this lint?

@CBenoit
Copy link
Member

CBenoit commented Oct 8, 2025

I want to double check a little bit more before merging this.

@CBenoit
Copy link
Member

CBenoit commented Nov 6, 2025

I’m putting back this PR on my TODO review list.

@RRRadicalEdward
Copy link
Collaborator Author

I’m putting back this PR on my TODO review list.

Hi @CBenoit. Did you have a chance to double-check this PR?

@CBenoit
Copy link
Member

CBenoit commented Feb 12, 2026

Sorry I actually forgot about it despite the TODO I wrote 😨

@RRRadicalEdward
Copy link
Collaborator Author

RRRadicalEdward commented Feb 13, 2026

Sorry I actually forgot about it despite the TODO I wrote 😨

I just remembered about this PR yesterday. We have a mental connect 😄

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the ironrdp-web crate to eliminate indexing_slicing clippy lint warnings by replacing direct slice indexing operations with safer alternatives that return Result or Option. The changes make the code more panic-resistant by ensuring all slice accesses are bounds-checked at runtime with proper error handling.

Changes:

  • Converted slice indexing operations to use .get() and .get_mut() methods with appropriate error handling
  • Updated function signatures to return Result types where slice access could fail
  • Replaced array indexing in pixel processing with first_chunk() method

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/ironrdp-web/src/image.rs Modified extract_partial_image, extract_smallest_rectangle, and extract_whole_rows to return Result and use .get() for slice access with contextual error messages
crates/ironrdp-web/src/session.rs Updated to propagate errors from extract_partial_image using the ? operator
crates/ironrdp-web/src/canvas.rs Replaced direct indexing with first_chunk::<3>() for extracting RGB values from 4-byte pixel chunks
Cargo.toml Added TODO comment noting intention to enable indexing_slicing lint project-wide

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RRRadicalEdward RRRadicalEdward force-pushed the ironrdp-web-add-clippy-index-slicing-lint branch from 5b51f36 to be67bdc Compare February 13, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants