Skip to content
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

tool_formparse: avoid clobbering on function params #10046

Closed
wants to merge 1 commit into from

Conversation

danielgustafsson
Copy link
Member

While perfectly legal to do, clobbering function parameters and using them as local variables is confusing at best and rarely improves code readability. Fix by using a local variable instead, no functionality is changed.

src/tool_formparse.c Outdated Show resolved Hide resolved
Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

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

Also, we sort of reserve the use of the name data all over libcurl code to point to the easy handle struct, and this is used for a different purpose...

Would it also make sense to change the function argument to const char *data you think?

@danielgustafsson
Copy link
Member Author

Also, we sort of reserve the use of the name data all over libcurl code to point to the easy handle struct, and this is used for a different purpose...

Would it also make sense to change the function argument to const char *data you think?

I think it does, maybe even go further and rename from data to const char *mime_data and in turn rename the local variable something else?

@bagder
Copy link
Member

bagder commented Dec 6, 2022

I would approve!

While perfectly legal to do, clobbering function parameters and using
them as local variables is confusing at best and rarely improves code
readability.  Fix by using a local variable instead, no functionality
is changed.

This also renames the parameter from data to mime_data since the term
data is (soft) reserved for the easy handle struct.

Closes: curl#10046
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
@danielgustafsson
Copy link
Member Author

Pushed a rebase with the discussed changes.

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

Successfully merging this pull request may close these issues.

None yet

2 participants