diff options
Diffstat (limited to 'prog/encodingexec.go')
| -rw-r--r-- | prog/encodingexec.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/prog/encodingexec.go b/prog/encodingexec.go index b2b173bbe..e45ba1192 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -57,8 +57,9 @@ func (s ByPhysicalAddr) Less(i, j int) bool { } // SerializeForExec serializes program p for execution by process pid into the provided buffer. +// Returns number of bytes written to the buffer. // If the provided buffer is too small for the program an error is returned. -func (p *Prog) SerializeForExec(buffer []byte, pid int) error { +func (p *Prog) SerializeForExec(buffer []byte, pid int) (int, error) { if debug { if err := p.validate(); err != nil { panic(fmt.Errorf("serializing invalid program: %v", err)) @@ -193,9 +194,9 @@ func (p *Prog) SerializeForExec(buffer []byte, pid int) error { } w.write(ExecInstrEOF) if w.eof { - return fmt.Errorf("provided buffer is too small") + return 0, fmt.Errorf("provided buffer is too small") } - return nil + return len(buffer) - len(w.buf), nil } func (target *Target) physicalAddr(arg Arg) uint64 { |
