mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Merge pull request #23 from pythonbpf/formatter
update formatter and pre-commit
This commit is contained in:
@ -146,8 +146,7 @@ def handle_assign(
|
||||
local_sym_tab[var_name].var,
|
||||
)
|
||||
logger.info(
|
||||
f"Assigned {call_type} constant "
|
||||
f"{rval.args[0].value} to {var_name}"
|
||||
f"Assigned {call_type} constant {rval.args[0].value} to {var_name}"
|
||||
)
|
||||
elif HelperHandlerRegistry.has_handler(call_type):
|
||||
# var = builder.alloca(ir.IntType(64), name=var_name)
|
||||
@ -483,8 +482,7 @@ def allocate_mem(
|
||||
var = builder.alloca(ir_type, name=var_name)
|
||||
has_metadata = True
|
||||
logger.info(
|
||||
f"Pre-allocated variable {var_name} "
|
||||
f"for struct {call_type}"
|
||||
f"Pre-allocated variable {var_name} for struct {call_type}"
|
||||
)
|
||||
elif isinstance(rval.func, ast.Attribute):
|
||||
ir_type = ir.PointerType(ir.IntType(64))
|
||||
|
||||
@ -62,7 +62,7 @@ def bpf_map_lookup_elem_emitter(
|
||||
"""
|
||||
if not call.args or len(call.args) != 1:
|
||||
raise ValueError(
|
||||
"Map lookup expects exactly one argument (key), got " f"{len(call.args)}"
|
||||
f"Map lookup expects exactly one argument (key), got {len(call.args)}"
|
||||
)
|
||||
key_ptr = get_or_create_ptr_from_arg(call.args[0], builder, local_sym_tab)
|
||||
map_void_ptr = builder.bitcast(map_ptr, ir.PointerType())
|
||||
@ -145,8 +145,7 @@ def bpf_map_update_elem_emitter(
|
||||
"""
|
||||
if not call.args or len(call.args) < 2 or len(call.args) > 3:
|
||||
raise ValueError(
|
||||
"Map update expects 2 or 3 args (key, value, flags), "
|
||||
f"got {len(call.args)}"
|
||||
f"Map update expects 2 or 3 args (key, value, flags), got {len(call.args)}"
|
||||
)
|
||||
|
||||
key_arg = call.args[0]
|
||||
@ -196,7 +195,7 @@ def bpf_map_delete_elem_emitter(
|
||||
"""
|
||||
if not call.args or len(call.args) != 1:
|
||||
raise ValueError(
|
||||
"Map delete expects exactly one argument (key), got " f"{len(call.args)}"
|
||||
f"Map delete expects exactly one argument (key), got {len(call.args)}"
|
||||
)
|
||||
key_ptr = get_or_create_ptr_from_arg(call.args[0], builder, local_sym_tab)
|
||||
map_void_ptr = builder.bitcast(map_ptr, ir.PointerType())
|
||||
@ -255,7 +254,7 @@ def bpf_perf_event_output_handler(
|
||||
):
|
||||
if len(call.args) != 1:
|
||||
raise ValueError(
|
||||
"Perf event output expects exactly one argument, " f"got {len(call.args)}"
|
||||
f"Perf event output expects exactly one argument, got {len(call.args)}"
|
||||
)
|
||||
data_arg = call.args[0]
|
||||
ctx_ptr = func.args[0] # First argument to the function is ctx
|
||||
|
||||
@ -270,7 +270,7 @@ def _prepare_expr_args(expr, func, module, builder, local_sym_tab, struct_sym_ta
|
||||
val = builder.sext(val, ir.IntType(64))
|
||||
else:
|
||||
logger.warning(
|
||||
"Only int and ptr supported in bpf_printk args. " "Others default to 0."
|
||||
"Only int and ptr supported in bpf_printk args. Others default to 0."
|
||||
)
|
||||
val = ir.Constant(ir.IntType(64), 0)
|
||||
return val
|
||||
|
||||
@ -278,9 +278,7 @@ def process_bpf_map(func_node, module):
|
||||
if handler:
|
||||
return handler(map_name, rval, module)
|
||||
else:
|
||||
logger.warning(
|
||||
f"Unknown map type " f"{rval.func.id}, defaulting to HashMap"
|
||||
)
|
||||
logger.warning(f"Unknown map type {rval.func.id}, defaulting to HashMap")
|
||||
return process_hash_map(map_name, rval, module)
|
||||
else:
|
||||
raise ValueError("Function under @map must return a map")
|
||||
|
||||
Reference in New Issue
Block a user