summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/hash/jenkins
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@google.com>2021-04-10 14:52:00 -0700
committergVisor bot <gvisor-bot@google.com>2021-04-10 14:53:55 -0700
commitc84ff991240c0ec71dd1978db250bcbfbe4c142b (patch)
tree721d5bf6b26139a5cedd6b9e04b7e71c4db0c069 /pkg/tcpip/hash/jenkins
parent2fea7d096b6224da50e09fa4bace7f3c203ed074 (diff)
Use the SecureRNG to generate listener nonces
Some other cleanup while I'm here: - Remove unused arguments - Handle some unhandled errors - Remove redundant casts - Remove redundant parens - Avoid shadowing `hash` package name PiperOrigin-RevId: 367816161
Diffstat (limited to 'pkg/tcpip/hash/jenkins')
-rw-r--r--pkg/tcpip/hash/jenkins/jenkins.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/pkg/tcpip/hash/jenkins/jenkins.go b/pkg/tcpip/hash/jenkins/jenkins.go
index 52c22230e..33ff22a7b 100644
--- a/pkg/tcpip/hash/jenkins/jenkins.go
+++ b/pkg/tcpip/hash/jenkins/jenkins.go
@@ -42,26 +42,26 @@ func (s *Sum32) Reset() { *s = 0 }
// Sum32 returns the hash value
func (s *Sum32) Sum32() uint32 {
- hash := *s
+ sCopy := *s
- hash += (hash << 3)
- hash ^= hash >> 11
- hash += hash << 15
+ sCopy += sCopy << 3
+ sCopy ^= sCopy >> 11
+ sCopy += sCopy << 15
- return uint32(hash)
+ return uint32(sCopy)
}
// Write adds more data to the running hash.
//
// It never returns an error.
func (s *Sum32) Write(data []byte) (int, error) {
- hash := *s
+ sCopy := *s
for _, b := range data {
- hash += Sum32(b)
- hash += hash << 10
- hash ^= hash >> 6
+ sCopy += Sum32(b)
+ sCopy += sCopy << 10
+ sCopy ^= sCopy >> 6
}
- *s = hash
+ *s = sCopy
return len(data), nil
}