Skip to content

Commit 3ded17b

Browse files
committed
Fix size calc for ArrayType in structs
1 parent 715442d commit 3ded17b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pythonbpf/structs/struct_type.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ def gep(self, builder, ptr, field_name):
2222
def field_size(self, field_name):
2323
fld = self.fields[field_name]
2424
if isinstance(fld, ir.ArrayType):
25-
return fld.element.count * (fld.element.width // 8)
25+
return fld.count * (fld.element.width // 8)
2626
elif isinstance(fld, ir.IntType):
2727
return fld.width // 8
2828
elif isinstance(fld, ir.PointerType):
2929
return 8
30+
31+
raise TypeError(f"Unsupported field type: {fld}")

0 commit comments

Comments
 (0)