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

Force Function Rename #4703

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

Conversation

brightprogrammer
Copy link
Contributor

New function to forcefully rename an analysis function. Multiple retries will be performed by adding a numeric suffix to function name until the number of retries max's out

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

...

Test plan

...

Closing issues

...

New function to forcefully rename a function. Multiple retries will be
performed by adding a numeric suffix to function name until the number
of retries max's out
@brightprogrammer
Copy link
Contributor Author

About canalysis.c:3336 TODO?

* @return `false` otherwiese.
*
* @sa rz_analysis_function_force_rename
* */
RZ_API bool rz_analysis_function_rename(RzAnalysisFunction *fcn, const char *name) {
Copy link
Member

Choose a reason for hiding this comment

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

add RZ_NOTNULL

*
* @sa rz_analysis_function_rename
* */
RZ_API const char *rz_analysis_function_force_rename(RzAnalysisFunction *fcn, const char *name) {
Copy link
Member

Choose a reason for hiding this comment

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

same here. RZ_NOT_NULL.

Comment on lines +316 to +329
const char *final_name = strdup(name);
ut32 retries = 100;
ut32 suffix = 0;
while ((retries--) && !rz_analysis_function_rename(fcn, final_name)) {
if (final_name) {
free((void *)final_name);
final_name = NULL;
}

ut32 strsz = snprintf(NULL, 0, "%s_%u", name, suffix) + 1;
final_name = malloc(strsz);
snprintf((char *)final_name, strsz, "%s_%u", name, suffix++);
}
return retries ? fcn->name : NULL;
Copy link
Member

Choose a reason for hiding this comment

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

instead of doing retries, just do name_offset which is granted to be unique. also use rz_strf directly instead of calling snprintf.

Copy link
Member

@wargio wargio left a comment

Choose a reason for hiding this comment

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

See above

@wargio
Copy link
Member

wargio commented Nov 6, 2024

About canalysis.c:3336 TODO?

ignore it.

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

Successfully merging this pull request may close these issues.

2 participants