summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-11-08 08:44:47 +0000
committergVisor bot <gvisor-bot@google.com>2021-11-08 08:44:47 +0000
commit2c3ddc4dbfa7a32f08cb25cfa7cbf1b86245c3e5 (patch)
tree0208e21253a6c3b0e4e18ee013d63dae2c38437f
parentf62d5f516175c78eff1857ca938e2c53afb6b7a5 (diff)
parent4622e17bccc7c40a2698e8314d29bbde87090cec (diff)
Merge release-20211101.0-22-g4622e17bc (automated)
-rw-r--r--pkg/abi/linux/linux_abi_autogen_unsafe.go172
-rw-r--r--pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go24
-rw-r--r--pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go24
-rw-r--r--pkg/lisafs/lisafs_abi_autogen_unsafe.go92
-rw-r--r--pkg/lisafs/message.go52
-rw-r--r--pkg/lisafs/sample_message.go12
-rw-r--r--pkg/marshal/marshal.go4
-rw-r--r--pkg/marshal/primitive/primitive_abi_autogen_unsafe.go160
-rw-r--r--pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go20
9 files changed, 262 insertions, 298 deletions
diff --git a/pkg/abi/linux/linux_abi_autogen_unsafe.go b/pkg/abi/linux/linux_abi_autogen_unsafe.go
index f27f98b2d..1406f0a51 100644
--- a/pkg/abi/linux/linux_abi_autogen_unsafe.go
+++ b/pkg/abi/linux/linux_abi_autogen_unsafe.go
@@ -546,29 +546,29 @@ func CopyBPFInstructionSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src
}
// MarshalUnsafeBPFInstructionSlice is like BPFInstruction.MarshalUnsafe, but for a []BPFInstruction.
-func MarshalUnsafeBPFInstructionSlice(src []BPFInstruction, dst []byte) (int, error) {
+func MarshalUnsafeBPFInstructionSlice(src []BPFInstruction, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*BPFInstruction)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*BPFInstruction)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeBPFInstructionSlice is like BPFInstruction.UnmarshalUnsafe, but for a []BPFInstruction.
-func UnmarshalUnsafeBPFInstructionSlice(dst []BPFInstruction, src []byte) (int, error) {
+func UnmarshalUnsafeBPFInstructionSlice(dst []BPFInstruction, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*BPFInstruction)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*BPFInstruction)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -725,29 +725,29 @@ func CopyCapUserDataSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []C
}
// MarshalUnsafeCapUserDataSlice is like CapUserData.MarshalUnsafe, but for a []CapUserData.
-func MarshalUnsafeCapUserDataSlice(src []CapUserData, dst []byte) (int, error) {
+func MarshalUnsafeCapUserDataSlice(src []CapUserData, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*CapUserData)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*CapUserData)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeCapUserDataSlice is like CapUserData.UnmarshalUnsafe, but for a []CapUserData.
-func UnmarshalUnsafeCapUserDataSlice(dst []CapUserData, src []byte) (int, error) {
+func UnmarshalUnsafeCapUserDataSlice(dst []CapUserData, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*CapUserData)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*CapUserData)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -2231,45 +2231,45 @@ func CopyStatxSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []Statx)
}
// MarshalUnsafeStatxSlice is like Statx.MarshalUnsafe, but for a []Statx.
-func MarshalUnsafeStatxSlice(src []Statx, dst []byte) (int, error) {
+func MarshalUnsafeStatxSlice(src []Statx, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*Statx)(nil).SizeBytes()
if !src[0].Packed() {
// Type Statx doesn't have a packed layout in memory, fall back to MarshalBytes.
for idx := 0; idx < count; idx++ {
dst = src[idx].MarshalBytes(dst)
}
- return size * count, nil
+ return dst
}
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*Statx)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeStatxSlice is like Statx.UnmarshalUnsafe, but for a []Statx.
-func UnmarshalUnsafeStatxSlice(dst []Statx, src []byte) (int, error) {
+func UnmarshalUnsafeStatxSlice(dst []Statx, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*Statx)(nil).SizeBytes()
if !dst[0].Packed() {
// Type Statx doesn't have a packed layout in memory, fall back to UnmarshalBytes.
for idx := 0; idx < count; idx++ {
src = dst[idx].UnmarshalBytes(src)
}
- return size * count, nil
+ return src
}
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*Statx)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -10670,29 +10670,29 @@ func CopyPollFDSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []PollFD
}
// MarshalUnsafePollFDSlice is like PollFD.MarshalUnsafe, but for a []PollFD.
-func MarshalUnsafePollFDSlice(src []PollFD, dst []byte) (int, error) {
+func MarshalUnsafePollFDSlice(src []PollFD, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*PollFD)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*PollFD)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafePollFDSlice is like PollFD.UnmarshalUnsafe, but for a []PollFD.
-func UnmarshalUnsafePollFDSlice(dst []PollFD, src []byte) (int, error) {
+func UnmarshalUnsafePollFDSlice(dst []PollFD, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*PollFD)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*PollFD)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -11389,29 +11389,29 @@ func CopySembufSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []Sembuf
}
// MarshalUnsafeSembufSlice is like Sembuf.MarshalUnsafe, but for a []Sembuf.
-func MarshalUnsafeSembufSlice(src []Sembuf, dst []byte) (int, error) {
+func MarshalUnsafeSembufSlice(src []Sembuf, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*Sembuf)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*Sembuf)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeSembufSlice is like Sembuf.UnmarshalUnsafe, but for a []Sembuf.
-func UnmarshalUnsafeSembufSlice(dst []Sembuf, src []byte) (int, error) {
+func UnmarshalUnsafeSembufSlice(dst []Sembuf, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*Sembuf)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*Sembuf)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -15265,29 +15265,29 @@ func CopyTimespecSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []Time
}
// MarshalUnsafeTimespecSlice is like Timespec.MarshalUnsafe, but for a []Timespec.
-func MarshalUnsafeTimespecSlice(src []Timespec, dst []byte) (int, error) {
+func MarshalUnsafeTimespecSlice(src []Timespec, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*Timespec)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*Timespec)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeTimespecSlice is like Timespec.UnmarshalUnsafe, but for a []Timespec.
-func UnmarshalUnsafeTimespecSlice(dst []Timespec, src []byte) (int, error) {
+func UnmarshalUnsafeTimespecSlice(dst []Timespec, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*Timespec)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*Timespec)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -15440,29 +15440,29 @@ func CopyTimevalSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []Timev
}
// MarshalUnsafeTimevalSlice is like Timeval.MarshalUnsafe, but for a []Timeval.
-func MarshalUnsafeTimevalSlice(src []Timeval, dst []byte) (int, error) {
+func MarshalUnsafeTimevalSlice(src []Timeval, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*Timeval)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*Timeval)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeTimevalSlice is like Timeval.UnmarshalUnsafe, but for a []Timeval.
-func UnmarshalUnsafeTimevalSlice(dst []Timeval, src []byte) (int, error) {
+func UnmarshalUnsafeTimevalSlice(dst []Timeval, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*Timeval)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*Timeval)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
diff --git a/pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go b/pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go
index 75ce7393f..5308faba1 100644
--- a/pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go
+++ b/pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go
@@ -185,29 +185,29 @@ func CopyEpollEventSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []Ep
}
// MarshalUnsafeEpollEventSlice is like EpollEvent.MarshalUnsafe, but for a []EpollEvent.
-func MarshalUnsafeEpollEventSlice(src []EpollEvent, dst []byte) (int, error) {
+func MarshalUnsafeEpollEventSlice(src []EpollEvent, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*EpollEvent)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*EpollEvent)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeEpollEventSlice is like EpollEvent.UnmarshalUnsafe, but for a []EpollEvent.
-func UnmarshalUnsafeEpollEventSlice(dst []EpollEvent, src []byte) (int, error) {
+func UnmarshalUnsafeEpollEventSlice(dst []EpollEvent, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*EpollEvent)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*EpollEvent)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
diff --git a/pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go b/pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go
index f23283a7b..951baa8ab 100644
--- a/pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go
+++ b/pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go
@@ -189,29 +189,29 @@ func CopyEpollEventSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []Ep
}
// MarshalUnsafeEpollEventSlice is like EpollEvent.MarshalUnsafe, but for a []EpollEvent.
-func MarshalUnsafeEpollEventSlice(src []EpollEvent, dst []byte) (int, error) {
+func MarshalUnsafeEpollEventSlice(src []EpollEvent, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*EpollEvent)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*EpollEvent)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeEpollEventSlice is like EpollEvent.UnmarshalUnsafe, but for a []EpollEvent.
-func UnmarshalUnsafeEpollEventSlice(dst []EpollEvent, src []byte) (int, error) {
+func UnmarshalUnsafeEpollEventSlice(dst []EpollEvent, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*EpollEvent)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*EpollEvent)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
diff --git a/pkg/lisafs/lisafs_abi_autogen_unsafe.go b/pkg/lisafs/lisafs_abi_autogen_unsafe.go
index 1df29512b..363c1bba2 100644
--- a/pkg/lisafs/lisafs_abi_autogen_unsafe.go
+++ b/pkg/lisafs/lisafs_abi_autogen_unsafe.go
@@ -334,29 +334,29 @@ func CopyFDIDSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []FDID) (i
}
// MarshalUnsafeFDIDSlice is like FDID.MarshalUnsafe, but for a []FDID.
-func MarshalUnsafeFDIDSlice(src []FDID, dst []byte) (int, error) {
+func MarshalUnsafeFDIDSlice(src []FDID, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*FDID)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeFDIDSlice is like FDID.UnmarshalUnsafe, but for a []FDID.
-func UnmarshalUnsafeFDIDSlice(dst []FDID, src []byte) (int, error) {
+func UnmarshalUnsafeFDIDSlice(dst []FDID, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*FDID)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -1658,45 +1658,45 @@ func CopyInodeSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []Inode)
}
// MarshalUnsafeInodeSlice is like Inode.MarshalUnsafe, but for a []Inode.
-func MarshalUnsafeInodeSlice(src []Inode, dst []byte) (int, error) {
+func MarshalUnsafeInodeSlice(src []Inode, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*Inode)(nil).SizeBytes()
if !src[0].Packed() {
// Type Inode doesn't have a packed layout in memory, fall back to MarshalBytes.
for idx := 0; idx < count; idx++ {
dst = src[idx].MarshalBytes(dst)
}
- return size * count, nil
+ return dst
}
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*Inode)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeInodeSlice is like Inode.UnmarshalUnsafe, but for a []Inode.
-func UnmarshalUnsafeInodeSlice(dst []Inode, src []byte) (int, error) {
+func UnmarshalUnsafeInodeSlice(dst []Inode, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*Inode)(nil).SizeBytes()
if !dst[0].Packed() {
// Type Inode doesn't have a packed layout in memory, fall back to UnmarshalBytes.
for idx := 0; idx < count; idx++ {
src = dst[idx].UnmarshalBytes(src)
}
- return size * count, nil
+ return src
}
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*Inode)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -1974,29 +1974,29 @@ func CopyMIDSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []MID) (int
}
// MarshalUnsafeMIDSlice is like MID.MarshalUnsafe, but for a []MID.
-func MarshalUnsafeMIDSlice(src []MID, dst []byte) (int, error) {
+func MarshalUnsafeMIDSlice(src []MID, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*MID)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeMIDSlice is like MID.UnmarshalUnsafe, but for a []MID.
-func UnmarshalUnsafeMIDSlice(dst []MID, src []byte) (int, error) {
+func UnmarshalUnsafeMIDSlice(dst []MID, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*MID)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -4081,29 +4081,29 @@ func CopyMsg1SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []MsgSimpl
}
// MarshalUnsafeMsg1Slice is like MsgSimple.MarshalUnsafe, but for a []MsgSimple.
-func MarshalUnsafeMsg1Slice(src []MsgSimple, dst []byte) (int, error) {
+func MarshalUnsafeMsg1Slice(src []MsgSimple, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
- size := (*MsgSimple)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size * count, nil
+ size := (*MsgSimple)(nil).SizeBytes()
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeMsg1Slice is like MsgSimple.UnmarshalUnsafe, but for a []MsgSimple.
-func UnmarshalUnsafeMsg1Slice(dst []MsgSimple, src []byte) (int, error) {
+func UnmarshalUnsafeMsg1Slice(dst []MsgSimple, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
- size := (*MsgSimple)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return count*size, nil
+ size := (*MsgSimple)(nil).SizeBytes()
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// Packed implements marshal.Marshallable.Packed.
diff --git a/pkg/lisafs/message.go b/pkg/lisafs/message.go
index 0d7c30ce3..c5474d804 100644
--- a/pkg/lisafs/message.go
+++ b/pkg/lisafs/message.go
@@ -307,11 +307,7 @@ func (m *MountResp) MarshalBytes(dst []byte) []byte {
dst = m.MaxMessageSize.MarshalUnsafe(dst)
numSupported := primitive.Uint16(len(m.SupportedMs))
dst = numSupported.MarshalBytes(dst)
- n, err := MarshalUnsafeMIDSlice(m.SupportedMs, dst)
- if err != nil {
- panic(err)
- }
- return dst[n:]
+ return MarshalUnsafeMIDSlice(m.SupportedMs, dst)
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
@@ -320,12 +316,12 @@ func (m *MountResp) UnmarshalBytes(src []byte) []byte {
src = m.MaxMessageSize.UnmarshalUnsafe(src)
var numSupported primitive.Uint16
src = numSupported.UnmarshalBytes(src)
- m.SupportedMs = make([]MID, numSupported)
- n, err := UnmarshalUnsafeMIDSlice(m.SupportedMs, src)
- if err != nil {
- panic(err)
+ if cap(m.SupportedMs) < int(numSupported) {
+ m.SupportedMs = make([]MID, numSupported)
+ } else {
+ m.SupportedMs = m.SupportedMs[:numSupported]
}
- return src[n:]
+ return UnmarshalUnsafeMIDSlice(m.SupportedMs, src)
}
// ChannelResp is the response to the create channel request.
@@ -440,11 +436,7 @@ func (w *WalkResp) MarshalBytes(dst []byte) []byte {
numInodes := primitive.Uint32(len(w.Inodes))
dst = numInodes.MarshalUnsafe(dst)
- n, err := MarshalUnsafeInodeSlice(w.Inodes, dst)
- if err != nil {
- panic(err)
- }
- return dst[n:]
+ return MarshalUnsafeInodeSlice(w.Inodes, dst)
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
@@ -459,11 +451,7 @@ func (w *WalkResp) UnmarshalBytes(src []byte) []byte {
} else {
w.Inodes = w.Inodes[:numInodes]
}
- n, err := UnmarshalUnsafeInodeSlice(w.Inodes, src)
- if err != nil {
- panic(err)
- }
- return src[n:]
+ return UnmarshalUnsafeInodeSlice(w.Inodes, src)
}
// WalkStatResp is used to communicate stat results for WalkStat.
@@ -481,11 +469,7 @@ func (w *WalkStatResp) MarshalBytes(dst []byte) []byte {
numStats := primitive.Uint32(len(w.Stats))
dst = numStats.MarshalUnsafe(dst)
- n, err := linux.MarshalUnsafeStatxSlice(w.Stats, dst)
- if err != nil {
- panic(err)
- }
- return dst[n:]
+ return linux.MarshalUnsafeStatxSlice(w.Stats, dst)
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
@@ -498,11 +482,7 @@ func (w *WalkStatResp) UnmarshalBytes(src []byte) []byte {
} else {
w.Stats = w.Stats[:numStats]
}
- n, err := linux.UnmarshalUnsafeStatxSlice(w.Stats, src)
- if err != nil {
- panic(err)
- }
- return src[n:]
+ return linux.UnmarshalUnsafeStatxSlice(w.Stats, src)
}
// OpenAtReq is used to open existing FDs with the specified flags.
@@ -578,11 +558,7 @@ func (f *FdArray) SizeBytes() int {
func (f *FdArray) MarshalBytes(dst []byte) []byte {
arrLen := primitive.Uint32(len(*f))
dst = arrLen.MarshalUnsafe(dst)
- n, err := MarshalUnsafeFDIDSlice(*f, dst)
- if err != nil {
- panic(err)
- }
- return dst[n:]
+ return MarshalUnsafeFDIDSlice(*f, dst)
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
@@ -594,11 +570,7 @@ func (f *FdArray) UnmarshalBytes(src []byte) []byte {
} else {
*f = (*f)[:arrLen]
}
- n, err := UnmarshalUnsafeFDIDSlice(*f, src)
- if err != nil {
- panic(err)
- }
- return src[n:]
+ return UnmarshalUnsafeFDIDSlice(*f, src)
}
// CloseReq is used to close(2) FDs.
diff --git a/pkg/lisafs/sample_message.go b/pkg/lisafs/sample_message.go
index 745736b6d..3d4c090e4 100644
--- a/pkg/lisafs/sample_message.go
+++ b/pkg/lisafs/sample_message.go
@@ -55,22 +55,14 @@ func (m *MsgDynamic) SizeBytes() int {
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (m *MsgDynamic) MarshalBytes(dst []byte) []byte {
dst = m.N.MarshalUnsafe(dst)
- n, err := MarshalUnsafeMsg1Slice(m.Arr, dst)
- if err != nil {
- panic(err)
- }
- return dst[n:]
+ return MarshalUnsafeMsg1Slice(m.Arr, dst)
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (m *MsgDynamic) UnmarshalBytes(src []byte) []byte {
src = m.N.UnmarshalUnsafe(src)
m.Arr = make([]MsgSimple, m.N)
- n, err := UnmarshalUnsafeMsg1Slice(m.Arr, src)
- if err != nil {
- panic(err)
- }
- return src[n:]
+ return UnmarshalUnsafeMsg1Slice(m.Arr, src)
}
// Randomize randomizes the contents of m.
diff --git a/pkg/marshal/marshal.go b/pkg/marshal/marshal.go
index 9e34eae80..a48a5835d 100644
--- a/pkg/marshal/marshal.go
+++ b/pkg/marshal/marshal.go
@@ -150,13 +150,13 @@ type Marshallable interface {
// // might be more efficient that repeatedly calling Foo.MarshalUnsafe
// // over a []Foo in a loop if the type is Packed.
// // Preconditions: dst must be at least len(src)*Foo.SizeBytes() in length.
-// func MarshalUnsafeFooSlice(src []Foo, dst []byte) (int, error) { ... }
+// func MarshalUnsafeFooSlice(src []Foo, dst []byte) []byte { ... }
//
// // UnmarshalUnsafeFooSlice is like Foo.UnmarshalUnsafe, buf for a []Foo. It
// // might be more efficient that repeatedly calling Foo.UnmarshalUnsafe
// // over a []Foo in a loop if the type is Packed.
// // Preconditions: src must be at least len(dst)*Foo.SizeBytes() in length.
-// func UnmarshalUnsafeFooSlice(dst []Foo, src []byte) (int, error) { ... }
+// func UnmarshalUnsafeFooSlice(dst []Foo, src []byte) []byte { ... }
//
// // CopyFooSliceIn copies in a slice of Foo objects from the task's memory.
// func CopyFooSliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []Foo) (int, error) { ... }
diff --git a/pkg/marshal/primitive/primitive_abi_autogen_unsafe.go b/pkg/marshal/primitive/primitive_abi_autogen_unsafe.go
index 792c0a693..f8174e98c 100644
--- a/pkg/marshal/primitive/primitive_abi_autogen_unsafe.go
+++ b/pkg/marshal/primitive/primitive_abi_autogen_unsafe.go
@@ -170,29 +170,29 @@ func CopyInt16SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []int16)
}
// MarshalUnsafeInt16Slice is like Int16.MarshalUnsafe, but for a []Int16.
-func MarshalUnsafeInt16Slice(src []Int16, dst []byte) (int, error) {
+func MarshalUnsafeInt16Slice(src []Int16, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*Int16)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeInt16Slice is like Int16.UnmarshalUnsafe, but for a []Int16.
-func UnmarshalUnsafeInt16Slice(dst []Int16, src []byte) (int, error) {
+func UnmarshalUnsafeInt16Slice(dst []Int16, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*Int16)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -343,29 +343,29 @@ func CopyInt32SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []int32)
}
// MarshalUnsafeInt32Slice is like Int32.MarshalUnsafe, but for a []Int32.
-func MarshalUnsafeInt32Slice(src []Int32, dst []byte) (int, error) {
+func MarshalUnsafeInt32Slice(src []Int32, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*Int32)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeInt32Slice is like Int32.UnmarshalUnsafe, but for a []Int32.
-func UnmarshalUnsafeInt32Slice(dst []Int32, src []byte) (int, error) {
+func UnmarshalUnsafeInt32Slice(dst []Int32, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*Int32)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -516,29 +516,29 @@ func CopyInt64SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []int64)
}
// MarshalUnsafeInt64Slice is like Int64.MarshalUnsafe, but for a []Int64.
-func MarshalUnsafeInt64Slice(src []Int64, dst []byte) (int, error) {
+func MarshalUnsafeInt64Slice(src []Int64, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*Int64)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeInt64Slice is like Int64.UnmarshalUnsafe, but for a []Int64.
-func UnmarshalUnsafeInt64Slice(dst []Int64, src []byte) (int, error) {
+func UnmarshalUnsafeInt64Slice(dst []Int64, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*Int64)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -689,29 +689,29 @@ func CopyInt8SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []int8) (i
}
// MarshalUnsafeInt8Slice is like Int8.MarshalUnsafe, but for a []Int8.
-func MarshalUnsafeInt8Slice(src []Int8, dst []byte) (int, error) {
+func MarshalUnsafeInt8Slice(src []Int8, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*Int8)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeInt8Slice is like Int8.UnmarshalUnsafe, but for a []Int8.
-func UnmarshalUnsafeInt8Slice(dst []Int8, src []byte) (int, error) {
+func UnmarshalUnsafeInt8Slice(dst []Int8, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*Int8)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -862,29 +862,29 @@ func CopyUint16SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []uint16
}
// MarshalUnsafeUint16Slice is like Uint16.MarshalUnsafe, but for a []Uint16.
-func MarshalUnsafeUint16Slice(src []Uint16, dst []byte) (int, error) {
+func MarshalUnsafeUint16Slice(src []Uint16, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*Uint16)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeUint16Slice is like Uint16.UnmarshalUnsafe, but for a []Uint16.
-func UnmarshalUnsafeUint16Slice(dst []Uint16, src []byte) (int, error) {
+func UnmarshalUnsafeUint16Slice(dst []Uint16, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*Uint16)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -1035,29 +1035,29 @@ func CopyUint32SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []uint32
}
// MarshalUnsafeUint32Slice is like Uint32.MarshalUnsafe, but for a []Uint32.
-func MarshalUnsafeUint32Slice(src []Uint32, dst []byte) (int, error) {
+func MarshalUnsafeUint32Slice(src []Uint32, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*Uint32)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeUint32Slice is like Uint32.UnmarshalUnsafe, but for a []Uint32.
-func UnmarshalUnsafeUint32Slice(dst []Uint32, src []byte) (int, error) {
+func UnmarshalUnsafeUint32Slice(dst []Uint32, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*Uint32)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -1208,29 +1208,29 @@ func CopyUint64SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []uint64
}
// MarshalUnsafeUint64Slice is like Uint64.MarshalUnsafe, but for a []Uint64.
-func MarshalUnsafeUint64Slice(src []Uint64, dst []byte) (int, error) {
+func MarshalUnsafeUint64Slice(src []Uint64, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*Uint64)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeUint64Slice is like Uint64.UnmarshalUnsafe, but for a []Uint64.
-func UnmarshalUnsafeUint64Slice(dst []Uint64, src []byte) (int, error) {
+func UnmarshalUnsafeUint64Slice(dst []Uint64, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*Uint64)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -1381,28 +1381,28 @@ func CopyUint8SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []uint8)
}
// MarshalUnsafeUint8Slice is like Uint8.MarshalUnsafe, but for a []Uint8.
-func MarshalUnsafeUint8Slice(src []Uint8, dst []byte) (int, error) {
+func MarshalUnsafeUint8Slice(src []Uint8, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*Uint8)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeUint8Slice is like Uint8.UnmarshalUnsafe, but for a []Uint8.
-func UnmarshalUnsafeUint8Slice(dst []Uint8, src []byte) (int, error) {
+func UnmarshalUnsafeUint8Slice(dst []Uint8, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*Uint8)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
diff --git a/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go b/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go
index 770e66602..e5fe5f599 100644
--- a/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go
+++ b/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go
@@ -164,29 +164,29 @@ func CopyGIDSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []GID) (int
}
// MarshalUnsafeGIDSlice is like GID.MarshalUnsafe, but for a []GID.
-func MarshalUnsafeGIDSlice(src []GID, dst []byte) (int, error) {
+func MarshalUnsafeGIDSlice(src []GID, dst []byte) []byte {
count := len(src)
if count == 0 {
- return 0, nil
+ return dst
}
size := (*GID)(nil).SizeBytes()
- dst = dst[:size*count]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
- return size*count, nil
+ buf := dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
+ return dst[size*count:]
}
// UnmarshalUnsafeGIDSlice is like GID.UnmarshalUnsafe, but for a []GID.
-func UnmarshalUnsafeGIDSlice(dst []GID, src []byte) (int, error) {
+func UnmarshalUnsafeGIDSlice(dst []GID, src []byte) []byte {
count := len(dst)
if count == 0 {
- return 0, nil
+ return src
}
size := (*GID)(nil).SizeBytes()
- src = src[:(size*count)]
- gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
- return size*count, nil
+ buf := src[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
+ return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.