Skip to content

avoid shadowing warning #3247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

avoid shadowing warning #3247

wants to merge 1 commit into from

Conversation

neheb
Copy link
Collaborator

@neheb neheb commented Apr 10, 2025

No description provided.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
@@ -855,7 +855,7 @@ void QuickTimeVideo::userDataDecoder(size_t size, size_t recursion_depth) {
while ((size_internal / 4 != 0) && (size_internal > 0)) {
buf.data()[4] = '\0';
io_->readOrThrow(buf.data(), 4);
const size_t size = buf.read_uint32(0, bigEndian);
size = buf.read_uint32(0, bigEndian);
Copy link
Collaborator

Choose a reason for hiding this comment

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

size as the original input variable is used below outside the while's scope... Isn't this a local variable that needs to be renamed instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. But it’s simpler to abuse the fact that it’s copied by value into the function. Modifications don’t make it outside

@neheb neheb requested a review from Copilot June 27, 2025 23:16
Copy link

@Copilot 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 removes variable shadowing by eliminating redundant declarations and renaming conflicting locals.

  • Eliminates a shadowed size variable in userDataDecoder by assigning directly to the parameter.
  • Renames the addrinfo* result variable in the HTTP function to avoid shadowing.

Reviewed Changes

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

File Description
src/quicktimevideo.cpp Removed local const size declaration and now reuses the size parameter
src/http.cpp Renamed result to r for addrinfo*, avoiding a naming conflict
Comments suppressed due to low confidence (2)

src/quicktimevideo.cpp:858

  • [nitpick] The parameter size is still ambiguous after removing the shadowing declaration. Consider renaming the function parameter (e.g., remainingSize) or introducing a descriptively named local variable (e.g., chunkSize) to clarify intent and improve readability.
    size = buf.read_uint32(0, bigEndian);

src/http.cpp:204

  • [nitpick] The variable name r is too short and unclear. Use a more descriptive identifier like addrinfoResult or resolvedInfo to improve maintainability and clarity.
    struct addrinfo* r;

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.

2 participants