@@ -40,11 +40,18 @@ const (
4040 Tbps = 1000 * Gbps
4141)
4242
43- // processMap generates statEntry objects from an ebpf.Map using the provided start time.
43+ // processMap processes a given ebpf.Map object by iterating over all its entries,
44+ // converting the counter values into a statEntry slice, and sorting the slice
45+ // using the given sortFunc.
4446//
4547// Parameters:
48+ // - m *ebpf.Map: the eBPF map to process
49+ // - start time.Time: the start time for calculating entry duration
50+ // - sortFunc func([]statEntry): a function to sort the statEntry slice
4651//
47- // m *ebpf.Map - the eb
52+ // Returns:
53+ // - []statEntry: the sorted statEntry slice
54+ // - error: an error if any occurred during map iteration, otherwise nil
4855func processMap (m * ebpf.Map , start time.Time , sortFunc func ([]statEntry )) ([]statEntry , error ) {
4956 stats , err := listMap (m , start )
5057 sortFunc (stats )
@@ -192,12 +199,16 @@ func outputJSON(m []statEntry) string {
192199 return string (out )
193200}
194201
195- // bsliceToString converts a byte slice to a string, trimming any null bytes.
202+ // bsliceToString converts a slice of int8 values to a string by first
203+ // transforming each int8 element to a byte. It then trims any NULL
204+ // characters from the resulting byte slice before converting it to
205+ // a string.
206+ //
207+ // Parameters:
208+ // - bs []int8: The slice of int8 values to be converted.
196209//
197- // It takes a byte slice as its parameter and returns a string.
198- // If the byte slice is empty, the function returns the string "kernel".
199- // Otherwise, it creates a new byte slice, copies the input byte slice into it,
200- // trims any null bytes from the end of the slice, and returns the result as a string.
210+ // Returns:
211+ // - string: The resulting string after conversion and trimming.
201212func bsliceToString (bs []int8 ) string {
202213 b := make ([]byte , len (bs ))
203214 for i , v := range bs {
0 commit comments