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

Code cleanups in tests/rpmpgppubkeyfingerprint.c #3068

Closed
wants to merge 1 commit into from

Conversation

sshedi
Copy link
Contributor

@sshedi sshedi commented Apr 29, 2024

No description provided.

return 1;
}

// We expect success now.
char *got = rpmhex(fp, fplen);
if (! got) {
fprintf(stderr, "%s: rpmhex failed\n", filename);
fclose(f);
Copy link
Contributor

@ffesti ffesti Apr 29, 2024

Choose a reason for hiding this comment

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

This should probably also free(fp);

@sshedi sshedi changed the title Fix file handle leaks Code cleanups in tests/rpmpgppubkeyfingerprint.c Apr 29, 2024
@sshedi
Copy link
Contributor Author

sshedi commented Apr 29, 2024

@ffesti I took the liberty to make this whole source look better. Please let me know if you want me to make changes in incremental commits. This is a small test file which is essentially testing a dummy function, so I made all changes in one commit.

@pmatilai
Copy link
Member

I took the liberty to make this whole source look better.

Better is subjective. The indentation was mostly following rpm coding style, now it's not. See Coding style / Indentation in CONTRIBUTING.md. Never, ever make formatting changes at the same time as other changes, and in particular, don't break what wasn't broken.

It's impossible to review a change like this. In the light of recent events, "small test stuff" certainly needs reviewing too. One thing that did catch my eye despite that is pointless NULL checks before freeing. Don't do that, free() will do it for you anyhow.

In the meanwhile, there are real cleanups/simplifications to be made. Like manually calculating string sizes when it could use rasprintf(), and manual getcwd() when we have rpmGetCwd() and malloc() with OOM checking for what's a static buffer that wouldn't need freeing.

@sshedi sshedi closed this by deleting the head repository May 2, 2024
@sshedi
Copy link
Contributor Author

sshedi commented May 2, 2024

Accidentally closed it, I will open a new PR.

@sshedi
Copy link
Contributor Author

sshedi commented May 2, 2024

Created #3072

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.

None yet

3 participants