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

btf: make copying types infallible #631

Merged
merged 1 commit into from Apr 27, 2022
Merged

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Apr 21, 2022

We currently have an unexported copyTypes function which allows transforming
a type graph before copying. This is very useful to strip qualifiers or
typedefs out of a graph. The function currently returns an error, since we
might not be able to remove all qualifiers, etc. in the case of deeply
nested or cyclical types.

Instead of returning an error, introduce an invalid sentinel Type "cycle" and
use it to signal that something went wrong. This allows removing the error return
which in turn allows us to extend Copy to the more powerful copyType paradigm.

Copy link
Collaborator

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Nice! I have some follow-up questions, but we can continue offline.

internal/btf/types.go Outdated Show resolved Hide resolved
internal/btf/types.go Outdated Show resolved Hide resolved
internal/btf/types.go Show resolved Hide resolved
internal/btf/types.go Outdated Show resolved Hide resolved
@lmb lmb added this to the Export `btf` milestone Apr 26, 2022
@lmb lmb force-pushed the btf-copy-type branch 2 times, most recently from 7dfb276 to 34c0638 Compare April 27, 2022 09:51
internal/btf/types.go Outdated Show resolved Hide resolved
@lmb lmb requested a review from ti-mo April 27, 2022 13:11
We currently have an unexported copyTypes function which allows transforming
a type graph before copying. This is very useful to strip qualifiers or
typedefs out of a graph. The function currently returns an error, since we
might not be able to remove all qualifiers, etc. in the case of deeply
nested or cyclical types.

Instead of returning an error, introduce an invalid sentinel Type "cycle" and
use it to signal that something went wrong. This allows removing the error return
which in turn allows us to extend Copy to the more powerful copyType paradigm.
@ti-mo ti-mo merged commit 5fd10f5 into cilium:master Apr 27, 2022
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

2 participants