-
Notifications
You must be signed in to change notification settings - Fork 163
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
Go dispatcher: Add SCMP ID tracking tables #2326
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @scrye)
go/godispatcher/internal/registration/iatable_test.go, line 149 at r1 (raw file):
err = ref.RegisterID(42) xtest.FailOnErr(t, err) Convey("Performing SCMP lookup now succeeds", func() {
Nit: the now
doesn't really make sense (only with the Test above, but that is in a different function)
go/godispatcher/internal/registration/scmp_table.go, line 34 at r1 (raw file):
func (t *SCMPTable) Lookup(id uint64) (interface{}, bool) { value, ok := t.m[id] return value, ok
This could be collapsed into return t.m[id]
go/godispatcher/internal/registration/scmp_table.go, line 50 at r1 (raw file):
func (t *SCMPTable) Remove(id uint64) error { if _, ok := t.m[id]; !ok { return common.NewBasicError("element not found", nil, "id", id)
Why is the error needed? Default go delete
also doesn't complain if an entry is deleted that isn't there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 5 files reviewed, 2 unresolved discussions (waiting on @lukedirtwalker)
go/godispatcher/internal/registration/scmp_table.go, line 34 at r1 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
This could be collapsed into
return t.m[id]
Sadly, it can't. The compiler assumes the one return value variant of map access if used in the return, so it complains that it's returning only one value instead of two.
go/godispatcher/internal/registration/scmp_table.go, line 50 at r1 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
Why is the error needed? Default go
delete
also doesn't complain if an entry is deleted that isn't there?
I was thinking it's useful to catch double frees, but it leads to some awkward untestable branches. I dropped the return value, it's more elegant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved
go/godispatcher/internal/registration/scmp_table.go, line 34 at r1 (raw file):
Previously, scrye (Sergiu Costea) wrote…
Sadly, it can't. The compiler assumes the one return value variant of map access if used in the return, so it complains that it's returning only one value instead of two.
wow TIL
This is a stepping stone to implementing SCMP Echo, TraceRoute, and RecordPath support in the Go dispatcher.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)