Skip to content

Commit

Permalink
Revert "simple: The btf type must be a pointer"
Browse files Browse the repository at this point in the history
This reverts commit 2f85ee2.
  • Loading branch information
Asphaltt committed Mar 8, 2025
1 parent 2f85ee2 commit 4dc53e6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
5 changes: 0 additions & 5 deletions simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package bice
import (
"fmt"

"github.com/Asphaltt/mybtf"
"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/btf"
)
Expand Down Expand Up @@ -70,10 +69,6 @@ import (
// The operator must be one of the following: =, ==, !=, <, <=, >, >=. '=' is
// used for comparison too.
func SimpleCompile(expr string, typ btf.Type) (asm.Instructions, error) {
if _, isPtr := mybtf.UnderlyingType(typ).(*btf.Pointer); !isPtr {
return nil, fmt.Errorf("type(%s) is not a pointer", typ)
}

ast, err := parse(expr)
if err != nil {
return nil, fmt.Errorf("failed to parse expression(%s): %w", expr, err)
Expand Down
10 changes: 1 addition & 9 deletions simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@
package bice

import (
"fmt"
"testing"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/btf"
"github.com/leonhwangprojects/bice/internal/test"
)

func TestSimpleCompile(t *testing.T) {
t.Run("non-pointer type", func(t *testing.T) {
_, err := SimpleCompile("skb->len > 1024", &btf.Int{})
test.AssertHaveErr(t, err)
test.AssertStrPrefix(t, err.Error(), fmt.Sprintf("type(%s) is not a pointer", &btf.Int{}))
})

t.Run("failed to parse", func(t *testing.T) {
_, err := SimpleCompile("a)(test)", getSkbBtf(t))
_, err := SimpleCompile("a)(test)", nil)
test.AssertHaveErr(t, err)
test.AssertStrPrefix(t, err.Error(), "failed to parse expression")
})
Expand Down

0 comments on commit 4dc53e6

Please sign in to comment.