Skip to content

Commit e467e07

Browse files
josharianzx2c4
authored andcommitted
all: use ++ to increment
Make the code slightly more idiomatic. No functional changes. Signed-off-by: Josh Bleecher Snyder <[email protected]>
1 parent f5576ba commit e467e07

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

device/allowedips_rand_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ func TestTrieRandomIPv4(t *testing.T) {
7373

7474
const AddressLength = 4
7575

76-
for n := 0; n < NumberOfPeers; n += 1 {
76+
for n := 0; n < NumberOfPeers; n++ {
7777
peers = append(peers, &Peer{})
7878
}
7979

80-
for n := 0; n < NumberOfAddresses; n += 1 {
80+
for n := 0; n < NumberOfAddresses; n++ {
8181
var addr [AddressLength]byte
8282
rand.Read(addr[:])
8383
cidr := uint(rand.Uint32() % (AddressLength * 8))
@@ -86,7 +86,7 @@ func TestTrieRandomIPv4(t *testing.T) {
8686
slow = slow.Insert(addr[:], cidr, peers[index])
8787
}
8888

89-
for n := 0; n < NumberOfTests; n += 1 {
89+
for n := 0; n < NumberOfTests; n++ {
9090
var addr [AddressLength]byte
9191
rand.Read(addr[:])
9292
peer1 := slow.Lookup(addr[:])
@@ -106,11 +106,11 @@ func TestTrieRandomIPv6(t *testing.T) {
106106

107107
const AddressLength = 16
108108

109-
for n := 0; n < NumberOfPeers; n += 1 {
109+
for n := 0; n < NumberOfPeers; n++ {
110110
peers = append(peers, &Peer{})
111111
}
112112

113-
for n := 0; n < NumberOfAddresses; n += 1 {
113+
for n := 0; n < NumberOfAddresses; n++ {
114114
var addr [AddressLength]byte
115115
rand.Read(addr[:])
116116
cidr := uint(rand.Uint32() % (AddressLength * 8))
@@ -119,7 +119,7 @@ func TestTrieRandomIPv6(t *testing.T) {
119119
slow = slow.Insert(addr[:], cidr, peers[index])
120120
}
121121

122-
for n := 0; n < NumberOfTests; n += 1 {
122+
for n := 0; n < NumberOfTests; n++ {
123123
var addr [AddressLength]byte
124124
rand.Read(addr[:])
125125
peer1 := slow.Lookup(addr[:])

device/allowedips_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ func benchmarkTrie(peerNumber int, addressNumber int, addressLength int, b *test
7070

7171
const AddressLength = 4
7272

73-
for n := 0; n < peerNumber; n += 1 {
73+
for n := 0; n < peerNumber; n++ {
7474
peers = append(peers, &Peer{})
7575
}
7676

77-
for n := 0; n < addressNumber; n += 1 {
77+
for n := 0; n < addressNumber; n++ {
7878
var addr [AddressLength]byte
7979
rand.Read(addr[:])
8080
cidr := uint(rand.Uint32() % (AddressLength * 8))
8181
index := rand.Int() % peerNumber
8282
trie = trie.insert(addr[:], cidr, peers[index])
8383
}
8484

85-
for n := 0; n < b.N; n += 1 {
85+
for n := 0; n < b.N; n++ {
8686
var addr [AddressLength]byte
8787
rand.Read(addr[:])
8888
trie.lookup(addr[:])

device/device.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func NewDevice(tunDevice tun.Device, logger *Logger) *Device {
323323

324324
cpus := runtime.NumCPU()
325325
device.state.stopping.Wait()
326-
for i := 0; i < cpus; i += 1 {
326+
for i := 0; i < cpus; i++ {
327327
device.state.stopping.Add(2) // decryption and handshake
328328
go device.RoutineEncryption()
329329
go device.RoutineDecryption()

device/pools.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ func (device *Device) PopulatePools() {
2626
}
2727
} else {
2828
device.pool.messageBufferReuseChan = make(chan *[MaxMessageSize]byte, PreallocatedBuffersPerPool)
29-
for i := 0; i < PreallocatedBuffersPerPool; i += 1 {
29+
for i := 0; i < PreallocatedBuffersPerPool; i++ {
3030
device.pool.messageBufferReuseChan <- new([MaxMessageSize]byte)
3131
}
3232
device.pool.inboundElementReuseChan = make(chan *QueueInboundElement, PreallocatedBuffersPerPool)
33-
for i := 0; i < PreallocatedBuffersPerPool; i += 1 {
33+
for i := 0; i < PreallocatedBuffersPerPool; i++ {
3434
device.pool.inboundElementReuseChan <- new(QueueInboundElement)
3535
}
3636
device.pool.outboundElementReuseChan = make(chan *QueueOutboundElement, PreallocatedBuffersPerPool)
37-
for i := 0; i < PreallocatedBuffersPerPool; i += 1 {
37+
for i := 0; i < PreallocatedBuffersPerPool; i++ {
3838
device.pool.outboundElementReuseChan <- new(QueueOutboundElement)
3939
}
4040
}

tun/tun_openbsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func CreateTUN(name string, mtu int) (Device, error) {
124124
if ifIndex != -1 {
125125
tunfile, err = os.OpenFile(fmt.Sprintf("/dev/tun%d", ifIndex), unix.O_RDWR, 0)
126126
} else {
127-
for ifIndex = 0; ifIndex < 256; ifIndex += 1 {
127+
for ifIndex = 0; ifIndex < 256; ifIndex++ {
128128
tunfile, err = os.OpenFile(fmt.Sprintf("/dev/tun%d", ifIndex), unix.O_RDWR, 0)
129129
if err == nil || !errorIsEBUSY(err) {
130130
break

0 commit comments

Comments
 (0)