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

Convert main data structures in elfdeps to C++ #3581

Merged
merged 7 commits into from
Feb 25, 2025

Conversation

pmatilai
Copy link
Member

I ended up doing this to make dealing with #2197 saner. The multi-arch stuff itself is not ready for merging but moving to STL stuff is something we'll want to do anyway going forward, regardless of what/when happens with the multi-arch stuff, and this'll be easier to review separately anyhow.

Not adding any new tests here because elfdeps is reasonably covered already (as in, made itself known while working on this 😅 )

@pmatilai pmatilai requested a review from a team as a code owner February 19, 2025 09:26
@pmatilai pmatilai requested review from dmnks and removed request for a team February 19, 2025 09:26
return 1;

if (rstreqn(soname, "ld.", 3) || rstreqn(soname, "ld-", 3) ||
rstreqn(soname, "ld64.", 3) || rstreqn(soname, "ld64-", 3))
Copy link
Contributor

Choose a reason for hiding this comment

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

Heh, there seems to have been a bug here (comparing at most 3 chars whereas the tested strings are longer). That's now fixed with the conversion 😄 Nice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, look at that. I didn't notice... Funny timing as we just talked about humans and calculating string lengths yesterday 😆

That bug exists in many 4.x releases then.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, I've filed #3596 to cover the backports.

tools/elfdeps.cc Outdated
const std::string & soname,
const std::string & ver, const std::string & marker)
{
if (skipSoname(soname.c_str()))
Copy link
Contributor

@dmnks dmnks Feb 24, 2025

Choose a reason for hiding this comment

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

This was probably forgotten as part of the "Use a C++ string for skipSoname() convenience" commit, i.e. the c_str() should be removed 😅

Copy link
Contributor

@dmnks dmnks Feb 24, 2025

Choose a reason for hiding this comment

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

Oh, now I somewhat recall that you can actually assign a NULL-terminated string to an std::string variable. Still, it seems like the conversion can be removed for clarity anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yup, that's just an accidental leftove caused by "wrong" refactoring order - reordered the two relevant commits and voila the issue goes away 😅 Thanks for spotting.

@dmnks
Copy link
Contributor

dmnks commented Feb 24, 2025

Other than the c_str() thing, LGTM.

Do away with the silly typedef while at it.
Rename addDep() to addSoDep() to hint at the intended use, and add
a bare version of addDep() that has no extra logic. It's a thin layer
of isolation but isolation nevertheless. No functional changes.
Allegedly no functional changes.
Don't bother checking for non-empty soname in the callers, addSoDep()
will check for this anyhow.
The marker and ver don't *need* to be STL strings, but life is simpler
if they all follow the same conventions. Just pass empty strings in
place of NULL now and adjust the logic accordingly.
@dmnks dmnks merged commit 061a513 into rpm-software-management:master Feb 25, 2025
1 check passed
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