mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 01:05:15 +01:00
all: use ++ to increment
Make the code slightly more idiomatic. No functional changes. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
d0f8e9477c
commit
1481e72107
@ -73,11 +73,11 @@ func TestTrieRandomIPv4(t *testing.T) {
|
||||
|
||||
const AddressLength = 4
|
||||
|
||||
for n := 0; n < NumberOfPeers; n += 1 {
|
||||
for n := 0; n < NumberOfPeers; n++ {
|
||||
peers = append(peers, &Peer{})
|
||||
}
|
||||
|
||||
for n := 0; n < NumberOfAddresses; n += 1 {
|
||||
for n := 0; n < NumberOfAddresses; n++ {
|
||||
var addr [AddressLength]byte
|
||||
rand.Read(addr[:])
|
||||
cidr := uint(rand.Uint32() % (AddressLength * 8))
|
||||
@ -86,7 +86,7 @@ func TestTrieRandomIPv4(t *testing.T) {
|
||||
slow = slow.Insert(addr[:], cidr, peers[index])
|
||||
}
|
||||
|
||||
for n := 0; n < NumberOfTests; n += 1 {
|
||||
for n := 0; n < NumberOfTests; n++ {
|
||||
var addr [AddressLength]byte
|
||||
rand.Read(addr[:])
|
||||
peer1 := slow.Lookup(addr[:])
|
||||
@ -106,11 +106,11 @@ func TestTrieRandomIPv6(t *testing.T) {
|
||||
|
||||
const AddressLength = 16
|
||||
|
||||
for n := 0; n < NumberOfPeers; n += 1 {
|
||||
for n := 0; n < NumberOfPeers; n++ {
|
||||
peers = append(peers, &Peer{})
|
||||
}
|
||||
|
||||
for n := 0; n < NumberOfAddresses; n += 1 {
|
||||
for n := 0; n < NumberOfAddresses; n++ {
|
||||
var addr [AddressLength]byte
|
||||
rand.Read(addr[:])
|
||||
cidr := uint(rand.Uint32() % (AddressLength * 8))
|
||||
@ -119,7 +119,7 @@ func TestTrieRandomIPv6(t *testing.T) {
|
||||
slow = slow.Insert(addr[:], cidr, peers[index])
|
||||
}
|
||||
|
||||
for n := 0; n < NumberOfTests; n += 1 {
|
||||
for n := 0; n < NumberOfTests; n++ {
|
||||
var addr [AddressLength]byte
|
||||
rand.Read(addr[:])
|
||||
peer1 := slow.Lookup(addr[:])
|
||||
|
@ -70,11 +70,11 @@ func benchmarkTrie(peerNumber int, addressNumber int, addressLength int, b *test
|
||||
|
||||
const AddressLength = 4
|
||||
|
||||
for n := 0; n < peerNumber; n += 1 {
|
||||
for n := 0; n < peerNumber; n++ {
|
||||
peers = append(peers, &Peer{})
|
||||
}
|
||||
|
||||
for n := 0; n < addressNumber; n += 1 {
|
||||
for n := 0; n < addressNumber; n++ {
|
||||
var addr [AddressLength]byte
|
||||
rand.Read(addr[:])
|
||||
cidr := uint(rand.Uint32() % (AddressLength * 8))
|
||||
@ -82,7 +82,7 @@ func benchmarkTrie(peerNumber int, addressNumber int, addressLength int, b *test
|
||||
trie = trie.insert(addr[:], cidr, peers[index])
|
||||
}
|
||||
|
||||
for n := 0; n < b.N; n += 1 {
|
||||
for n := 0; n < b.N; n++ {
|
||||
var addr [AddressLength]byte
|
||||
rand.Read(addr[:])
|
||||
trie.lookup(addr[:])
|
||||
|
@ -323,7 +323,7 @@ func NewDevice(tunDevice tun.Device, logger *Logger) *Device {
|
||||
|
||||
cpus := runtime.NumCPU()
|
||||
device.state.stopping.Wait()
|
||||
for i := 0; i < cpus; i += 1 {
|
||||
for i := 0; i < cpus; i++ {
|
||||
device.state.stopping.Add(2) // decryption and handshake
|
||||
go device.RoutineEncryption()
|
||||
go device.RoutineDecryption()
|
||||
|
@ -26,15 +26,15 @@ func (device *Device) PopulatePools() {
|
||||
}
|
||||
} else {
|
||||
device.pool.messageBufferReuseChan = make(chan *[MaxMessageSize]byte, PreallocatedBuffersPerPool)
|
||||
for i := 0; i < PreallocatedBuffersPerPool; i += 1 {
|
||||
for i := 0; i < PreallocatedBuffersPerPool; i++ {
|
||||
device.pool.messageBufferReuseChan <- new([MaxMessageSize]byte)
|
||||
}
|
||||
device.pool.inboundElementReuseChan = make(chan *QueueInboundElement, PreallocatedBuffersPerPool)
|
||||
for i := 0; i < PreallocatedBuffersPerPool; i += 1 {
|
||||
for i := 0; i < PreallocatedBuffersPerPool; i++ {
|
||||
device.pool.inboundElementReuseChan <- new(QueueInboundElement)
|
||||
}
|
||||
device.pool.outboundElementReuseChan = make(chan *QueueOutboundElement, PreallocatedBuffersPerPool)
|
||||
for i := 0; i < PreallocatedBuffersPerPool; i += 1 {
|
||||
for i := 0; i < PreallocatedBuffersPerPool; i++ {
|
||||
device.pool.outboundElementReuseChan <- new(QueueOutboundElement)
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ func CreateTUN(name string, mtu int) (Device, error) {
|
||||
if ifIndex != -1 {
|
||||
tunfile, err = os.OpenFile(fmt.Sprintf("/dev/tun%d", ifIndex), unix.O_RDWR, 0)
|
||||
} else {
|
||||
for ifIndex = 0; ifIndex < 256; ifIndex += 1 {
|
||||
for ifIndex = 0; ifIndex < 256; ifIndex++ {
|
||||
tunfile, err = os.OpenFile(fmt.Sprintf("/dev/tun%d", ifIndex), unix.O_RDWR, 0)
|
||||
if err == nil || !errorIsEBUSY(err) {
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user