From c8faa34cdee37d9bcb588675e2385024bef86c18 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 15 Dec 2020 16:00:52 -0800 Subject: [PATCH] device: always name *Queue*Element variables elem They're called elem in most places. Rename a few local variables to make it consistent. This makes it easier to grep the code for things like elem.Drop. Signed-off-by: Josh Bleecher Snyder --- device/pools.go | 16 ++++++++-------- device/receive.go | 16 ++++++++-------- device/send.go | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/device/pools.go b/device/pools.go index 6939eeb..55eb6ab 100644 --- a/device/pools.go +++ b/device/pools.go @@ -64,12 +64,12 @@ func (device *Device) GetInboundElement() *QueueInboundElement { } } -func (device *Device) PutInboundElement(msg *QueueInboundElement) { - msg.clearPointers() +func (device *Device) PutInboundElement(elem *QueueInboundElement) { + elem.clearPointers() if PreallocatedBuffersPerPool == 0 { - device.pool.inboundElementPool.Put(msg) + device.pool.inboundElementPool.Put(elem) } else { - device.pool.inboundElementReuseChan <- msg + device.pool.inboundElementReuseChan <- elem } } @@ -81,11 +81,11 @@ func (device *Device) GetOutboundElement() *QueueOutboundElement { } } -func (device *Device) PutOutboundElement(msg *QueueOutboundElement) { - msg.clearPointers() +func (device *Device) PutOutboundElement(elem *QueueOutboundElement) { + elem.clearPointers() if PreallocatedBuffersPerPool == 0 { - device.pool.outboundElementPool.Put(msg) + device.pool.outboundElementPool.Put(elem) } else { - device.pool.outboundElementReuseChan <- msg + device.pool.outboundElementReuseChan <- elem } } diff --git a/device/receive.go b/device/receive.go index 852bd89..aeaae51 100644 --- a/device/receive.go +++ b/device/receive.go @@ -56,26 +56,26 @@ func (elem *QueueInboundElement) IsDropped() bool { return atomic.LoadInt32(&elem.dropped) == AtomicTrue } -func (device *Device) addToInboundAndDecryptionQueues(inboundQueue chan *QueueInboundElement, decryptionQueue chan *QueueInboundElement, element *QueueInboundElement) bool { +func (device *Device) addToInboundAndDecryptionQueues(inboundQueue chan *QueueInboundElement, decryptionQueue chan *QueueInboundElement, elem *QueueInboundElement) bool { select { - case inboundQueue <- element: + case inboundQueue <- elem: select { - case decryptionQueue <- element: + case decryptionQueue <- elem: return true default: - element.Drop() - element.Unlock() + elem.Drop() + elem.Unlock() return false } default: - device.PutInboundElement(element) + device.PutInboundElement(elem) return false } } -func (device *Device) addToHandshakeQueue(queue chan QueueHandshakeElement, element QueueHandshakeElement) bool { +func (device *Device) addToHandshakeQueue(queue chan QueueHandshakeElement, elem QueueHandshakeElement) bool { select { - case queue <- element: + case queue <- elem: return true default: return false diff --git a/device/send.go b/device/send.go index 1f71f79..6b21708 100644 --- a/device/send.go +++ b/device/send.go @@ -81,10 +81,10 @@ func (elem *QueueOutboundElement) IsDropped() bool { return atomic.LoadInt32(&elem.dropped) == AtomicTrue } -func addToNonceQueue(queue chan *QueueOutboundElement, element *QueueOutboundElement, device *Device) { +func addToNonceQueue(queue chan *QueueOutboundElement, elem *QueueOutboundElement, device *Device) { for { select { - case queue <- element: + case queue <- elem: return default: select { @@ -97,20 +97,20 @@ func addToNonceQueue(queue chan *QueueOutboundElement, element *QueueOutboundEle } } -func addToOutboundAndEncryptionQueues(outboundQueue chan *QueueOutboundElement, encryptionQueue chan *QueueOutboundElement, element *QueueOutboundElement) { +func addToOutboundAndEncryptionQueues(outboundQueue chan *QueueOutboundElement, encryptionQueue chan *QueueOutboundElement, elem *QueueOutboundElement) { select { - case outboundQueue <- element: + case outboundQueue <- elem: select { - case encryptionQueue <- element: + case encryptionQueue <- elem: return default: - element.Drop() - element.peer.device.PutMessageBuffer(element.buffer) - element.Unlock() + elem.Drop() + elem.peer.device.PutMessageBuffer(elem.buffer) + elem.Unlock() } default: - element.peer.device.PutMessageBuffer(element.buffer) - element.peer.device.PutOutboundElement(element) + elem.peer.device.PutMessageBuffer(elem.buffer) + elem.peer.device.PutOutboundElement(elem) } }