Skip to content

Commit 189526d

Browse files
format chore
1 parent 1593b7b commit 189526d

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

pythonbpf/allocation_pass.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,19 @@ def _allocate_for_call(
117117
if len(rval.args) == 0:
118118
# Zero-arg constructor: allocate the struct itself
119119
var = builder.alloca(struct_info.ir_type, name=var_name)
120-
local_sym_tab[var_name] = LocalSymbol(var, struct_info.ir_type, call_type)
120+
local_sym_tab[var_name] = LocalSymbol(
121+
var, struct_info.ir_type, call_type
122+
)
121123
logger.info(f"Pre-allocated {var_name} for struct {call_type}")
122124
else:
123125
# Pointer cast: allocate as pointer to struct
124126
ptr_type = ir.PointerType(struct_info.ir_type)
125127
var = builder.alloca(ptr_type, name=var_name)
126128
var.align = 8
127129
local_sym_tab[var_name] = LocalSymbol(var, ptr_type, call_type)
128-
logger.info(f"Pre-allocated {var_name} for struct pointer cast to {call_type}")
130+
logger.info(
131+
f"Pre-allocated {var_name} for struct pointer cast to {call_type}"
132+
)
129133

130134
elif VmlinuxHandlerRegistry.is_vmlinux_struct(call_type):
131135
# When calling struct_name(pointer), we're doing a cast, not construction

pythonbpf/expr/expr_pass.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,13 @@ def _handle_vmlinux_cast(
682682

683683

684684
def _handle_user_defined_struct_cast(
685-
func,
686-
module,
687-
builder,
688-
expr,
689-
local_sym_tab,
690-
map_sym_tab,
691-
structs_sym_tab,
685+
func,
686+
module,
687+
builder,
688+
expr,
689+
local_sym_tab,
690+
map_sym_tab,
691+
structs_sym_tab,
692692
):
693693
"""Handle user-defined struct cast expressions like iphdr(nh).
694694
@@ -744,6 +744,7 @@ def _handle_user_defined_struct_cast(
744744

745745
return casted_ptr, struct_name
746746

747+
747748
# ============================================================================
748749
# Expression Dispatcher
749750
# ============================================================================

tests/failing_tests/xdp/xdp_test_1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pythonbpf import bpf, section, bpfglobal, compile, compile_to_ir, struct
77
from ctypes import c_int64, c_ubyte, c_ushort, c_uint32
88

9+
910
@bpf
1011
@struct
1112
class iphdr:
@@ -19,6 +20,7 @@ class iphdr:
1920
saddr: c_uint32
2021
daddr: c_uint32
2122

23+
2224
@bpf
2325
@section("xdp")
2426
def ip_detector(ctx: struct_xdp_md) -> c_int64:

0 commit comments

Comments
 (0)