Skip to content

Commit

Permalink
refactor: getStackAddresses doesn't return an err
Browse files Browse the repository at this point in the history
  • Loading branch information
josedonizetti committed Aug 24, 2023
1 parent 5dd4431 commit b0424ea
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/ebpf/events_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (t *Tracee) decodeEvents(outerCtx context.Context, sourceChan chan []byte)
// Add stack trace if needed
var stackAddresses []uint64
if t.config.Output.StackAddresses {
stackAddresses, _ = t.getStackAddresses(ctx.StackID)
stackAddresses = t.getStackAddresses(ctx.StackID)
}

// Currently, the timestamp received from the bpf code is of the monotonic clock.
Expand Down Expand Up @@ -594,7 +594,7 @@ func (t *Tracee) sinkEvents(ctx context.Context, in <-chan *trace.Event) <-chan
return errc
}

func (t *Tracee) getStackAddresses(stackID uint32) ([]uint64, error) {
func (t *Tracee) getStackAddresses(stackID uint32) []uint64 {
stackAddresses := make([]uint64, maxStackDepth)
stackFrameSize := (strconv.IntSize / 8)

Expand All @@ -603,7 +603,8 @@ func (t *Tracee) getStackAddresses(stackID uint32) ([]uint64, error) {
// Stack IDs in it's Map
stackBytes, err := t.StackAddressesMap.GetValue(unsafe.Pointer(&stackID))
if err != nil {
return stackAddresses[0:0], nil
logger.Debugw("stackaddress already deleted", "error", err)
return stackAddresses[0:0]
}

stackCounter := 0
Expand All @@ -621,7 +622,7 @@ func (t *Tracee) getStackAddresses(stackID uint32) ([]uint64, error) {
// But if this fails continue on
_ = t.StackAddressesMap.DeleteKey(unsafe.Pointer(&stackID))

return stackAddresses[0:stackCounter], nil
return stackAddresses[0:stackCounter]
}

// WaitForPipeline waits for results from all error channels.
Expand Down

0 comments on commit b0424ea

Please sign in to comment.