aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ipc
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-05-07 17:04:18 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-05-16 15:38:27 +0000
commitf694ecdc179cf43429135188934eed687ae28645 (patch)
tree5302e424961f85abe2043dd0cf680859df939ceb /pkg/ipc
parent5b8f52cdd0b790158fdbe88d0fd902d24f8a996d (diff)
pkg/ipc: split out EmptyProgInfo()
Diffstat (limited to 'pkg/ipc')
-rw-r--r--pkg/ipc/ipc.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go
index c83fabe84..826d3068d 100644
--- a/pkg/ipc/ipc.go
+++ b/pkg/ipc/ipc.go
@@ -105,6 +105,17 @@ type ProgInfo struct {
Freshness int // number of programs executed in the same process before this one
}
+func EmptyProgInfo(calls int) *ProgInfo {
+ info := &ProgInfo{Calls: make([]CallInfo, calls)}
+ for i := range info.Calls {
+ // Store some unsuccessful errno in the case we won't get any result.
+ // It also won't have CallExecuted flag, but it's handy to make it
+ // look failed based on errno as well.
+ info.Calls[i].Errno = int(syscall.ENOSYS)
+ }
+ return info
+}
+
type Env struct {
in []byte
out []byte
@@ -401,13 +412,7 @@ func (env *Env) parseOutput(opts *ExecOpts, ncalls int) (*ProgInfo, error) {
if !ok {
return nil, fmt.Errorf("failed to read number of calls")
}
- info := &ProgInfo{Calls: make([]CallInfo, ncalls)}
- for i := range info.Calls {
- // Store some unsuccessful errno in the case we won't get any result.
- // It also won't have CallExecuted flag, but it's handy to make it
- // look failed based on errno as well.
- info.Calls[i].Errno = int(syscall.ENOSYS)
- }
+ info := EmptyProgInfo(ncalls)
extraParts := make([]CallInfo, 0)
for i := uint32(0); i < ncmd; i++ {
if len(out) < int(unsafe.Sizeof(callReply{})) {