global: buff -> buf

This always struck me as kind of weird and non-standard.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2023-03-13 17:55:05 +01:00
parent 7d327ed35a
commit 0ad14a89f5
18 changed files with 189 additions and 189 deletions

View File

@@ -141,7 +141,7 @@ func (tun *NativeTun) BatchSize() int {
// Note: Read() and Write() assume the caller comes only from a single thread; there's no locking.
func (tun *NativeTun) Read(buffs [][]byte, sizes []int, offset int) (int, error) {
func (tun *NativeTun) Read(bufs [][]byte, sizes []int, offset int) (int, error) {
tun.running.Add(1)
defer tun.running.Done()
retry:
@@ -158,7 +158,7 @@ retry:
switch err {
case nil:
packetSize := len(packet)
copy(buffs[0][offset:], packet)
copy(bufs[0][offset:], packet)
sizes[0] = packetSize
tun.session.ReleaseReceivePacket(packet)
tun.rate.update(uint64(packetSize))
@@ -179,22 +179,22 @@ retry:
}
}
func (tun *NativeTun) Write(buffs [][]byte, offset int) (int, error) {
func (tun *NativeTun) Write(bufs [][]byte, offset int) (int, error) {
tun.running.Add(1)
defer tun.running.Done()
if tun.close.Load() {
return 0, os.ErrClosed
}
for i, buff := range buffs {
packetSize := len(buff) - offset
for i, buf := range bufs {
packetSize := len(buf) - offset
tun.rate.update(uint64(packetSize))
packet, err := tun.session.AllocateSendPacket(packetSize)
switch err {
case nil:
// TODO: Explore options to eliminate this copy.
copy(packet, buff[offset:])
copy(packet, buf[offset:])
tun.session.SendPacket(packet)
continue
case windows.ERROR_HANDLE_EOF:
@@ -205,7 +205,7 @@ func (tun *NativeTun) Write(buffs [][]byte, offset int) (int, error) {
return i, fmt.Errorf("Write failed: %w", err)
}
}
return len(buffs), nil
return len(bufs), nil
}
// LUID returns Windows interface instance ID.