Skip to content

Commit 0042280

Browse files
committed
Rename public API and remove deadcode in return_utils
1 parent 7a67041 commit 0042280

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

pythonbpf/functions/functions_pass.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
)
1515
from pythonbpf.allocation_pass import handle_assign_allocation, allocate_temp_pool
1616

17-
from .return_utils import _handle_none_return, _handle_xdp_return, _is_xdp_name
17+
from .return_utils import handle_none_return, handle_xdp_return, is_xdp_name
1818

1919

2020
logger = logging.getLogger(__name__)
@@ -146,9 +146,9 @@ def handle_if(
146146
def handle_return(builder, stmt, local_sym_tab, ret_type):
147147
logger.info(f"Handling return statement: {ast.dump(stmt)}")
148148
if stmt.value is None:
149-
return _handle_none_return(builder)
150-
elif isinstance(stmt.value, ast.Name) and _is_xdp_name(stmt.value.id):
151-
return _handle_xdp_return(stmt, builder, ret_type)
149+
return handle_none_return(builder)
150+
elif isinstance(stmt.value, ast.Name) and is_xdp_name(stmt.value.id):
151+
return handle_xdp_return(stmt, builder, ret_type)
152152
else:
153153
val = eval_expr(
154154
func=None,

pythonbpf/functions/return_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
}
1515

1616

17-
def _handle_none_return(builder) -> bool:
17+
def handle_none_return(builder) -> bool:
1818
"""Handle return or return None -> returns 0."""
1919
builder.ret(ir.Constant(ir.IntType(64), 0))
2020
logger.debug("Generated default return: 0")
2121
return True
2222

2323

24-
def _is_xdp_name(name: str) -> bool:
24+
def is_xdp_name(name: str) -> bool:
2525
"""Check if a name is an XDP action"""
2626
return name in XDP_ACTIONS
2727

2828

29-
def _handle_xdp_return(stmt: ast.Return, builder, ret_type) -> bool:
29+
def handle_xdp_return(stmt: ast.Return, builder, ret_type) -> bool:
3030
"""Handle XDP returns"""
3131
if not isinstance(stmt.value, ast.Name):
3232
return False
@@ -37,7 +37,6 @@ def _handle_xdp_return(stmt: ast.Return, builder, ret_type) -> bool:
3737
raise ValueError(
3838
f"Unknown XDP action: {action_name}. Available: {XDP_ACTIONS.keys()}"
3939
)
40-
return False
4140

4241
value = XDP_ACTIONS[action_name]
4342
builder.ret(ir.Constant(ret_type, value))

0 commit comments

Comments
 (0)