diff options
Diffstat (limited to 'lib9p/9p.gen')
-rwxr-xr-x | lib9p/9p.gen | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib9p/9p.gen b/lib9p/9p.gen index 6f2ad2c..cdec067 100755 --- a/lib9p/9p.gen +++ b/lib9p/9p.gen @@ -433,7 +433,10 @@ enum {idprefix}version {{ for member in struct.members: if struct.name == "stat" and member.name == "stat_size": # SPECIAL continue - ret += f"\t{c_typename(idprefix, member.typ).ljust(typewidth)} {'*' if member.cnt else ' '}{member.name};" + ctype = c_typename(idprefix, member.typ) + if (struct.name in ["d", "s"]) and member.cnt: # SPECIAL + ctype = "char" + ret += f"\t{ctype.ljust(typewidth)} {'*' if member.cnt else ' '}{member.name};" if (not all_the_same) and (comment := c_vercomment(member.ver)): ret += (" " * (namewidth - len(member.name))) + " " + comment ret += "\n" @@ -689,8 +692,8 @@ static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx, prev_size = member.static_size if typ.name == "stat": # SPECIAL assert typ.members[0].static_size - ret += f"\n{prefix1}((uint32_t)decode_u{typ.members[0].static_size*8}le(&ctx->net_bytes[size_offset]) != ctx->net_offset - size_offset)" - ret += f'\n{prefix2}\t? lib9p_error(ctx->ctx, LINUX_EBADMSG, "stat size does not match stat contents")"' + ret += f"\n{prefix1}((uint32_t)decode_u{typ.members[0].static_size*8}le(&ctx->net_bytes[size_offset]) != ctx->net_offset - size_offset" + ret += f'\n{prefix2}\t? lib9p_error(ctx->ctx, LINUX_EBADMSG, "stat size does not match stat contents")' ret += f"\n{prefix2}\t: false)" ret += ";\n" ret += "}\n" @@ -738,7 +741,7 @@ static ALWAYS_INLINE void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) struct_versions = typ.members[0].ver for member in typ.members: if typ.name == "stat" and member.name == "stat_size": # SPECIAL - ret += f"\tsize->net_offset += {member.static_size};\n" + ret += f"\tctx->net_offset += {member.static_size};\n" continue ret += "\t" prefix = "\t" @@ -835,9 +838,10 @@ static ALWAYS_INLINE bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { for member in typ.members: if typ.name == "stat" and member.name == "stat_size": # SPECIAL: assert member.static_size - ret += f"\n{prefix }((ctx->net_offset + {member.static_size} > ctx->ctx->max_msg_size)" + ret += f"\n{prefix }(ctx->net_offset + {member.static_size} > ctx->ctx->max_msg_size" ret += f"\n{prefix2}\t? _marshal_too_large(ctx)" ret += f"\n{prefix2}\t: ({{ ctx->net_offset += {member.static_size}; false; }}))" + prefix = prefix1 continue ret += f"\n{prefix}" if member.ver != struct_versions: |