summaryrefslogtreecommitdiff
path: root/lib9p/core_gen
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/core_gen')
-rw-r--r--lib9p/core_gen/c_marshal.py4
-rw-r--r--lib9p/core_gen/h.py4
2 files changed, 5 insertions, 3 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):
diff --git a/lib9p/core_gen/h.py b/lib9p/core_gen/h.py
index 61775c1..378fc06 100644
--- a/lib9p/core_gen/h.py
+++ b/lib9p/core_gen/h.py
@@ -354,14 +354,14 @@ enum {c9util.ident('version')} {{
ret += "\n"
ret += f"struct {c9util.ident('Tmsg_send_buf')} {{\n"
- ret += "\tsize_t iov_cnt;\n"
+ ret += "\tint iov_cnt;\n"
ret += f"\tstruct iovec iov[{c9util.IDENT('TMSG_MAX_IOV')}];\n"
ret += f"\tuint8_t copied[{c9util.IDENT('TMSG_MAX_COPY')}];\n"
ret += "};\n"
ret += "\n"
ret += f"struct {c9util.ident('Rmsg_send_buf')} {{\n"
- ret += "\tsize_t iov_cnt;\n"
+ ret += "\tint iov_cnt;\n"
ret += f"\tstruct iovec iov[{c9util.IDENT('RMSG_MAX_IOV')}];\n"
ret += f"\tuint8_t copied[{c9util.IDENT('RMSG_MAX_COPY')}];\n"
ret += "};\n"