From bd7bc63fac5851b1a1c7366a74504452578e237a Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Thu, 15 Nov 2018 21:16:43 +0100 Subject: [PATCH] prevent stack copy --- common/protocol/address.go | 1 + common/serial/serial.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/common/protocol/address.go b/common/protocol/address.go index 4f80e6c9..a3c628d4 100644 --- a/common/protocol/address.go +++ b/common/protocol/address.go @@ -226,6 +226,7 @@ func (p *addressParser) readAddress(b *buf.Buffer, reader io.Reader) (net.Addres } } +//go:nosplit func (p *addressParser) writeAddress(writer io.Writer, address net.Address) error { tb := p.addrByteMap[address.Family()] if tb == afInvalid { diff --git a/common/serial/serial.go b/common/serial/serial.go index c964db97..c2320bc9 100644 --- a/common/serial/serial.go +++ b/common/serial/serial.go @@ -9,6 +9,7 @@ import ( ) // ReadUint16 reads first two bytes from the reader, and then coverts them to an uint16 value. +//go:nosplit func ReadUint16(reader io.Reader) (uint16, error) { var b stack.TwoBytes s := b[:] @@ -22,6 +23,7 @@ func ReadUint16(reader io.Reader) (uint16, error) { } // WriteUint16 writes an uint16 value into writer. +//go:nosplit func WriteUint16(writer io.Writer, value uint16) (int, error) { var b stack.TwoBytes s := b[:] @@ -33,6 +35,7 @@ func WriteUint16(writer io.Writer, value uint16) (int, error) { } // WriteUint64 writes an uint64 value into writer. +//go:nosplit func WriteUint64(writer io.Writer, value uint64) (int, error) { var b stack.EightBytes s := b[:]