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

MAC: Avoid always-nil error #2602

Merged
merged 3 commits into from
Apr 25, 2019
Merged

Conversation

oncilla
Copy link
Contributor

@oncilla oncilla commented Apr 18, 2019

The spath.Hop.CalcMac unnecessarily returns an error. It is always nil.

This PR removes the error from the returned values and reduces the
error handling branches in the code.


This change is Reviewable

@oncilla oncilla requested a review from scrye April 18, 2019 10:34
@oncilla oncilla added this to the Q2S1 milestone Apr 18, 2019
Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 9 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @oncilla)


go/lib/spath/hop.go, line 155 at r1 (raw file):

	mac.Reset()
	// We can safely ignore the return values: https://godoc.org/hash#Hash
	mac.Write(all)

I would add a panic if the Write returns an error; it would catch faulty implementations of hash.Hash.

Copy link
Contributor Author

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewable status: 7 of 9 files reviewed, 1 unresolved discussion (waiting on @scrye)


go/lib/spath/hop.go, line 155 at r1 (raw file):

Previously, scrye (Sergiu Costea) wrote…

I would add a panic if the Write returns an error; it would catch faulty implementations of hash.Hash.

Done.

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 3 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

The `spat.Hop.CalcMac` unecessarily returns an error. It is always nil.

This PR removes the error from the returned values and reduces the
error handling branches in the code.
Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@oncilla oncilla merged commit a7dc0bd into scionproto:master Apr 25, 2019
@oncilla oncilla deleted the pub-hash-hash-fun branch April 25, 2019 10:58
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