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

graphics/deko3d: fix and simplify rbtree code #101

Merged
merged 1 commit into from
Sep 14, 2022
Merged

graphics/deko3d: fix and simplify rbtree code #101

merged 1 commit into from
Sep 14, 2022

Conversation

scturtle
Copy link
Contributor

Solve #100.

};
// This is technically UB, but basically every compiler worth using admits it as an extension
return (ClassT*)((intptr_t)member - whatever{ptr}.offset);
return (ClassT *)((char *)member - (char *)&((ClassT *)0->*ptr));
Copy link
Contributor

@fincs fincs Sep 11, 2022

Choose a reason for hiding this comment

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

This is still UB fwiw. I'd say the original version of this function is easier to read and does not involve dereferencing a null pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

if (mode == UpperBound && node)
node = walk(node, N::Right);
else if (!node && parent)
node = &parent->left() == &point ? parent : walk(parent, N::Right);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ternary actually correct for UpperBound mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please let me know if there is any problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was mostly asking how did you arrive to that simplification, as I'm currently struggling to wrap my head around this code :p

Copy link
Contributor

Choose a reason for hiding this comment

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

After some analysis, I believe this code to be correct.

@fincs fincs merged commit 0947425 into switchbrew:master Sep 14, 2022
xfangfang added a commit to xfangfang/borealis that referenced this pull request Oct 30, 2023
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