Skip to content

Commit 0d69186

Browse files
committed
Add is_map in maps_pass
1 parent 0fb1caf commit 0d69186

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

pythonbpf/maps_pass.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88

99
def maps_proc(tree, module, chunks):
1010
for func_node in chunks:
11-
# Check if this function is a map
12-
is_map = False
13-
for decorator in func_node.decorator_list:
14-
if isinstance(decorator, ast.Name) and decorator.id == "map":
15-
is_map = True
16-
break
17-
if is_map:
11+
if is_map(func_node):
1812
print(f"Found BPF map: {func_node.name}")
1913
process_bpf_map(func_node, module)
2014
continue
2115
return map_sym_tab
2216

2317

18+
def is_map(func_node):
19+
return any(
20+
isinstance(decorator, ast.Name) and decorator.id == "map"
21+
for decorator in func_node.decorator_list
22+
)
23+
24+
2425
BPF_MAP_MAPPINGS = {
2526
"HASH": 1, # BPF_MAP_TYPE_HASH
2627
"PERF_EVENT_ARRAY": 4, # BPF_MAP_TYPE_PERF_EVENT_ARRAY

0 commit comments

Comments
 (0)