diff options
Diffstat (limited to 'lib9p/core_gen/c_marshal.py')
-rw-r--r-- | lib9p/core_gen/c_marshal.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib9p/core_gen/c_marshal.py b/lib9p/core_gen/c_marshal.py index 322e1ef..581ed92 100644 --- a/lib9p/core_gen/c_marshal.py +++ b/lib9p/core_gen/c_marshal.py @@ -78,7 +78,7 @@ class OffsetExpr: if dsttyp: if not oneline: oneline.append("0") - ret += f"{'\t'*indent_depth}{dsttyp} {dstvar} = {' + '.join(oneline)};\n" + ret += f"{'\t'*indent_depth}{dsttyp} {dstvar} = LM_SAFEDOWNCAST({dsttyp}, {' + '.join(oneline)});\n" elif oneline: ret += f"{'\t'*indent_depth}{dstvar} += {' + '.join(oneline)};\n" ret += multiline @@ -350,6 +350,8 @@ def gen_c_marshal(versions: set[str], typs: list[idl.UserType]) -> str: return f"offsetof{''.join('_'+m.membname for m in path.elems[:-1])}_{sym}" val = c9util.idl_expr(child.val, lookup_sym) + if child.typ.static_size < 32: + val = f"LM_SAFEDOWNCAST(uint{child.typ.static_size*8}_t, {val})" else: val = path.c_str("val->") if isinstance(child.typ, idl.Bitfield): |