diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-14 16:37:27 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-15 14:56:35 -0600 |
commit | 9c0338b1b4495457659157e1e9f47d422dcefc2e (patch) | |
tree | 9102ac3a979f082e1c39f9d4223df5f98a7be0c2 /lib9p/core_generated.c | |
parent | 67cec6d2770aa14a13c89247612f16c628ebd54c (diff) |
lib9p: Remove uses of printf
Diffstat (limited to 'lib9p/core_generated.c')
-rw-r--r-- | lib9p/core_generated.c | 5047 |
1 files changed, 2340 insertions, 2707 deletions
diff --git a/lib9p/core_generated.c b/lib9p/core_generated.c index 2532d12..81ace7d 100644 --- a/lib9p/core_generated.c +++ b/lib9p/core_generated.c @@ -12,132 +12,6 @@ #include "core_tables.h" #include "core_utf8.h" -/* libmisc/obj.h vtables ******************************************************/ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_tag_t, lib9p_tag, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_fid_t, lib9p_fid, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_s, lib9p_s, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_dm_t, lib9p_dm, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_qt_t, lib9p_qt, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_qid, lib9p_qid, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_stat, lib9p_stat, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_o_t, lib9p_o, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tversion, lib9p_msg_Tversion, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rversion, lib9p_msg_Rversion, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tauth, lib9p_msg_Tauth, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rauth, lib9p_msg_Rauth, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tattach, lib9p_msg_Tattach, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rerror, lib9p_msg_Rerror, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tflush, lib9p_msg_Tflush, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rflush, lib9p_msg_Rflush, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Twalk, lib9p_msg_Twalk, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rwalk, lib9p_msg_Rwalk, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Topen, lib9p_msg_Topen, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Ropen, lib9p_msg_Ropen, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tcreate, lib9p_msg_Tcreate, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rcreate, lib9p_msg_Rcreate, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tread, lib9p_msg_Tread, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rread, lib9p_msg_Rread, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Twrite, lib9p_msg_Twrite, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rwrite, lib9p_msg_Rwrite, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tclunk, lib9p_msg_Tclunk, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rclunk, lib9p_msg_Rclunk, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tremove, lib9p_msg_Tremove, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rremove, lib9p_msg_Rremove, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tstat, lib9p_msg_Tstat, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rstat, lib9p_msg_Rstat, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Twstat, lib9p_msg_Twstat, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rwstat, lib9p_msg_Rwstat, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_p9p -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Topenfd, lib9p_msg_Topenfd, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Ropenfd, lib9p_msg_Ropenfd, static); -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_nuid_t, lib9p_nuid, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_errno_t, lib9p_errno, static); -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_L -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_super_magic_t, lib9p_super_magic, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_lo_t, lib9p_lo, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_dt_t, lib9p_dt, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_mode_t, lib9p_mode, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_b4_t, lib9p_b4, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_getattr_t, lib9p_getattr, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_setattr_t, lib9p_setattr, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_lock_type_t, lib9p_lock_type, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_lock_flags_t, lib9p_lock_flags, static); -LO_IMPLEMENTATION_C(fmt_formatter, lib9p_lock_status_t, lib9p_lock_status, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlerror, lib9p_msg_Rlerror, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tstatfs, lib9p_msg_Tstatfs, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rstatfs, lib9p_msg_Rstatfs, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tlopen, lib9p_msg_Tlopen, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlopen, lib9p_msg_Rlopen, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tlcreate, lib9p_msg_Tlcreate, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlcreate, lib9p_msg_Rlcreate, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tsymlink, lib9p_msg_Tsymlink, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rsymlink, lib9p_msg_Rsymlink, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tmknod, lib9p_msg_Tmknod, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rmknod, lib9p_msg_Rmknod, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Trename, lib9p_msg_Trename, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rrename, lib9p_msg_Rrename, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Treadlink, lib9p_msg_Treadlink, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rreadlink, lib9p_msg_Rreadlink, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tgetattr, lib9p_msg_Tgetattr, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rgetattr, lib9p_msg_Rgetattr, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tsetattr, lib9p_msg_Tsetattr, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rsetattr, lib9p_msg_Rsetattr, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Txattrwalk, lib9p_msg_Txattrwalk, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rxattrwalk, lib9p_msg_Rxattrwalk, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Txattrcreate, lib9p_msg_Txattrcreate, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rxattrcreate, lib9p_msg_Rxattrcreate, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Treaddir, lib9p_msg_Treaddir, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rreaddir, lib9p_msg_Rreaddir, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tfsync, lib9p_msg_Tfsync, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rfsync, lib9p_msg_Rfsync, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tlock, lib9p_msg_Tlock, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlock, lib9p_msg_Rlock, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tgetlock, lib9p_msg_Tgetlock, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rgetlock, lib9p_msg_Rgetlock, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tlink, lib9p_msg_Tlink, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlink, lib9p_msg_Rlink, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tmkdir, lib9p_msg_Tmkdir, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rmkdir, lib9p_msg_Rmkdir, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Trenameat, lib9p_msg_Trenameat, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rrenameat, lib9p_msg_Rrenameat, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tunlinkat, lib9p_msg_Tunlinkat, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Runlinkat, lib9p_msg_Runlinkat, static); -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tsession, lib9p_msg_Tsession, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rsession, lib9p_msg_Rsession, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tsread, lib9p_msg_Tsread, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rsread, lib9p_msg_Rsread, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tswrite, lib9p_msg_Tswrite, static); -LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite, static); -#endif /* CONFIG_9P_ENABLE_9P2000_e */ - /* utilities ******************************************************************/ #if CONFIG_9P_ENABLE_9P2000 #define _is_ver_9P2000(v) (v == LIB9P_VER_9P2000) @@ -355,7 +229,7 @@ static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = { * that. */ \ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content"); \ if (net_offset > net_size) \ - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content (%"PRIu32" > %"PRIu32") @ %d", net_offset, net_size, __LINE__); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content (", net_offset, " > ", net_size, ")"); #define VALIDATE_NET_UTF8(n) \ { \ size_t len = n; \ @@ -387,8 +261,8 @@ static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t * uint32_t offsetof_qid_type = net_offset + 8; VALIDATE_NET_BYTES(21); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_mode = net_offset + 0; VALIDATE_NET_BYTES(22); VALIDATE_NET_UTF8(LAST_U16LE()); @@ -406,12 +280,11 @@ static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t * } #endif /* CONFIG_9P_ENABLE_9P2000_u */ uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof__stat_size) != (uint32_t)(offsetof_end - offsetof_fstype)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "stat->_stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof__stat_size), (uint32_t)(offsetof_end - offsetof_fstype)); + if (GET_U32LE(offsetof__stat_size) != offsetof_end - offsetof_fstype) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "stat->_stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof__stat_size)), " != correct:", (base10, offsetof_end - offsetof_fstype)); if (GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: ", + (base16_u32_, GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version])); if (ret_net_size) *ret_net_size = net_offset; return (ssize_t)host_size; @@ -427,12 +300,10 @@ static ssize_t validate_Tversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_BYTES(13); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(100)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(100)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 100) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 100)); return (ssize_t)host_size; } @@ -444,12 +315,10 @@ static ssize_t validate_Rversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_BYTES(13); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(101)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(101)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 101) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 101)); return (ssize_t)host_size; } @@ -470,12 +339,10 @@ static ssize_t validate_Tauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(102)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(102)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 102) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 102)); return (ssize_t)host_size; } @@ -487,15 +354,13 @@ static ssize_t validate_Rauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_aqid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(103)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(103)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 103) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 103)); return (ssize_t)host_size; } @@ -514,12 +379,10 @@ static ssize_t validate_Tattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(104)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(104)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 104) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 104)); return (ssize_t)host_size; } @@ -531,15 +394,13 @@ static ssize_t validate_Rattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(105)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(105)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 105) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 105)); return (ssize_t)host_size; } @@ -558,12 +419,10 @@ static ssize_t validate_Rerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t } #endif /* CONFIG_9P_ENABLE_9P2000_u */ uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(107)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(107)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 107) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 107)); return (ssize_t)host_size; } @@ -576,12 +435,10 @@ static ssize_t validate_Tflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 9; VALIDATE_NET_BYTES(9); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(108)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(108)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 108) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 108)); return (ssize_t)host_size; } @@ -592,12 +449,10 @@ static ssize_t validate_Rflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(109)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(109)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 109) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 109)); return (ssize_t)host_size; } @@ -614,15 +469,12 @@ static ssize_t validate_Twalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_UTF8(LAST_U16LE()); } uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(110)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(110)); - if ((uint16_t)GET_U16LE(offsetof_nwname) > (uint16_t)(16)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->nwname value is too large: %"PRIu16" > %"PRIu16, - (uint16_t)GET_U16LE(offsetof_nwname), (uint16_t)(16)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 110) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 110)); + if (GET_U16LE(offsetof_nwname) > 16) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->nwname value is too large: ", (base10, GET_U16LE(offsetof_nwname)), " > ", (base10, 16)); return (ssize_t)host_size; } @@ -638,19 +490,16 @@ static ssize_t validate_Rwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_wqid_type = net_offset + 0; VALIDATE_NET_BYTES(13); if (GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version])); } uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(111)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(111)); - if ((uint16_t)GET_U16LE(offsetof_nwqid) > (uint16_t)(16)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->nwqid value is too large: %"PRIu16" > %"PRIu16, - (uint16_t)GET_U16LE(offsetof_nwqid), (uint16_t)(16)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 111) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 111)); + if (GET_U16LE(offsetof_nwqid) > 16) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->nwqid value is too large: ", (base10, GET_U16LE(offsetof_nwqid)), " > ", (base10, 16)); return (ssize_t)host_size; } @@ -664,15 +513,13 @@ static ssize_t validate_Topen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_mode = net_offset + 11; uint32_t offsetof_end = net_offset + 12; VALIDATE_NET_BYTES(12); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(112)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(112)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 112) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 112)); if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, - GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: ", + (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])); return (ssize_t)host_size; } @@ -684,16 +531,14 @@ static ssize_t validate_Ropen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(113)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(113)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 113) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 113)); return (ssize_t)host_size; } @@ -708,18 +553,16 @@ static ssize_t validate_Tcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_mode = net_offset + 4; uint32_t offsetof_end = net_offset + 5; VALIDATE_NET_BYTES(5); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(114)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(114)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 114) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 114)); if (GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: ", + (base16_u32_, GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version])); if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, - GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: ", + (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])); return (ssize_t)host_size; } @@ -731,16 +574,14 @@ static ssize_t validate_Rcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(115)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(115)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 115) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 115)); return (ssize_t)host_size; } @@ -755,18 +596,14 @@ static ssize_t validate_Tread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_count = net_offset + 19; uint32_t offsetof_end = net_offset + 23; VALIDATE_NET_BYTES(23); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(116)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(116)); - if ((uint64_t)GET_U64LE(offsetof_offset) > (uint64_t)(INT64_MAX)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->offset value is too large: %"PRIu64" > %"PRIu64, - (uint64_t)GET_U64LE(offsetof_offset), (uint64_t)(INT64_MAX)); - if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->count value is too large: %"PRIu32" > %"PRIu32, - (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 116) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 116)); + if (GET_U64LE(offsetof_offset) > INT64_MAX) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->offset value is too large: ", (base10, GET_U64LE(offsetof_offset)), " > ", (base10, INT64_MAX)); + if (GET_U32LE(offsetof_count) > INT32_MAX) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX)); return (ssize_t)host_size; } @@ -779,15 +616,12 @@ static ssize_t validate_Rread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_BYTES(11); VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(117)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(117)); - if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->count value is too large: %"PRIu32" > %"PRIu32, - (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 117) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 117)); + if (GET_U32LE(offsetof_count) > INT32_MAX) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX)); return (ssize_t)host_size; } @@ -801,18 +635,14 @@ static ssize_t validate_Twrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_BYTES(23); VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(118)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(118)); - if ((uint64_t)GET_U64LE(offsetof_offset) > (uint64_t)(INT64_MAX)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->offset value is too large: %"PRIu64" > %"PRIu64, - (uint64_t)GET_U64LE(offsetof_offset), (uint64_t)(INT64_MAX)); - if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->count value is too large: %"PRIu32" > %"PRIu32, - (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 118) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 118)); + if (GET_U64LE(offsetof_offset) > INT64_MAX) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->offset value is too large: ", (base10, GET_U64LE(offsetof_offset)), " > ", (base10, INT64_MAX)); + if (GET_U32LE(offsetof_count) > INT32_MAX) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX)); return (ssize_t)host_size; } @@ -824,15 +654,12 @@ static ssize_t validate_Rwrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_count = net_offset + 7; uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(119)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(119)); - if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->count value is too large: %"PRIu32" > %"PRIu32, - (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 119) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 119)); + if (GET_U32LE(offsetof_count) > INT32_MAX) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX)); return (ssize_t)host_size; } @@ -843,12 +670,10 @@ static ssize_t validate_Tclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(120)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(120)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 120) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 120)); return (ssize_t)host_size; } @@ -859,12 +684,10 @@ static ssize_t validate_Rclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(121)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(121)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 121) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 121)); return (ssize_t)host_size; } @@ -875,12 +698,10 @@ static ssize_t validate_Tremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(122)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(122)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 122) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 122)); return (ssize_t)host_size; } @@ -891,12 +712,10 @@ static ssize_t validate_Rremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(123)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(123)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 123) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 123)); return (ssize_t)host_size; } @@ -909,12 +728,10 @@ static ssize_t validate_Tstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(124)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(124)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 124) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 124)); return (ssize_t)host_size; } @@ -930,8 +747,8 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_stat_qid_type = net_offset + 17; VALIDATE_NET_BYTES(30); if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_stat_mode = net_offset + 0; VALIDATE_NET_BYTES(22); VALIDATE_NET_UTF8(LAST_U16LE()); @@ -949,22 +766,18 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t } #endif /* CONFIG_9P_ENABLE_9P2000_u */ uint32_t offsetof_stat_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_stat__stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_fstype)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->stat._stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_stat__stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_fstype)); + if (GET_U32LE(offsetof_stat__stat_size) != offsetof_stat_end - offsetof_stat_fstype) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->stat._stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof_stat__stat_size)), " != correct:", (base10, offsetof_stat_end - offsetof_stat_fstype)); if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: ", + (base16_u32_, GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(125)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(125)); - if ((uint32_t)GET_U32LE(offsetof_nstat) != (uint32_t)(offsetof_end - offsetof_stat)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_nstat), (uint32_t)(offsetof_end - offsetof_stat)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 125) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 125)); + if (GET_U32LE(offsetof_nstat) != offsetof_end - offsetof_stat) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->nstat value is wrong: actual:", (base10, GET_U32LE(offsetof_nstat)), " != correct:", (base10, offsetof_end - offsetof_stat)); return (ssize_t)host_size; } @@ -980,8 +793,8 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_stat_qid_type = net_offset + 21; VALIDATE_NET_BYTES(34); if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_stat_mode = net_offset + 0; VALIDATE_NET_BYTES(22); VALIDATE_NET_UTF8(LAST_U16LE()); @@ -999,22 +812,18 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t } #endif /* CONFIG_9P_ENABLE_9P2000_u */ uint32_t offsetof_stat_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_stat__stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_fstype)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->stat._stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_stat__stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_fstype)); + if (GET_U32LE(offsetof_stat__stat_size) != offsetof_stat_end - offsetof_stat_fstype) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->stat._stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof_stat__stat_size)), " != correct:", (base10, offsetof_stat_end - offsetof_stat_fstype)); if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: ", + (base16_u32_, GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(126)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(126)); - if ((uint32_t)GET_U32LE(offsetof_nstat) != (uint32_t)(offsetof_end - offsetof_stat)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_nstat), (uint32_t)(offsetof_end - offsetof_stat)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 126) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 126)); + if (GET_U32LE(offsetof_nstat) != offsetof_end - offsetof_stat) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->nstat value is wrong: actual:", (base10, GET_U32LE(offsetof_nstat)), " != correct:", (base10, offsetof_end - offsetof_stat)); return (ssize_t)host_size; } @@ -1025,12 +834,10 @@ static ssize_t validate_Rwstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(127)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(127)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 127) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 127)); return (ssize_t)host_size; } @@ -1044,15 +851,13 @@ static ssize_t validate_Topenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_mode = net_offset + 11; uint32_t offsetof_end = net_offset + 12; VALIDATE_NET_BYTES(12); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(98)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(98)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 98) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 98)); if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, - GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: ", + (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])); return (ssize_t)host_size; } @@ -1064,16 +869,14 @@ static ssize_t validate_Ropenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 8; VALIDATE_NET_BYTES(8); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(99)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(99)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 99) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 99)); return (ssize_t)host_size; } @@ -1086,12 +889,10 @@ static ssize_t validate_Rlerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(7)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(7)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 7) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 7)); return (ssize_t)host_size; } @@ -1102,12 +903,10 @@ static ssize_t validate_Tstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(8)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(8)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 8) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 8)); return (ssize_t)host_size; } @@ -1118,12 +917,10 @@ static ssize_t validate_Rstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 67; VALIDATE_NET_BYTES(67); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(9)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(9)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 9) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 9)); return (ssize_t)host_size; } @@ -1135,15 +932,13 @@ static ssize_t validate_Tlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_flags = net_offset + 11; uint32_t offsetof_end = net_offset + 15; VALIDATE_NET_BYTES(15); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(12)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(12)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 12) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 12)); if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32, - GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: ", + (base16_u32_, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version])); return (ssize_t)host_size; } @@ -1155,16 +950,14 @@ static ssize_t validate_Rlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(13)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(13)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 13) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 13)); return (ssize_t)host_size; } @@ -1179,18 +972,16 @@ static ssize_t validate_Tlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_mode = net_offset + 4; uint32_t offsetof_end = net_offset + 12; VALIDATE_NET_BYTES(12); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(14)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(14)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 14) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 14)); if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32, - GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: ", + (base16_u32_, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version])); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ", + (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])); return (ssize_t)host_size; } @@ -1202,16 +993,14 @@ static ssize_t validate_Rlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(15)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(15)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 15) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 15)); return (ssize_t)host_size; } @@ -1226,12 +1015,10 @@ static ssize_t validate_Tsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(16)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(16)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 16) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 16)); return (ssize_t)host_size; } @@ -1243,15 +1030,13 @@ static ssize_t validate_Rsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(17)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(17)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 17) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 17)); return (ssize_t)host_size; } @@ -1265,15 +1050,13 @@ static ssize_t validate_Tmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_mode = net_offset + 0; uint32_t offsetof_end = net_offset + 16; VALIDATE_NET_BYTES(16); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(18)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(18)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 18) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 18)); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ", + (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])); return (ssize_t)host_size; } @@ -1285,15 +1068,13 @@ static ssize_t validate_Rmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(19)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(19)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 19) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 19)); return (ssize_t)host_size; } @@ -1305,12 +1086,10 @@ static ssize_t validate_Trename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ VALIDATE_NET_BYTES(17); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(20)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(20)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 20) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 20)); return (ssize_t)host_size; } @@ -1321,12 +1100,10 @@ static ssize_t validate_Rrename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(21)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(21)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 21) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 21)); return (ssize_t)host_size; } @@ -1337,12 +1114,10 @@ static ssize_t validate_Treadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(22)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(22)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 22) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 22)); return (ssize_t)host_size; } @@ -1354,12 +1129,10 @@ static ssize_t validate_Rreadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint VALIDATE_NET_BYTES(9); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(23)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(23)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 23) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 23)); return (ssize_t)host_size; } @@ -1371,15 +1144,13 @@ static ssize_t validate_Tgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_request_mask = net_offset + 11; uint32_t offsetof_end = net_offset + 19; VALIDATE_NET_BYTES(19); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(24)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(24)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 24) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 24)); if (GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64, - GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: ", + (base16_u64_, GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version])); return (ssize_t)host_size; } @@ -1392,23 +1163,21 @@ static ssize_t validate_Rgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_qid_type = net_offset + 15; VALIDATE_NET_BYTES(28); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_mode = net_offset + 0; uint32_t offsetof_end = net_offset + 132; VALIDATE_NET_BYTES(132); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(25)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(25)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 25) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 25)); if (GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64, - GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: ", + (base16_u64_, GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version])); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ", + (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])); return (ssize_t)host_size; } @@ -1421,18 +1190,16 @@ static ssize_t validate_Tsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_mode = net_offset + 15; uint32_t offsetof_end = net_offset + 67; VALIDATE_NET_BYTES(67); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(26)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(26)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 26) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 26)); if (GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in setattr bitfield: %#08"PRIx32, - GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in setattr bitfield: ", + (base16_u32_, GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version])); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ", + (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])); return (ssize_t)host_size; } @@ -1443,12 +1210,10 @@ static ssize_t validate_Rsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(27)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(27)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 27) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 27)); return (ssize_t)host_size; } @@ -1460,12 +1225,10 @@ static ssize_t validate_Txattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uin VALIDATE_NET_BYTES(17); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(30)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(30)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 30) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 30)); return (ssize_t)host_size; } @@ -1476,12 +1239,10 @@ static ssize_t validate_Rxattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uin uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 15; VALIDATE_NET_BYTES(15); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(31)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(31)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 31) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 31)); return (ssize_t)host_size; } @@ -1494,12 +1255,10 @@ static ssize_t validate_Txattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, u VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 12; VALIDATE_NET_BYTES(12); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(32)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(32)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 32) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 32)); return (ssize_t)host_size; } @@ -1510,12 +1269,10 @@ static ssize_t validate_Rxattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, u uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(33)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(33)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 33) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 33)); return (ssize_t)host_size; } @@ -1526,12 +1283,10 @@ static ssize_t validate_Treaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 23; VALIDATE_NET_BYTES(23); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(40)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(40)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 40) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 40)); return (ssize_t)host_size; } @@ -1543,12 +1298,10 @@ static ssize_t validate_Rreaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_BYTES(11); VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(41)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(41)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 41) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 41)); return (ssize_t)host_size; } @@ -1559,12 +1312,10 @@ static ssize_t validate_Tfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 15; VALIDATE_NET_BYTES(15); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(50)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(50)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 50) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 50)); return (ssize_t)host_size; } @@ -1575,12 +1326,10 @@ static ssize_t validate_Rfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(51)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(51)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 51) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 51)); return (ssize_t)host_size; } @@ -1593,15 +1342,13 @@ static ssize_t validate_Tlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_BYTES(38); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(52)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(52)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 52) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 52)); if (GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lock_flags bitfield: %#08"PRIx32, - GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lock_flags bitfield: ", + (base16_u32_, GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version])); return (ssize_t)host_size; } @@ -1612,12 +1359,10 @@ static ssize_t validate_Rlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 8; VALIDATE_NET_BYTES(8); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(53)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(53)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 53) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 53)); return (ssize_t)host_size; } @@ -1629,12 +1374,10 @@ static ssize_t validate_Tgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_BYTES(34); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(54)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(54)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 54) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 54)); return (ssize_t)host_size; } @@ -1646,12 +1389,10 @@ static ssize_t validate_Rgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_BYTES(30); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(55)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(55)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 55) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 55)); return (ssize_t)host_size; } @@ -1663,12 +1404,10 @@ static ssize_t validate_Tlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_BYTES(17); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(70)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(70)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 70) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 70)); return (ssize_t)host_size; } @@ -1679,12 +1418,10 @@ static ssize_t validate_Rlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(71)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(71)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 71) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 71)); return (ssize_t)host_size; } @@ -1698,15 +1435,13 @@ static ssize_t validate_Tmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_mode = net_offset + 0; uint32_t offsetof_end = net_offset + 8; VALIDATE_NET_BYTES(8); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(72)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(72)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 72) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 72)); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ", + (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])); return (ssize_t)host_size; } @@ -1718,15 +1453,13 @@ static ssize_t validate_Rmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ", + (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(73)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(73)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 73) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 73)); return (ssize_t)host_size; } @@ -1740,12 +1473,10 @@ static ssize_t validate_Trenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint VALIDATE_NET_BYTES(6); VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(74)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(74)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 74) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 74)); return (ssize_t)host_size; } @@ -1756,12 +1487,10 @@ static ssize_t validate_Rrenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(75)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(75)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 75) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 75)); return (ssize_t)host_size; } @@ -1774,12 +1503,10 @@ static ssize_t validate_Tunlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(76)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(76)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 76) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 76)); return (ssize_t)host_size; } @@ -1790,12 +1517,10 @@ static ssize_t validate_Runlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(77)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(77)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 77) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 77)); return (ssize_t)host_size; } @@ -1808,12 +1533,10 @@ static ssize_t validate_Tsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 15; VALIDATE_NET_BYTES(15); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(150)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(150)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 150) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 150)); return (ssize_t)host_size; } @@ -1824,12 +1547,10 @@ static ssize_t validate_Rsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(151)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(151)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 151) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 151)); return (ssize_t)host_size; } @@ -1845,12 +1566,10 @@ static ssize_t validate_Tsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_UTF8(LAST_U16LE()); } uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(152)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(152)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 152) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 152)); return (ssize_t)host_size; } @@ -1862,12 +1581,10 @@ static ssize_t validate_Rsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_BYTES(11); VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(153)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(153)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 153) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 153)); return (ssize_t)host_size; } @@ -1885,12 +1602,10 @@ static ssize_t validate_Tswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ VALIDATE_NET_BYTES(4); VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(154)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(154)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 154) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 154)); return (ssize_t)host_size; } @@ -1901,12 +1616,10 @@ static ssize_t validate_Rswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_typ = net_offset + 4; uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(155)) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(155)); + if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)); + if (GET_U8LE(offsetof_typ) != 155) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 155)); return (ssize_t)host_size; } #endif /* CONFIG_9P_ENABLE_9P2000_e */ @@ -3057,10 +2770,9 @@ static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _ static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *val, struct _marshal_ret *ret) { uint32_t needed_size = 13 + val->version.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tversion", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tversion message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3077,10 +2789,9 @@ static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *v static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *val, struct _marshal_ret *ret) { uint32_t needed_size = 13 + val->version.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rversion", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rversion message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3104,10 +2815,9 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tauth", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tauth message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3131,10 +2841,9 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st static bool marshal_Rauth(struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *val, struct _marshal_ret *ret) { uint32_t needed_size = 20; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rauth", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rauth message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3156,10 +2865,9 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tattach", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tattach message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3184,10 +2892,9 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val, struct _marshal_ret *ret) { uint32_t needed_size = 20; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rattach", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rattach message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3211,10 +2918,9 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, } #endif /* CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rerror", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rerror message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3237,10 +2943,9 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, struct _marshal_ret *ret) { uint32_t needed_size = 9; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tflush", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tflush message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3255,10 +2960,9 @@ static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, static bool marshal_Rflush(struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rflush", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rflush message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3275,10 +2979,9 @@ static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, st needed_size += 2 + val->wname[i].len; } if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Twalk", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Twalk message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3299,10 +3002,9 @@ static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, st static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, struct _marshal_ret *ret) { uint32_t needed_size = 9 + (val->nwqid)*13; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rwalk", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rwalk message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3324,10 +3026,9 @@ static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, st static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, struct _marshal_ret *ret) { uint32_t needed_size = 12; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Topen", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Topen message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3343,10 +3044,9 @@ static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, st static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, struct _marshal_ret *ret) { uint32_t needed_size = 24; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Ropen", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Ropen message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3364,10 +3064,9 @@ static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, st static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val, struct _marshal_ret *ret) { uint32_t needed_size = 18 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tcreate", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tcreate message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3386,10 +3085,9 @@ static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val, struct _marshal_ret *ret) { uint32_t needed_size = 24; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rcreate", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rcreate message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3409,10 +3107,9 @@ static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, struct _marshal_ret *ret) { uint32_t needed_size = 23; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tread", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tread message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3429,10 +3126,9 @@ static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, st static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, struct _marshal_ret *ret) { uint32_t needed_size = 11 + val->count; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rread", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rread message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3448,10 +3144,9 @@ static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, st static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val, struct _marshal_ret *ret) { uint32_t needed_size = 23 + val->count; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Twrite", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Twrite message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3469,10 +3164,9 @@ static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val, static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val, struct _marshal_ret *ret) { uint32_t needed_size = 11; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rwrite", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rwrite message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3487,10 +3181,9 @@ static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val, static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val, struct _marshal_ret *ret) { uint32_t needed_size = 11; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tclunk", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tclunk message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3505,10 +3198,9 @@ static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val, static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rclunk", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rclunk message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3522,10 +3214,9 @@ static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val, static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val, struct _marshal_ret *ret) { uint32_t needed_size = 11; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tremove", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tremove message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3540,10 +3231,9 @@ static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rremove", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rremove message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3559,10 +3249,9 @@ static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val static bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, struct _marshal_ret *ret) { uint32_t needed_size = 11; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tstat", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tstat message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3582,10 +3271,9 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st } #endif /* CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rstat", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rstat message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3640,10 +3328,9 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, } #endif /* CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Twstat", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Twstat message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3694,10 +3381,9 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rwstat", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rwstat message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3713,10 +3399,9 @@ static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val, static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val, struct _marshal_ret *ret) { uint32_t needed_size = 12; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Topenfd", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Topenfd message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3732,10 +3417,9 @@ static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val, struct _marshal_ret *ret) { uint32_t needed_size = 28; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Ropenfd", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Ropenfd message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3756,10 +3440,9 @@ static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val, struct _marshal_ret *ret) { uint32_t needed_size = 11; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rlerror", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlerror message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3774,10 +3457,9 @@ static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val, struct _marshal_ret *ret) { uint32_t needed_size = 11; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tstatfs", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tstatfs message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3792,10 +3474,9 @@ static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val, struct _marshal_ret *ret) { uint32_t needed_size = 67; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rstatfs", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rstatfs message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3818,10 +3499,9 @@ static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val, struct _marshal_ret *ret) { uint32_t needed_size = 15; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tlopen", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tlopen message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3837,10 +3517,9 @@ static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val, static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val, struct _marshal_ret *ret) { uint32_t needed_size = 24; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rlopen", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlopen message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3858,10 +3537,9 @@ static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val, static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *val, struct _marshal_ret *ret) { uint32_t needed_size = 25 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tlcreate", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tlcreate message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3881,10 +3559,9 @@ static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *v static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *val, struct _marshal_ret *ret) { uint32_t needed_size = 24; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rlcreate", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlcreate message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3902,10 +3579,9 @@ static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *v static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *val, struct _marshal_ret *ret) { uint32_t needed_size = 19 + val->name.len + val->symtgt.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tsymlink", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tsymlink message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3925,10 +3601,9 @@ static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *v static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *val, struct _marshal_ret *ret) { uint32_t needed_size = 20; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rsymlink", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rsymlink message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3945,10 +3620,9 @@ static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *v static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val, struct _marshal_ret *ret) { uint32_t needed_size = 29 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tmknod", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tmknod message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3969,10 +3643,9 @@ static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val, static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val, struct _marshal_ret *ret) { uint32_t needed_size = 20; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rmknod", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rmknod message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -3989,10 +3662,9 @@ static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val, static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val, struct _marshal_ret *ret) { uint32_t needed_size = 17 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Trename", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Trename message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4010,10 +3682,9 @@ static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val static bool marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rrename", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rrename message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4027,10 +3698,9 @@ static bool marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink *val, struct _marshal_ret *ret) { uint32_t needed_size = 11; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Treadlink", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Treadlink message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4045,10 +3715,9 @@ static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink *val, struct _marshal_ret *ret) { uint32_t needed_size = 9 + val->target.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rreadlink", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rreadlink message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4064,10 +3733,9 @@ static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *val, struct _marshal_ret *ret) { uint32_t needed_size = 19; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tgetattr", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tgetattr message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4083,10 +3751,9 @@ static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *v static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *val, struct _marshal_ret *ret) { uint32_t needed_size = 160; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rgetattr", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rgetattr message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4122,10 +3789,9 @@ static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *v static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *val, struct _marshal_ret *ret) { uint32_t needed_size = 67; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tsetattr", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tsetattr message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4149,10 +3815,9 @@ static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *v static bool marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rsetattr", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rsetattr message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4166,10 +3831,9 @@ static bool marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *v static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwalk *val, struct _marshal_ret *ret) { uint32_t needed_size = 17 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Txattrwalk", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Txattrwalk message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4187,10 +3851,9 @@ static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwal static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwalk *val, struct _marshal_ret *ret) { uint32_t needed_size = 15; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rxattrwalk", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rxattrwalk message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4205,10 +3868,9 @@ static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwal static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrcreate *val, struct _marshal_ret *ret) { uint32_t needed_size = 25 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Txattrcreate", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Txattrcreate message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4227,10 +3889,9 @@ static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrc static bool marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrcreate *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rxattrcreate", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rxattrcreate message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4244,10 +3905,9 @@ static bool marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrc static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *val, struct _marshal_ret *ret) { uint32_t needed_size = 23; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Treaddir", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Treaddir message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4264,10 +3924,9 @@ static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *v static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *val, struct _marshal_ret *ret) { uint64_t needed_size = 11 + val->count; if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")", - "Rreaddir", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rreaddir message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = (uint32_t)needed_size; @@ -4283,10 +3942,9 @@ static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *v static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val, struct _marshal_ret *ret) { uint32_t needed_size = 15; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tfsync", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tfsync message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4302,10 +3960,9 @@ static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val, static bool marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rfsync", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rfsync message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4319,10 +3976,9 @@ static bool marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val, static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, struct _marshal_ret *ret) { uint32_t needed_size = 38 + val->client_id.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tlock", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tlock message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4344,10 +4000,9 @@ static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, st static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, struct _marshal_ret *ret) { uint32_t needed_size = 8; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rlock", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlock message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4362,10 +4017,9 @@ static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, st static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *val, struct _marshal_ret *ret) { uint32_t needed_size = 34 + val->client_id.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tgetlock", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tgetlock message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4386,10 +4040,9 @@ static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *v static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *val, struct _marshal_ret *ret) { uint32_t needed_size = 30 + val->client_id.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rgetlock", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rgetlock message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4409,10 +4062,9 @@ static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *v static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, struct _marshal_ret *ret) { uint32_t needed_size = 17 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tlink", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tlink message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4430,10 +4082,9 @@ static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, st static bool marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rlink", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlink message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4447,10 +4098,9 @@ static bool marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, st static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val, struct _marshal_ret *ret) { uint32_t needed_size = 21 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tmkdir", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tmkdir message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4469,10 +4119,9 @@ static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val, static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val, struct _marshal_ret *ret) { uint32_t needed_size = 20; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rmkdir", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rmkdir message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4489,10 +4138,9 @@ static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val, static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat *val, struct _marshal_ret *ret) { uint32_t needed_size = 19 + val->oldname.len + val->newname.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Trenameat", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Trenameat message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4512,10 +4160,9 @@ static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat static bool marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rrenameat", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rrenameat message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4529,10 +4176,9 @@ static bool marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat *val, struct _marshal_ret *ret) { uint32_t needed_size = 17 + val->name.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tunlinkat", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tunlinkat message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4550,10 +4196,9 @@ static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Runlinkat", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Runlinkat message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4569,10 +4214,9 @@ static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *val, struct _marshal_ret *ret) { uint32_t needed_size = 15; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Tsession", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tsession message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4587,10 +4231,9 @@ static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *v static bool marshal_Rsession(struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *val, struct _marshal_ret *ret) { uint32_t needed_size = 7; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rsession", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rsession message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4607,10 +4250,9 @@ static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val, needed_size += 2 + val->wname[i].len; } if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")", - "Tsread", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tsread message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = (uint32_t)needed_size; @@ -4630,10 +4272,9 @@ static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val, static bool marshal_Rsread(struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *val, struct _marshal_ret *ret) { uint64_t needed_size = 11 + val->count; if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")", - "Rsread", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rsread message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = (uint32_t)needed_size; @@ -4652,10 +4293,9 @@ static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val needed_size += 2 + val->wname[i].len; } if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")", - "Tswrite", - ctx->version ? "negotiated" : "client", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tswrite message too large to marshal into ", + ctx->version ? "negotiated" : "client", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = (uint32_t)needed_size; @@ -4677,10 +4317,9 @@ static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val, struct _marshal_ret *ret) { uint32_t needed_size = 11; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", - "Rswrite", - ctx->version ? "negotiated" : "server", - needed_size, ctx->max_msg_size); + lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rswrite message too large to marshal into ", + ctx->version ? "negotiated" : "server", " limit", + " (", needed_size, " > ", ctx->max_msg_size, ")"); return true; } uint32_t offsetof_end = needed_size; @@ -4693,3158 +4332,3152 @@ static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val } #endif /* CONFIG_9P_ENABLE_9P2000_e */ -/* *_format *******************************************************************/ +/* fmt_print_* ****************************************************************/ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -static void lib9p_tag_format(lib9p_tag_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_tag(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_tag_t *self) { switch (*self) { case LIB9P_TAG_NOTAG: - fmt_state_puts(state, "NOTAG"); + fmt_print_str(w, "NOTAG"); break; default: - fmt_state_printf(state, "%"PRIu16, *self); + fmt_print_base10(w, *self); } } -static void lib9p_fid_format(lib9p_fid_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_fid(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_fid_t *self) { switch (*self) { case LIB9P_FID_NOFID: - fmt_state_puts(state, "NOFID"); + fmt_print_str(w, "NOFID"); break; default: - fmt_state_printf(state, "%"PRIu32, *self); + fmt_print_base10(w, *self); } } -static void lib9p_s_format(struct lib9p_s *self, struct fmt_state *state) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat" -#pragma GCC diagnostic ignored "-Wformat-extra-args" - fmt_state_printf(state, "%.*q", self->len, self->utf8); -#pragma GCC diagnostic pop -} - #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -static void lib9p_dm_format(lib9p_dm_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_dm(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_dm_t *self) { bool empty = true; - fmt_state_putchar(state, '('); + fmt_print_byte(w, '('); if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<31)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "DIR"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "DIR"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<30)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "APPEND"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "APPEND"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<29)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "EXCL"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "EXCL"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<28)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "_PLAN9_MOUNT"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "_PLAN9_MOUNT"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<27)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "AUTH"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "AUTH"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<26)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "TMP"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "TMP"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<25)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<25"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<25"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<24)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<24"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<24"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<23)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "DEVICE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "DEVICE"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<22)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<22"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<22"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<21)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PIPE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PIPE"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<20)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "SOCKET"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "SOCKET"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<19)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "SETUID"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "SETUID"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<18)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "SETGID"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "SETGID"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<17)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<17"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<17"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<16)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<16"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<16"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<15)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<15"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<15"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<14)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<14"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<14"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<13)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<13"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<13"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<12)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<12"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<12"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<11)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<11"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<11"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<10)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<10"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<10"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<9)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<9"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<9"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<8)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "OWNER_R"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "OWNER_R"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<7)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "OWNER_W"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "OWNER_W"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<6)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "OWNER_X"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "OWNER_X"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<5)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "GROUP_R"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "GROUP_R"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<4)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "GROUP_W"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "GROUP_W"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<3)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "GROUP_X"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "GROUP_X"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<2)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "OTHER_R"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "OTHER_R"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<1)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "OTHER_W"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "OTHER_W"); empty = false; } if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<0)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "OTHER_X"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "OTHER_X"); empty = false; } if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_printf(state, "%#04"PRIo32, *self & 0777); - fmt_state_putchar(state, ')'); + fmt_print_byte(w, '|'); + fmt_print(w, (rjust, 4, '0', (base8, *self & 0777))); + fmt_print_byte(w, ')'); } #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -static void lib9p_qt_format(lib9p_qt_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_qt(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_qt_t *self) { bool empty = true; - fmt_state_putchar(state, '('); + fmt_print_byte(w, '('); if (*self & (UINT8_C(1)<<7)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "DIR"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "DIR"); empty = false; } if (*self & (UINT8_C(1)<<6)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "APPEND"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "APPEND"); empty = false; } if (*self & (UINT8_C(1)<<5)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "EXCL"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "EXCL"); empty = false; } if (*self & (UINT8_C(1)<<4)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "_PLAN9_MOUNT"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "_PLAN9_MOUNT"); empty = false; } if (*self & (UINT8_C(1)<<3)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "AUTH"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "AUTH"); empty = false; } if (*self & (UINT8_C(1)<<2)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "TMP"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "TMP"); empty = false; } if (*self & (UINT8_C(1)<<1)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "SYMLINK"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "SYMLINK"); empty = false; } if (*self & (UINT8_C(1)<<0)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<0"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<0"); empty = false; } if (empty) - fmt_state_putchar(state, '0'); - fmt_state_putchar(state, ')'); -} - -static void lib9p_qid_format(struct lib9p_qid *self, struct fmt_state *state) { - fmt_state_putchar(state, '{'); - fmt_state_puts(state, " type="); - lib9p_qt_format(&self->type, state); - fmt_state_puts(state, " vers="); - fmt_state_printf(state, "%"PRIu32, self->vers); - fmt_state_puts(state, " path="); - fmt_state_printf(state, "%"PRIu64, self->path); - fmt_state_puts(state, " }"); + fmt_print_byte(w, '0'); + fmt_print_byte(w, ')'); } #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void lib9p_stat_format(struct lib9p_stat *self, struct fmt_state *state) { - fmt_state_putchar(state, '{'); - fmt_state_puts(state, " fstype="); - fmt_state_printf(state, "%"PRIu16, self->fstype); - fmt_state_puts(state, " fsdev="); - fmt_state_printf(state, "%"PRIu32, self->fsdev); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " mode="); - lib9p_dm_format(&self->mode, state); - fmt_state_puts(state, " atime="); - fmt_state_printf(state, "%"PRIu32, self->atime); - fmt_state_puts(state, " mtime="); - fmt_state_printf(state, "%"PRIu32, self->mtime); - fmt_state_puts(state, " length="); - fmt_state_printf(state, "%"PRIu64, self->length); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " owner_uname="); - lib9p_s_format(&self->owner_uname, state); - fmt_state_puts(state, " owner_gname="); - lib9p_s_format(&self->owner_gname, state); - fmt_state_puts(state, " last_modifier_uname="); - lib9p_s_format(&self->last_modifier_uname, state); -#if CONFIG_9P_ENABLE_9P2000_u - fmt_state_puts(state, " extension="); - lib9p_s_format(&self->extension, state); - fmt_state_puts(state, " owner_unum="); - lib9p_nuid_format(&self->owner_unum, state); - fmt_state_puts(state, " owner_gnum="); - lib9p_nuid_format(&self->owner_gnum, state); - fmt_state_puts(state, " last_modifier_unum="); - lib9p_nuid_format(&self->last_modifier_unum, state); -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - fmt_state_puts(state, " }"); -} - -static void lib9p_o_format(lib9p_o_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_o(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_o_t *self) { bool empty = true; - fmt_state_putchar(state, '('); + fmt_print_byte(w, '('); if (*self & (UINT8_C(1)<<7)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<7"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<7"); empty = false; } if (*self & (UINT8_C(1)<<6)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "RCLOSE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "RCLOSE"); empty = false; } if (*self & (UINT8_C(1)<<5)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "CEXEC"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "CEXEC"); empty = false; } if (*self & (UINT8_C(1)<<4)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "TRUNC"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "TRUNC"); empty = false; } if (*self & (UINT8_C(1)<<3)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<3"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<3"); empty = false; } if (*self & (UINT8_C(1)<<2)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<2"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<2"); empty = false; } switch (*self & LIB9P_O_MODE_MASK) { case LIB9P_O_MODE_READ: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE_READ"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE_READ"); empty = false; break; case LIB9P_O_MODE_WRITE: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE_WRITE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE_WRITE"); empty = false; break; case LIB9P_O_MODE_RDWR: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE_RDWR"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE_RDWR"); empty = false; break; case LIB9P_O_MODE_EXEC: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE_EXEC"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE_EXEC"); empty = false; break; default: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_printf(state, "%"PRIu8, *self & LIB9P_O_MODE_MASK); + fmt_print_byte(w, '|'); + fmt_print_base10(w, *self & LIB9P_O_MODE_MASK); empty = false; } if (empty) - fmt_state_putchar(state, '0'); - fmt_state_putchar(state, ')'); + fmt_print_byte(w, '0'); + fmt_print_byte(w, ')'); } #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -static void lib9p_msg_Tversion_format(struct lib9p_msg_Tversion *self, struct fmt_state *state) { - fmt_state_puts(state, "Tversion {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " max_msg_size="); - fmt_state_printf(state, "%"PRIu32, self->max_msg_size); - fmt_state_puts(state, " version="); - lib9p_s_format(&self->version, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rversion_format(struct lib9p_msg_Rversion *self, struct fmt_state *state) { - fmt_state_puts(state, "Rversion {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " max_msg_size="); - fmt_state_printf(state, "%"PRIu32, self->max_msg_size); - fmt_state_puts(state, " version="); - lib9p_s_format(&self->version, state); - fmt_state_puts(state, " }"); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void lib9p_msg_Tauth_format(struct lib9p_msg_Tauth *self, struct fmt_state *state) { - fmt_state_puts(state, "Tauth {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " afid="); - lib9p_fid_format(&self->afid, state); - fmt_state_puts(state, " uname="); - lib9p_s_format(&self->uname, state); - fmt_state_puts(state, " aname="); - lib9p_s_format(&self->aname, state); #if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - fmt_state_puts(state, " unum="); - lib9p_nuid_format(&self->unum, state); -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rauth_format(struct lib9p_msg_Rauth *self, struct fmt_state *state) { - fmt_state_puts(state, "Rauth {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " aqid="); - lib9p_qid_format(&self->aqid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tattach_format(struct lib9p_msg_Tattach *self, struct fmt_state *state) { - fmt_state_puts(state, "Tattach {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " afid="); - lib9p_fid_format(&self->afid, state); - fmt_state_puts(state, " uname="); - lib9p_s_format(&self->uname, state); - fmt_state_puts(state, " aname="); - lib9p_s_format(&self->aname, state); -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - fmt_state_puts(state, " unum="); - lib9p_nuid_format(&self->unum, state); -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rattach_format(struct lib9p_msg_Rattach *self, struct fmt_state *state) { - fmt_state_puts(state, "Rattach {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " }"); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -static void lib9p_msg_Rerror_format(struct lib9p_msg_Rerror *self, struct fmt_state *state) { - fmt_state_puts(state, "Rerror {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " errstr="); - lib9p_s_format(&self->errstr, state); -#if CONFIG_9P_ENABLE_9P2000_u - fmt_state_puts(state, " errnum="); - lib9p_errno_format(&self->errnum, state); -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - fmt_state_puts(state, " }"); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void lib9p_msg_Tflush_format(struct lib9p_msg_Tflush *self, struct fmt_state *state) { - fmt_state_puts(state, "Tflush {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " oldtag="); - fmt_state_printf(state, "%"PRIu16, self->oldtag); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rflush_format(struct lib9p_msg_Rflush *self, struct fmt_state *state) { - fmt_state_puts(state, "Rflush {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Twalk_format(struct lib9p_msg_Twalk *self, struct fmt_state *state) { - fmt_state_puts(state, "Twalk {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " newfid="); - lib9p_fid_format(&self->newfid, state); - fmt_state_puts(state, " nwname="); - fmt_state_printf(state, "%"PRIu16, self->nwname); - fmt_state_puts(state, " wname=["); - for (uint16_t i = 0; i < self->nwname; i++) { - if (i) - fmt_state_putchar(state, ','); - fmt_state_putchar(state, ' '); - lib9p_s_format(&self->wname[i], state); - } - fmt_state_puts(state, " ]"); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rwalk_format(struct lib9p_msg_Rwalk *self, struct fmt_state *state) { - fmt_state_puts(state, "Rwalk {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " nwqid="); - fmt_state_printf(state, "%"PRIu16, self->nwqid); - fmt_state_puts(state, " wqid=["); - for (uint16_t i = 0; i < self->nwqid; i++) { - if (i) - fmt_state_putchar(state, ','); - fmt_state_putchar(state, ' '); - lib9p_qid_format(&self->wqid[i], state); - } - fmt_state_puts(state, " ]"); - fmt_state_puts(state, " }"); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void lib9p_msg_Topen_format(struct lib9p_msg_Topen *self, struct fmt_state *state) { - fmt_state_puts(state, "Topen {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " mode="); - lib9p_o_format(&self->mode, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Ropen_format(struct lib9p_msg_Ropen *self, struct fmt_state *state) { - fmt_state_puts(state, "Ropen {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " iounit="); - fmt_state_printf(state, "%"PRIu32, self->iounit); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tcreate_format(struct lib9p_msg_Tcreate *self, struct fmt_state *state) { - fmt_state_puts(state, "Tcreate {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " perm="); - lib9p_dm_format(&self->perm, state); - fmt_state_puts(state, " mode="); - lib9p_o_format(&self->mode, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rcreate_format(struct lib9p_msg_Rcreate *self, struct fmt_state *state) { - fmt_state_puts(state, "Rcreate {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " iounit="); - fmt_state_printf(state, "%"PRIu32, self->iounit); - fmt_state_puts(state, " }"); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void lib9p_msg_Tread_format(struct lib9p_msg_Tread *self, struct fmt_state *state) { - fmt_state_puts(state, "Tread {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " offset="); - fmt_state_printf(state, "%"PRIu64, self->offset); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rread_format(struct lib9p_msg_Rread *self, struct fmt_state *state) { - fmt_state_puts(state, "Rread {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); - if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat" -#pragma GCC diagnostic ignored "-Wformat-extra-args" - fmt_state_printf(state, " data=%.*q%s", - (int)(self->count < 50 ? self->count : 50), - (char *)self->data, - self->count < 50 ? "" : "..."); -#pragma GCC diagnostic pop - } else { - fmt_state_puts(state, " data=<bytedata>"); - } - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Twrite_format(struct lib9p_msg_Twrite *self, struct fmt_state *state) { - fmt_state_puts(state, "Twrite {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " offset="); - fmt_state_printf(state, "%"PRIu64, self->offset); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); - if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat" -#pragma GCC diagnostic ignored "-Wformat-extra-args" - fmt_state_printf(state, " data=%.*q%s", - (int)(self->count < 50 ? self->count : 50), - (char *)self->data, - self->count < 50 ? "" : "..."); -#pragma GCC diagnostic pop - } else { - fmt_state_puts(state, " data=<bytedata>"); - } - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rwrite_format(struct lib9p_msg_Rwrite *self, struct fmt_state *state) { - fmt_state_puts(state, "Rwrite {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tclunk_format(struct lib9p_msg_Tclunk *self, struct fmt_state *state) { - fmt_state_puts(state, "Tclunk {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rclunk_format(struct lib9p_msg_Rclunk *self, struct fmt_state *state) { - fmt_state_puts(state, "Rclunk {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tremove_format(struct lib9p_msg_Tremove *self, struct fmt_state *state) { - fmt_state_puts(state, "Tremove {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rremove_format(struct lib9p_msg_Rremove *self, struct fmt_state *state) { - fmt_state_puts(state, "Rremove {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void lib9p_msg_Tstat_format(struct lib9p_msg_Tstat *self, struct fmt_state *state) { - fmt_state_puts(state, "Tstat {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rstat_format(struct lib9p_msg_Rstat *self, struct fmt_state *state) { - fmt_state_puts(state, "Rstat {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " stat="); - lib9p_stat_format(&self->stat, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Twstat_format(struct lib9p_msg_Twstat *self, struct fmt_state *state) { - fmt_state_puts(state, "Twstat {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " stat="); - lib9p_stat_format(&self->stat, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rwstat_format(struct lib9p_msg_Rwstat *self, struct fmt_state *state) { - fmt_state_puts(state, "Rwstat {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_p9p -static void lib9p_msg_Topenfd_format(struct lib9p_msg_Topenfd *self, struct fmt_state *state) { - fmt_state_puts(state, "Topenfd {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " mode="); - lib9p_o_format(&self->mode, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Ropenfd_format(struct lib9p_msg_Ropenfd *self, struct fmt_state *state) { - fmt_state_puts(state, "Ropenfd {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " iounit="); - fmt_state_printf(state, "%"PRIu32, self->iounit); - fmt_state_puts(state, " unixfd="); - fmt_state_printf(state, "%"PRIu32, self->unixfd); - fmt_state_puts(state, " }"); -} - -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u -static void lib9p_nuid_format(lib9p_nuid_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_nuid(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_nuid_t *self) { switch (*self) { case LIB9P_NUID_NONUID: - fmt_state_puts(state, "NONUID"); + fmt_print_str(w, "NONUID"); break; default: - fmt_state_printf(state, "%"PRIu32, *self); + fmt_print_base10(w, *self); } } -static void lib9p_errno_format(lib9p_errno_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_errno(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_errno_t *self) { switch (*self) { case LIB9P_ERRNO_NOERROR: - fmt_state_puts(state, "NOERROR"); + fmt_print_str(w, "NOERROR"); break; case LIB9P_ERRNO_L_EPERM: - fmt_state_puts(state, "L_EPERM"); + fmt_print_str(w, "L_EPERM"); break; case LIB9P_ERRNO_L_ENOENT: - fmt_state_puts(state, "L_ENOENT"); + fmt_print_str(w, "L_ENOENT"); break; case LIB9P_ERRNO_L_ESRCH: - fmt_state_puts(state, "L_ESRCH"); + fmt_print_str(w, "L_ESRCH"); break; case LIB9P_ERRNO_L_EINTR: - fmt_state_puts(state, "L_EINTR"); + fmt_print_str(w, "L_EINTR"); break; case LIB9P_ERRNO_L_EIO: - fmt_state_puts(state, "L_EIO"); + fmt_print_str(w, "L_EIO"); break; case LIB9P_ERRNO_L_ENXIO: - fmt_state_puts(state, "L_ENXIO"); + fmt_print_str(w, "L_ENXIO"); break; case LIB9P_ERRNO_L_E2BIG: - fmt_state_puts(state, "L_E2BIG"); + fmt_print_str(w, "L_E2BIG"); break; case LIB9P_ERRNO_L_ENOEXEC: - fmt_state_puts(state, "L_ENOEXEC"); + fmt_print_str(w, "L_ENOEXEC"); break; case LIB9P_ERRNO_L_EBADF: - fmt_state_puts(state, "L_EBADF"); + fmt_print_str(w, "L_EBADF"); break; case LIB9P_ERRNO_L_ECHILD: - fmt_state_puts(state, "L_ECHILD"); + fmt_print_str(w, "L_ECHILD"); break; case LIB9P_ERRNO_L_EAGAIN: - fmt_state_puts(state, "L_EAGAIN"); + fmt_print_str(w, "L_EAGAIN"); break; case LIB9P_ERRNO_L_ENOMEM: - fmt_state_puts(state, "L_ENOMEM"); + fmt_print_str(w, "L_ENOMEM"); break; case LIB9P_ERRNO_L_EACCES: - fmt_state_puts(state, "L_EACCES"); + fmt_print_str(w, "L_EACCES"); break; case LIB9P_ERRNO_L_EFAULT: - fmt_state_puts(state, "L_EFAULT"); + fmt_print_str(w, "L_EFAULT"); break; case LIB9P_ERRNO_L_ENOTBLK: - fmt_state_puts(state, "L_ENOTBLK"); + fmt_print_str(w, "L_ENOTBLK"); break; case LIB9P_ERRNO_L_EBUSY: - fmt_state_puts(state, "L_EBUSY"); + fmt_print_str(w, "L_EBUSY"); break; case LIB9P_ERRNO_L_EEXIST: - fmt_state_puts(state, "L_EEXIST"); + fmt_print_str(w, "L_EEXIST"); break; case LIB9P_ERRNO_L_EXDEV: - fmt_state_puts(state, "L_EXDEV"); + fmt_print_str(w, "L_EXDEV"); break; case LIB9P_ERRNO_L_ENODEV: - fmt_state_puts(state, "L_ENODEV"); + fmt_print_str(w, "L_ENODEV"); break; case LIB9P_ERRNO_L_ENOTDIR: - fmt_state_puts(state, "L_ENOTDIR"); + fmt_print_str(w, "L_ENOTDIR"); break; case LIB9P_ERRNO_L_EISDIR: - fmt_state_puts(state, "L_EISDIR"); + fmt_print_str(w, "L_EISDIR"); break; case LIB9P_ERRNO_L_EINVAL: - fmt_state_puts(state, "L_EINVAL"); + fmt_print_str(w, "L_EINVAL"); break; case LIB9P_ERRNO_L_ENFILE: - fmt_state_puts(state, "L_ENFILE"); + fmt_print_str(w, "L_ENFILE"); break; case LIB9P_ERRNO_L_EMFILE: - fmt_state_puts(state, "L_EMFILE"); + fmt_print_str(w, "L_EMFILE"); break; case LIB9P_ERRNO_L_ENOTTY: - fmt_state_puts(state, "L_ENOTTY"); + fmt_print_str(w, "L_ENOTTY"); break; case LIB9P_ERRNO_L_ETXTBSY: - fmt_state_puts(state, "L_ETXTBSY"); + fmt_print_str(w, "L_ETXTBSY"); break; case LIB9P_ERRNO_L_EFBIG: - fmt_state_puts(state, "L_EFBIG"); + fmt_print_str(w, "L_EFBIG"); break; case LIB9P_ERRNO_L_ENOSPC: - fmt_state_puts(state, "L_ENOSPC"); + fmt_print_str(w, "L_ENOSPC"); break; case LIB9P_ERRNO_L_ESPIPE: - fmt_state_puts(state, "L_ESPIPE"); + fmt_print_str(w, "L_ESPIPE"); break; case LIB9P_ERRNO_L_EROFS: - fmt_state_puts(state, "L_EROFS"); + fmt_print_str(w, "L_EROFS"); break; case LIB9P_ERRNO_L_EMLINK: - fmt_state_puts(state, "L_EMLINK"); + fmt_print_str(w, "L_EMLINK"); break; case LIB9P_ERRNO_L_EPIPE: - fmt_state_puts(state, "L_EPIPE"); + fmt_print_str(w, "L_EPIPE"); break; case LIB9P_ERRNO_L_EDOM: - fmt_state_puts(state, "L_EDOM"); + fmt_print_str(w, "L_EDOM"); break; case LIB9P_ERRNO_L_ERANGE: - fmt_state_puts(state, "L_ERANGE"); + fmt_print_str(w, "L_ERANGE"); break; case LIB9P_ERRNO_L_EDEADLK: - fmt_state_puts(state, "L_EDEADLK"); + fmt_print_str(w, "L_EDEADLK"); break; case LIB9P_ERRNO_L_ENAMETOOLONG: - fmt_state_puts(state, "L_ENAMETOOLONG"); + fmt_print_str(w, "L_ENAMETOOLONG"); break; case LIB9P_ERRNO_L_ENOLCK: - fmt_state_puts(state, "L_ENOLCK"); + fmt_print_str(w, "L_ENOLCK"); break; case LIB9P_ERRNO_L_ENOSYS: - fmt_state_puts(state, "L_ENOSYS"); + fmt_print_str(w, "L_ENOSYS"); break; case LIB9P_ERRNO_L_ENOTEMPTY: - fmt_state_puts(state, "L_ENOTEMPTY"); + fmt_print_str(w, "L_ENOTEMPTY"); break; case LIB9P_ERRNO_L_ELOOP: - fmt_state_puts(state, "L_ELOOP"); + fmt_print_str(w, "L_ELOOP"); break; case LIB9P_ERRNO_L_ENOMSG: - fmt_state_puts(state, "L_ENOMSG"); + fmt_print_str(w, "L_ENOMSG"); break; case LIB9P_ERRNO_L_EIDRM: - fmt_state_puts(state, "L_EIDRM"); + fmt_print_str(w, "L_EIDRM"); break; case LIB9P_ERRNO_L_ECHRNG: - fmt_state_puts(state, "L_ECHRNG"); + fmt_print_str(w, "L_ECHRNG"); break; case LIB9P_ERRNO_L_EL2NSYNC: - fmt_state_puts(state, "L_EL2NSYNC"); + fmt_print_str(w, "L_EL2NSYNC"); break; case LIB9P_ERRNO_L_EL3HLT: - fmt_state_puts(state, "L_EL3HLT"); + fmt_print_str(w, "L_EL3HLT"); break; case LIB9P_ERRNO_L_EL3RST: - fmt_state_puts(state, "L_EL3RST"); + fmt_print_str(w, "L_EL3RST"); break; case LIB9P_ERRNO_L_ELNRNG: - fmt_state_puts(state, "L_ELNRNG"); + fmt_print_str(w, "L_ELNRNG"); break; case LIB9P_ERRNO_L_EUNATCH: - fmt_state_puts(state, "L_EUNATCH"); + fmt_print_str(w, "L_EUNATCH"); break; case LIB9P_ERRNO_L_ENOCSI: - fmt_state_puts(state, "L_ENOCSI"); + fmt_print_str(w, "L_ENOCSI"); break; case LIB9P_ERRNO_L_EL2HLT: - fmt_state_puts(state, "L_EL2HLT"); + fmt_print_str(w, "L_EL2HLT"); break; case LIB9P_ERRNO_L_EBADE: - fmt_state_puts(state, "L_EBADE"); + fmt_print_str(w, "L_EBADE"); break; case LIB9P_ERRNO_L_EBADR: - fmt_state_puts(state, "L_EBADR"); + fmt_print_str(w, "L_EBADR"); break; case LIB9P_ERRNO_L_EXFULL: - fmt_state_puts(state, "L_EXFULL"); + fmt_print_str(w, "L_EXFULL"); break; case LIB9P_ERRNO_L_ENOANO: - fmt_state_puts(state, "L_ENOANO"); + fmt_print_str(w, "L_ENOANO"); break; case LIB9P_ERRNO_L_EBADRQC: - fmt_state_puts(state, "L_EBADRQC"); + fmt_print_str(w, "L_EBADRQC"); break; case LIB9P_ERRNO_L_EBADSLT: - fmt_state_puts(state, "L_EBADSLT"); + fmt_print_str(w, "L_EBADSLT"); break; case LIB9P_ERRNO_L_EBFONT: - fmt_state_puts(state, "L_EBFONT"); + fmt_print_str(w, "L_EBFONT"); break; case LIB9P_ERRNO_L_ENOSTR: - fmt_state_puts(state, "L_ENOSTR"); + fmt_print_str(w, "L_ENOSTR"); break; case LIB9P_ERRNO_L_ENODATA: - fmt_state_puts(state, "L_ENODATA"); + fmt_print_str(w, "L_ENODATA"); break; case LIB9P_ERRNO_L_ETIME: - fmt_state_puts(state, "L_ETIME"); + fmt_print_str(w, "L_ETIME"); break; case LIB9P_ERRNO_L_ENOSR: - fmt_state_puts(state, "L_ENOSR"); + fmt_print_str(w, "L_ENOSR"); break; case LIB9P_ERRNO_L_ENONET: - fmt_state_puts(state, "L_ENONET"); + fmt_print_str(w, "L_ENONET"); break; case LIB9P_ERRNO_L_ENOPKG: - fmt_state_puts(state, "L_ENOPKG"); + fmt_print_str(w, "L_ENOPKG"); break; case LIB9P_ERRNO_L_EREMOTE: - fmt_state_puts(state, "L_EREMOTE"); + fmt_print_str(w, "L_EREMOTE"); break; case LIB9P_ERRNO_L_ENOLINK: - fmt_state_puts(state, "L_ENOLINK"); + fmt_print_str(w, "L_ENOLINK"); break; case LIB9P_ERRNO_L_EADV: - fmt_state_puts(state, "L_EADV"); + fmt_print_str(w, "L_EADV"); break; case LIB9P_ERRNO_L_ESRMNT: - fmt_state_puts(state, "L_ESRMNT"); + fmt_print_str(w, "L_ESRMNT"); break; case LIB9P_ERRNO_L_ECOMM: - fmt_state_puts(state, "L_ECOMM"); + fmt_print_str(w, "L_ECOMM"); break; case LIB9P_ERRNO_L_EPROTO: - fmt_state_puts(state, "L_EPROTO"); + fmt_print_str(w, "L_EPROTO"); break; case LIB9P_ERRNO_L_EMULTIHOP: - fmt_state_puts(state, "L_EMULTIHOP"); + fmt_print_str(w, "L_EMULTIHOP"); break; case LIB9P_ERRNO_L_EDOTDOT: - fmt_state_puts(state, "L_EDOTDOT"); + fmt_print_str(w, "L_EDOTDOT"); break; case LIB9P_ERRNO_L_EBADMSG: - fmt_state_puts(state, "L_EBADMSG"); + fmt_print_str(w, "L_EBADMSG"); break; case LIB9P_ERRNO_L_EOVERFLOW: - fmt_state_puts(state, "L_EOVERFLOW"); + fmt_print_str(w, "L_EOVERFLOW"); break; case LIB9P_ERRNO_L_ENOTUNIQ: - fmt_state_puts(state, "L_ENOTUNIQ"); + fmt_print_str(w, "L_ENOTUNIQ"); break; case LIB9P_ERRNO_L_EBADFD: - fmt_state_puts(state, "L_EBADFD"); + fmt_print_str(w, "L_EBADFD"); break; case LIB9P_ERRNO_L_EREMCHG: - fmt_state_puts(state, "L_EREMCHG"); + fmt_print_str(w, "L_EREMCHG"); break; case LIB9P_ERRNO_L_ELIBACC: - fmt_state_puts(state, "L_ELIBACC"); + fmt_print_str(w, "L_ELIBACC"); break; case LIB9P_ERRNO_L_ELIBBAD: - fmt_state_puts(state, "L_ELIBBAD"); + fmt_print_str(w, "L_ELIBBAD"); break; case LIB9P_ERRNO_L_ELIBSCN: - fmt_state_puts(state, "L_ELIBSCN"); + fmt_print_str(w, "L_ELIBSCN"); break; case LIB9P_ERRNO_L_ELIBMAX: - fmt_state_puts(state, "L_ELIBMAX"); + fmt_print_str(w, "L_ELIBMAX"); break; case LIB9P_ERRNO_L_ELIBEXEC: - fmt_state_puts(state, "L_ELIBEXEC"); + fmt_print_str(w, "L_ELIBEXEC"); break; case LIB9P_ERRNO_L_EILSEQ: - fmt_state_puts(state, "L_EILSEQ"); + fmt_print_str(w, "L_EILSEQ"); break; case LIB9P_ERRNO_L_ERESTART: - fmt_state_puts(state, "L_ERESTART"); + fmt_print_str(w, "L_ERESTART"); break; case LIB9P_ERRNO_L_ESTRPIPE: - fmt_state_puts(state, "L_ESTRPIPE"); + fmt_print_str(w, "L_ESTRPIPE"); break; case LIB9P_ERRNO_L_EUSERS: - fmt_state_puts(state, "L_EUSERS"); + fmt_print_str(w, "L_EUSERS"); break; case LIB9P_ERRNO_L_ENOTSOCK: - fmt_state_puts(state, "L_ENOTSOCK"); + fmt_print_str(w, "L_ENOTSOCK"); break; case LIB9P_ERRNO_L_EDESTADDRREQ: - fmt_state_puts(state, "L_EDESTADDRREQ"); + fmt_print_str(w, "L_EDESTADDRREQ"); break; case LIB9P_ERRNO_L_EMSGSIZE: - fmt_state_puts(state, "L_EMSGSIZE"); + fmt_print_str(w, "L_EMSGSIZE"); break; case LIB9P_ERRNO_L_EPROTOTYPE: - fmt_state_puts(state, "L_EPROTOTYPE"); + fmt_print_str(w, "L_EPROTOTYPE"); break; case LIB9P_ERRNO_L_ENOPROTOOPT: - fmt_state_puts(state, "L_ENOPROTOOPT"); + fmt_print_str(w, "L_ENOPROTOOPT"); break; case LIB9P_ERRNO_L_EPROTONOSUPPORT: - fmt_state_puts(state, "L_EPROTONOSUPPORT"); + fmt_print_str(w, "L_EPROTONOSUPPORT"); break; case LIB9P_ERRNO_L_ESOCKTNOSUPPORT: - fmt_state_puts(state, "L_ESOCKTNOSUPPORT"); + fmt_print_str(w, "L_ESOCKTNOSUPPORT"); break; case LIB9P_ERRNO_L_EOPNOTSUPP: - fmt_state_puts(state, "L_EOPNOTSUPP"); + fmt_print_str(w, "L_EOPNOTSUPP"); break; case LIB9P_ERRNO_L_EPFNOSUPPORT: - fmt_state_puts(state, "L_EPFNOSUPPORT"); + fmt_print_str(w, "L_EPFNOSUPPORT"); break; case LIB9P_ERRNO_L_EAFNOSUPPORT: - fmt_state_puts(state, "L_EAFNOSUPPORT"); + fmt_print_str(w, "L_EAFNOSUPPORT"); break; case LIB9P_ERRNO_L_EADDRINUSE: - fmt_state_puts(state, "L_EADDRINUSE"); + fmt_print_str(w, "L_EADDRINUSE"); break; case LIB9P_ERRNO_L_EADDRNOTAVAIL: - fmt_state_puts(state, "L_EADDRNOTAVAIL"); + fmt_print_str(w, "L_EADDRNOTAVAIL"); break; case LIB9P_ERRNO_L_ENETDOWN: - fmt_state_puts(state, "L_ENETDOWN"); + fmt_print_str(w, "L_ENETDOWN"); break; case LIB9P_ERRNO_L_ENETUNREACH: - fmt_state_puts(state, "L_ENETUNREACH"); + fmt_print_str(w, "L_ENETUNREACH"); break; case LIB9P_ERRNO_L_ENETRESET: - fmt_state_puts(state, "L_ENETRESET"); + fmt_print_str(w, "L_ENETRESET"); break; case LIB9P_ERRNO_L_ECONNABORTED: - fmt_state_puts(state, "L_ECONNABORTED"); + fmt_print_str(w, "L_ECONNABORTED"); break; case LIB9P_ERRNO_L_ECONNRESET: - fmt_state_puts(state, "L_ECONNRESET"); + fmt_print_str(w, "L_ECONNRESET"); break; case LIB9P_ERRNO_L_ENOBUFS: - fmt_state_puts(state, "L_ENOBUFS"); + fmt_print_str(w, "L_ENOBUFS"); break; case LIB9P_ERRNO_L_EISCONN: - fmt_state_puts(state, "L_EISCONN"); + fmt_print_str(w, "L_EISCONN"); break; case LIB9P_ERRNO_L_ENOTCONN: - fmt_state_puts(state, "L_ENOTCONN"); + fmt_print_str(w, "L_ENOTCONN"); break; case LIB9P_ERRNO_L_ESHUTDOWN: - fmt_state_puts(state, "L_ESHUTDOWN"); + fmt_print_str(w, "L_ESHUTDOWN"); break; case LIB9P_ERRNO_L_ETOOMANYREFS: - fmt_state_puts(state, "L_ETOOMANYREFS"); + fmt_print_str(w, "L_ETOOMANYREFS"); break; case LIB9P_ERRNO_L_ETIMEDOUT: - fmt_state_puts(state, "L_ETIMEDOUT"); + fmt_print_str(w, "L_ETIMEDOUT"); break; case LIB9P_ERRNO_L_ECONNREFUSED: - fmt_state_puts(state, "L_ECONNREFUSED"); + fmt_print_str(w, "L_ECONNREFUSED"); break; case LIB9P_ERRNO_L_EHOSTDOWN: - fmt_state_puts(state, "L_EHOSTDOWN"); + fmt_print_str(w, "L_EHOSTDOWN"); break; case LIB9P_ERRNO_L_EHOSTUNREACH: - fmt_state_puts(state, "L_EHOSTUNREACH"); + fmt_print_str(w, "L_EHOSTUNREACH"); break; case LIB9P_ERRNO_L_EALREADY: - fmt_state_puts(state, "L_EALREADY"); + fmt_print_str(w, "L_EALREADY"); break; case LIB9P_ERRNO_L_EINPROGRESS: - fmt_state_puts(state, "L_EINPROGRESS"); + fmt_print_str(w, "L_EINPROGRESS"); break; case LIB9P_ERRNO_L_ESTALE: - fmt_state_puts(state, "L_ESTALE"); + fmt_print_str(w, "L_ESTALE"); break; case LIB9P_ERRNO_L_EUCLEAN: - fmt_state_puts(state, "L_EUCLEAN"); + fmt_print_str(w, "L_EUCLEAN"); break; case LIB9P_ERRNO_L_ENOTNAM: - fmt_state_puts(state, "L_ENOTNAM"); + fmt_print_str(w, "L_ENOTNAM"); break; case LIB9P_ERRNO_L_ENAVAIL: - fmt_state_puts(state, "L_ENAVAIL"); + fmt_print_str(w, "L_ENAVAIL"); break; case LIB9P_ERRNO_L_EISNAM: - fmt_state_puts(state, "L_EISNAM"); + fmt_print_str(w, "L_EISNAM"); break; case LIB9P_ERRNO_L_EREMOTEIO: - fmt_state_puts(state, "L_EREMOTEIO"); + fmt_print_str(w, "L_EREMOTEIO"); break; case LIB9P_ERRNO_L_EDQUOT: - fmt_state_puts(state, "L_EDQUOT"); + fmt_print_str(w, "L_EDQUOT"); break; case LIB9P_ERRNO_L_ENOMEDIUM: - fmt_state_puts(state, "L_ENOMEDIUM"); + fmt_print_str(w, "L_ENOMEDIUM"); break; case LIB9P_ERRNO_L_EMEDIUMTYPE: - fmt_state_puts(state, "L_EMEDIUMTYPE"); + fmt_print_str(w, "L_EMEDIUMTYPE"); break; case LIB9P_ERRNO_L_ECANCELED: - fmt_state_puts(state, "L_ECANCELED"); + fmt_print_str(w, "L_ECANCELED"); break; case LIB9P_ERRNO_L_ENOKEY: - fmt_state_puts(state, "L_ENOKEY"); + fmt_print_str(w, "L_ENOKEY"); break; case LIB9P_ERRNO_L_EKEYEXPIRED: - fmt_state_puts(state, "L_EKEYEXPIRED"); + fmt_print_str(w, "L_EKEYEXPIRED"); break; case LIB9P_ERRNO_L_EKEYREVOKED: - fmt_state_puts(state, "L_EKEYREVOKED"); + fmt_print_str(w, "L_EKEYREVOKED"); break; case LIB9P_ERRNO_L_EKEYREJECTED: - fmt_state_puts(state, "L_EKEYREJECTED"); + fmt_print_str(w, "L_EKEYREJECTED"); break; case LIB9P_ERRNO_L_EOWNERDEAD: - fmt_state_puts(state, "L_EOWNERDEAD"); + fmt_print_str(w, "L_EOWNERDEAD"); break; case LIB9P_ERRNO_L_ENOTRECOVERABLE: - fmt_state_puts(state, "L_ENOTRECOVERABLE"); + fmt_print_str(w, "L_ENOTRECOVERABLE"); break; case LIB9P_ERRNO_L_ERFKILL: - fmt_state_puts(state, "L_ERFKILL"); + fmt_print_str(w, "L_ERFKILL"); break; case LIB9P_ERRNO_L_EHWPOISON: - fmt_state_puts(state, "L_EHWPOISON"); + fmt_print_str(w, "L_EHWPOISON"); break; default: - fmt_state_printf(state, "%"PRIu32, *self); + fmt_print_base10(w, *self); } } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L -static void lib9p_super_magic_format(lib9p_super_magic_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_super_magic(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_super_magic_t *self) { switch (*self) { case LIB9P_SUPER_MAGIC_V9FS_MAGIC: - fmt_state_puts(state, "V9FS_MAGIC"); + fmt_print_str(w, "V9FS_MAGIC"); break; default: - fmt_state_printf(state, "%"PRIu32, *self); + fmt_print_base10(w, *self); } } -static void lib9p_lo_format(lib9p_lo_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_lo(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_lo_t *self) { bool empty = true; - fmt_state_putchar(state, '('); + fmt_print_byte(w, '('); if (*self & (UINT32_C(1)<<31)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<31"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<31"); empty = false; } if (*self & (UINT32_C(1)<<30)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<30"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<30"); empty = false; } if (*self & (UINT32_C(1)<<29)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<29"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<29"); empty = false; } if (*self & (UINT32_C(1)<<28)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<28"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<28"); empty = false; } if (*self & (UINT32_C(1)<<27)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<27"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<27"); empty = false; } if (*self & (UINT32_C(1)<<26)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<26"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<26"); empty = false; } if (*self & (UINT32_C(1)<<25)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<25"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<25"); empty = false; } if (*self & (UINT32_C(1)<<24)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<24"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<24"); empty = false; } if (*self & (UINT32_C(1)<<23)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<23"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<23"); empty = false; } if (*self & (UINT32_C(1)<<22)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<22"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<22"); empty = false; } if (*self & (UINT32_C(1)<<21)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<21"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<21"); empty = false; } if (*self & (UINT32_C(1)<<20)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "SYNC"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "SYNC"); empty = false; } if (*self & (UINT32_C(1)<<19)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "CLOEXEC"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "CLOEXEC"); empty = false; } if (*self & (UINT32_C(1)<<18)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "NOATIME"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "NOATIME"); empty = false; } if (*self & (UINT32_C(1)<<17)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "NOFOLLOW"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "NOFOLLOW"); empty = false; } if (*self & (UINT32_C(1)<<16)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "DIRECTORY"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "DIRECTORY"); empty = false; } if (*self & (UINT32_C(1)<<15)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "LARGEFILE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "LARGEFILE"); empty = false; } if (*self & (UINT32_C(1)<<14)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "DIRECT"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "DIRECT"); empty = false; } if (*self & (UINT32_C(1)<<13)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "BSD_FASYNC"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "BSD_FASYNC"); empty = false; } if (*self & (UINT32_C(1)<<12)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "DSYNC"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "DSYNC"); empty = false; } if (*self & (UINT32_C(1)<<11)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "NONBLOCK"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "NONBLOCK"); empty = false; } if (*self & (UINT32_C(1)<<10)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "APPEND"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "APPEND"); empty = false; } if (*self & (UINT32_C(1)<<9)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "TRUNC"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "TRUNC"); empty = false; } if (*self & (UINT32_C(1)<<8)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "NOCTTY"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "NOCTTY"); empty = false; } if (*self & (UINT32_C(1)<<7)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "EXCL"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "EXCL"); empty = false; } if (*self & (UINT32_C(1)<<6)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "CREATE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "CREATE"); empty = false; } if (*self & (UINT32_C(1)<<5)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<5"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<5"); empty = false; } if (*self & (UINT32_C(1)<<4)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<4"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<4"); empty = false; } if (*self & (UINT32_C(1)<<3)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<3"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<3"); empty = false; } if (*self & (UINT32_C(1)<<2)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<2"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<2"); empty = false; } switch (*self & LIB9P_LO_MODE_MASK) { case LIB9P_LO_MODE_RDONLY: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE_RDONLY"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE_RDONLY"); empty = false; break; case LIB9P_LO_MODE_WRONLY: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE_WRONLY"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE_WRONLY"); empty = false; break; case LIB9P_LO_MODE_RDWR: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE_RDWR"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE_RDWR"); empty = false; break; case LIB9P_LO_MODE_NOACCESS: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE_NOACCESS"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE_NOACCESS"); empty = false; break; default: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_printf(state, "%"PRIu32, *self & LIB9P_LO_MODE_MASK); + fmt_print_byte(w, '|'); + fmt_print_base10(w, *self & LIB9P_LO_MODE_MASK); empty = false; } if (empty) - fmt_state_putchar(state, '0'); - fmt_state_putchar(state, ')'); + fmt_print_byte(w, '0'); + fmt_print_byte(w, ')'); } -static void lib9p_dt_format(lib9p_dt_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_dt(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_dt_t *self) { switch (*self) { case LIB9P_DT_UNKNOWN: - fmt_state_puts(state, "UNKNOWN"); + fmt_print_str(w, "UNKNOWN"); break; case LIB9P_DT_PIPE: - fmt_state_puts(state, "PIPE"); + fmt_print_str(w, "PIPE"); break; case LIB9P_DT_CHAR_DEV: - fmt_state_puts(state, "CHAR_DEV"); + fmt_print_str(w, "CHAR_DEV"); break; case LIB9P_DT_DIRECTORY: - fmt_state_puts(state, "DIRECTORY"); + fmt_print_str(w, "DIRECTORY"); break; case LIB9P_DT_BLOCK_DEV: - fmt_state_puts(state, "BLOCK_DEV"); + fmt_print_str(w, "BLOCK_DEV"); break; case LIB9P_DT_REGULAR: - fmt_state_puts(state, "REGULAR"); + fmt_print_str(w, "REGULAR"); break; case LIB9P_DT_SYMLINK: - fmt_state_puts(state, "SYMLINK"); + fmt_print_str(w, "SYMLINK"); break; case LIB9P_DT_SOCKET: - fmt_state_puts(state, "SOCKET"); + fmt_print_str(w, "SOCKET"); break; case _LIB9P_DT_WHITEOUT: - fmt_state_puts(state, "_WHITEOUT"); + fmt_print_str(w, "_WHITEOUT"); break; default: - fmt_state_printf(state, "%"PRIu8, *self); + fmt_print_base10(w, *self); } } -static void lib9p_mode_format(lib9p_mode_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_mode(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_mode_t *self) { bool empty = true; - fmt_state_putchar(state, '('); + fmt_print_byte(w, '('); if (*self & (UINT32_C(1)<<31)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<31"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<31"); empty = false; } if (*self & (UINT32_C(1)<<30)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<30"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<30"); empty = false; } if (*self & (UINT32_C(1)<<29)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<29"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<29"); empty = false; } if (*self & (UINT32_C(1)<<28)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<28"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<28"); empty = false; } if (*self & (UINT32_C(1)<<27)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<27"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<27"); empty = false; } if (*self & (UINT32_C(1)<<26)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<26"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<26"); empty = false; } if (*self & (UINT32_C(1)<<25)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<25"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<25"); empty = false; } if (*self & (UINT32_C(1)<<24)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<24"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<24"); empty = false; } if (*self & (UINT32_C(1)<<23)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<23"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<23"); empty = false; } if (*self & (UINT32_C(1)<<22)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<22"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<22"); empty = false; } if (*self & (UINT32_C(1)<<21)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<21"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<21"); empty = false; } if (*self & (UINT32_C(1)<<20)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<20"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<20"); empty = false; } if (*self & (UINT32_C(1)<<19)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<19"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<19"); empty = false; } if (*self & (UINT32_C(1)<<18)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<18"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<18"); empty = false; } if (*self & (UINT32_C(1)<<17)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<17"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<17"); empty = false; } if (*self & (UINT32_C(1)<<16)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<16"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<16"); empty = false; } switch (*self & LIB9P_MODE_FMT_MASK) { case LIB9P_MODE_FMT_PIPE: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "FMT_PIPE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "FMT_PIPE"); empty = false; break; case LIB9P_MODE_FMT_CHAR_DEV: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "FMT_CHAR_DEV"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "FMT_CHAR_DEV"); empty = false; break; case LIB9P_MODE_FMT_DIRECTORY: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "FMT_DIRECTORY"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "FMT_DIRECTORY"); empty = false; break; case LIB9P_MODE_FMT_BLOCK_DEV: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "FMT_BLOCK_DEV"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "FMT_BLOCK_DEV"); empty = false; break; case LIB9P_MODE_FMT_REGULAR: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "FMT_REGULAR"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "FMT_REGULAR"); empty = false; break; case LIB9P_MODE_FMT_SYMLINK: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "FMT_SYMLINK"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "FMT_SYMLINK"); empty = false; break; case LIB9P_MODE_FMT_SOCKET: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "FMT_SOCKET"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "FMT_SOCKET"); empty = false; break; default: if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_printf(state, "%"PRIu32, *self & LIB9P_MODE_FMT_MASK); + fmt_print_byte(w, '|'); + fmt_print_base10(w, *self & LIB9P_MODE_FMT_MASK); empty = false; } if (*self & (UINT32_C(1)<<11)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_SETGROUP"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_SETGROUP"); empty = false; } if (*self & (UINT32_C(1)<<10)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_SETUSER"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_SETUSER"); empty = false; } if (*self & (UINT32_C(1)<<9)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_STICKY"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_STICKY"); empty = false; } if (*self & (UINT32_C(1)<<8)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_OWNER_R"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_OWNER_R"); empty = false; } if (*self & (UINT32_C(1)<<7)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_OWNER_W"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_OWNER_W"); empty = false; } if (*self & (UINT32_C(1)<<6)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_OWNER_X"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_OWNER_X"); empty = false; } if (*self & (UINT32_C(1)<<5)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_GROUP_R"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_GROUP_R"); empty = false; } if (*self & (UINT32_C(1)<<4)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_GROUP_W"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_GROUP_W"); empty = false; } if (*self & (UINT32_C(1)<<3)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_GROUP_X"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_GROUP_X"); empty = false; } if (*self & (UINT32_C(1)<<2)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_OTHER_R"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_OTHER_R"); empty = false; } if (*self & (UINT32_C(1)<<1)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_OTHER_W"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_OTHER_W"); empty = false; } if (*self & (UINT32_C(1)<<0)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "PERM_OTHER_X"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "PERM_OTHER_X"); empty = false; } if (empty) - fmt_state_putchar(state, '0'); - fmt_state_putchar(state, ')'); + fmt_print_byte(w, '0'); + fmt_print_byte(w, ')'); } -static void lib9p_b4_format(lib9p_b4_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_b4(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_b4_t *self) { switch (*self) { case LIB9P_B4_FALSE: - fmt_state_puts(state, "FALSE"); + fmt_print_str(w, "FALSE"); break; case LIB9P_B4_TRUE: - fmt_state_puts(state, "TRUE"); + fmt_print_str(w, "TRUE"); break; default: - fmt_state_printf(state, "%"PRIu32, *self); + fmt_print_base10(w, *self); } } -static void lib9p_getattr_format(lib9p_getattr_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_getattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_getattr_t *self) { bool empty = true; - fmt_state_putchar(state, '('); + fmt_print_byte(w, '('); if (*self & (UINT64_C(1)<<63)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<63"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<63"); empty = false; } if (*self & (UINT64_C(1)<<62)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<62"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<62"); empty = false; } if (*self & (UINT64_C(1)<<61)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<61"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<61"); empty = false; } if (*self & (UINT64_C(1)<<60)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<60"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<60"); empty = false; } if (*self & (UINT64_C(1)<<59)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<59"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<59"); empty = false; } if (*self & (UINT64_C(1)<<58)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<58"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<58"); empty = false; } if (*self & (UINT64_C(1)<<57)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<57"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<57"); empty = false; } if (*self & (UINT64_C(1)<<56)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<56"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<56"); empty = false; } if (*self & (UINT64_C(1)<<55)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<55"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<55"); empty = false; } if (*self & (UINT64_C(1)<<54)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<54"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<54"); empty = false; } if (*self & (UINT64_C(1)<<53)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<53"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<53"); empty = false; } if (*self & (UINT64_C(1)<<52)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<52"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<52"); empty = false; } if (*self & (UINT64_C(1)<<51)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<51"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<51"); empty = false; } if (*self & (UINT64_C(1)<<50)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<50"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<50"); empty = false; } if (*self & (UINT64_C(1)<<49)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<49"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<49"); empty = false; } if (*self & (UINT64_C(1)<<48)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<48"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<48"); empty = false; } if (*self & (UINT64_C(1)<<47)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<47"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<47"); empty = false; } if (*self & (UINT64_C(1)<<46)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<46"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<46"); empty = false; } if (*self & (UINT64_C(1)<<45)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<45"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<45"); empty = false; } if (*self & (UINT64_C(1)<<44)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<44"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<44"); empty = false; } if (*self & (UINT64_C(1)<<43)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<43"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<43"); empty = false; } if (*self & (UINT64_C(1)<<42)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<42"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<42"); empty = false; } if (*self & (UINT64_C(1)<<41)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<41"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<41"); empty = false; } if (*self & (UINT64_C(1)<<40)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<40"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<40"); empty = false; } if (*self & (UINT64_C(1)<<39)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<39"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<39"); empty = false; } if (*self & (UINT64_C(1)<<38)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<38"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<38"); empty = false; } if (*self & (UINT64_C(1)<<37)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<37"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<37"); empty = false; } if (*self & (UINT64_C(1)<<36)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<36"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<36"); empty = false; } if (*self & (UINT64_C(1)<<35)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<35"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<35"); empty = false; } if (*self & (UINT64_C(1)<<34)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<34"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<34"); empty = false; } if (*self & (UINT64_C(1)<<33)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<33"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<33"); empty = false; } if (*self & (UINT64_C(1)<<32)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<32"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<32"); empty = false; } if (*self & (UINT64_C(1)<<31)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<31"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<31"); empty = false; } if (*self & (UINT64_C(1)<<30)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<30"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<30"); empty = false; } if (*self & (UINT64_C(1)<<29)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<29"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<29"); empty = false; } if (*self & (UINT64_C(1)<<28)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<28"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<28"); empty = false; } if (*self & (UINT64_C(1)<<27)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<27"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<27"); empty = false; } if (*self & (UINT64_C(1)<<26)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<26"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<26"); empty = false; } if (*self & (UINT64_C(1)<<25)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<25"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<25"); empty = false; } if (*self & (UINT64_C(1)<<24)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<24"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<24"); empty = false; } if (*self & (UINT64_C(1)<<23)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<23"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<23"); empty = false; } if (*self & (UINT64_C(1)<<22)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<22"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<22"); empty = false; } if (*self & (UINT64_C(1)<<21)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<21"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<21"); empty = false; } if (*self & (UINT64_C(1)<<20)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<20"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<20"); empty = false; } if (*self & (UINT64_C(1)<<19)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<19"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<19"); empty = false; } if (*self & (UINT64_C(1)<<18)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<18"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<18"); empty = false; } if (*self & (UINT64_C(1)<<17)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<17"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<17"); empty = false; } if (*self & (UINT64_C(1)<<16)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<16"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<16"); empty = false; } if (*self & (UINT64_C(1)<<15)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<15"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<15"); empty = false; } if (*self & (UINT64_C(1)<<14)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<14"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<14"); empty = false; } if (*self & (UINT64_C(1)<<13)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "DATA_VERSION"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "DATA_VERSION"); empty = false; } if (*self & (UINT64_C(1)<<12)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "GEN"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "GEN"); empty = false; } if (*self & (UINT64_C(1)<<11)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "BTIME"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "BTIME"); empty = false; } if (*self & (UINT64_C(1)<<10)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "BLOCKS"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "BLOCKS"); empty = false; } if (*self & (UINT64_C(1)<<9)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "SIZE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "SIZE"); empty = false; } if (*self & (UINT64_C(1)<<8)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "INO"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "INO"); empty = false; } if (*self & (UINT64_C(1)<<7)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "CTIME"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "CTIME"); empty = false; } if (*self & (UINT64_C(1)<<6)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MTIME"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MTIME"); empty = false; } if (*self & (UINT64_C(1)<<5)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "ATIME"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "ATIME"); empty = false; } if (*self & (UINT64_C(1)<<4)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "RDEV"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "RDEV"); empty = false; } if (*self & (UINT64_C(1)<<3)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "GID"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "GID"); empty = false; } if (*self & (UINT64_C(1)<<2)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "UID"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "UID"); empty = false; } if (*self & (UINT64_C(1)<<1)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "NLINK"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "NLINK"); empty = false; } if (*self & (UINT64_C(1)<<0)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE"); empty = false; } if (empty) - fmt_state_putchar(state, '0'); - fmt_state_putchar(state, ')'); + fmt_print_byte(w, '0'); + fmt_print_byte(w, ')'); } -static void lib9p_setattr_format(lib9p_setattr_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_setattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_setattr_t *self) { bool empty = true; - fmt_state_putchar(state, '('); + fmt_print_byte(w, '('); if (*self & (UINT32_C(1)<<31)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<31"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<31"); empty = false; } if (*self & (UINT32_C(1)<<30)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<30"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<30"); empty = false; } if (*self & (UINT32_C(1)<<29)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<29"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<29"); empty = false; } if (*self & (UINT32_C(1)<<28)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<28"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<28"); empty = false; } if (*self & (UINT32_C(1)<<27)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<27"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<27"); empty = false; } if (*self & (UINT32_C(1)<<26)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<26"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<26"); empty = false; } if (*self & (UINT32_C(1)<<25)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<25"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<25"); empty = false; } if (*self & (UINT32_C(1)<<24)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<24"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<24"); empty = false; } if (*self & (UINT32_C(1)<<23)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<23"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<23"); empty = false; } if (*self & (UINT32_C(1)<<22)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<22"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<22"); empty = false; } if (*self & (UINT32_C(1)<<21)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<21"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<21"); empty = false; } if (*self & (UINT32_C(1)<<20)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<20"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<20"); empty = false; } if (*self & (UINT32_C(1)<<19)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<19"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<19"); empty = false; } if (*self & (UINT32_C(1)<<18)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<18"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<18"); empty = false; } if (*self & (UINT32_C(1)<<17)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<17"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<17"); empty = false; } if (*self & (UINT32_C(1)<<16)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<16"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<16"); empty = false; } if (*self & (UINT32_C(1)<<15)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<15"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<15"); empty = false; } if (*self & (UINT32_C(1)<<14)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<14"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<14"); empty = false; } if (*self & (UINT32_C(1)<<13)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<13"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<13"); empty = false; } if (*self & (UINT32_C(1)<<12)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<12"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<12"); empty = false; } if (*self & (UINT32_C(1)<<11)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<11"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<11"); empty = false; } if (*self & (UINT32_C(1)<<10)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<10"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<10"); empty = false; } if (*self & (UINT32_C(1)<<9)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<9"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<9"); empty = false; } if (*self & (UINT32_C(1)<<8)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MTIME_SET"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MTIME_SET"); empty = false; } if (*self & (UINT32_C(1)<<7)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "ATIME_SET"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "ATIME_SET"); empty = false; } if (*self & (UINT32_C(1)<<6)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "CTIME"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "CTIME"); empty = false; } if (*self & (UINT32_C(1)<<5)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MTIME"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MTIME"); empty = false; } if (*self & (UINT32_C(1)<<4)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "ATIME"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "ATIME"); empty = false; } if (*self & (UINT32_C(1)<<3)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "SIZE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "SIZE"); empty = false; } if (*self & (UINT32_C(1)<<2)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "GID"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "GID"); empty = false; } if (*self & (UINT32_C(1)<<1)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "UID"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "UID"); empty = false; } if (*self & (UINT32_C(1)<<0)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "MODE"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "MODE"); empty = false; } if (empty) - fmt_state_putchar(state, '0'); - fmt_state_putchar(state, ')'); + fmt_print_byte(w, '0'); + fmt_print_byte(w, ')'); } -static void lib9p_lock_type_format(lib9p_lock_type_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_lock_type(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_lock_type_t *self) { switch (*self) { case LIB9P_LOCK_TYPE_RDLCK: - fmt_state_puts(state, "RDLCK"); + fmt_print_str(w, "RDLCK"); break; case LIB9P_LOCK_TYPE_WRLCK: - fmt_state_puts(state, "WRLCK"); + fmt_print_str(w, "WRLCK"); break; case LIB9P_LOCK_TYPE_UNLCK: - fmt_state_puts(state, "UNLCK"); + fmt_print_str(w, "UNLCK"); break; default: - fmt_state_printf(state, "%"PRIu8, *self); + fmt_print_base10(w, *self); } } -static void lib9p_lock_flags_format(lib9p_lock_flags_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_lock_flags(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_lock_flags_t *self) { bool empty = true; - fmt_state_putchar(state, '('); + fmt_print_byte(w, '('); if (*self & (UINT32_C(1)<<31)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<31"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<31"); empty = false; } if (*self & (UINT32_C(1)<<30)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<30"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<30"); empty = false; } if (*self & (UINT32_C(1)<<29)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<29"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<29"); empty = false; } if (*self & (UINT32_C(1)<<28)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<28"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<28"); empty = false; } if (*self & (UINT32_C(1)<<27)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<27"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<27"); empty = false; } if (*self & (UINT32_C(1)<<26)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<26"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<26"); empty = false; } if (*self & (UINT32_C(1)<<25)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<25"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<25"); empty = false; } if (*self & (UINT32_C(1)<<24)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<24"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<24"); empty = false; } if (*self & (UINT32_C(1)<<23)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<23"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<23"); empty = false; } if (*self & (UINT32_C(1)<<22)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<22"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<22"); empty = false; } if (*self & (UINT32_C(1)<<21)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<21"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<21"); empty = false; } if (*self & (UINT32_C(1)<<20)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<20"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<20"); empty = false; } if (*self & (UINT32_C(1)<<19)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<19"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<19"); empty = false; } if (*self & (UINT32_C(1)<<18)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<18"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<18"); empty = false; } if (*self & (UINT32_C(1)<<17)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<17"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<17"); empty = false; } if (*self & (UINT32_C(1)<<16)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<16"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<16"); empty = false; } if (*self & (UINT32_C(1)<<15)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<15"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<15"); empty = false; } if (*self & (UINT32_C(1)<<14)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<14"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<14"); empty = false; } if (*self & (UINT32_C(1)<<13)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<13"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<13"); empty = false; } if (*self & (UINT32_C(1)<<12)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<12"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<12"); empty = false; } if (*self & (UINT32_C(1)<<11)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<11"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<11"); empty = false; } if (*self & (UINT32_C(1)<<10)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<10"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<10"); empty = false; } if (*self & (UINT32_C(1)<<9)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<9"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<9"); empty = false; } if (*self & (UINT32_C(1)<<8)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<8"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<8"); empty = false; } if (*self & (UINT32_C(1)<<7)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<7"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<7"); empty = false; } if (*self & (UINT32_C(1)<<6)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<6"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<6"); empty = false; } if (*self & (UINT32_C(1)<<5)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<5"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<5"); empty = false; } if (*self & (UINT32_C(1)<<4)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<4"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<4"); empty = false; } if (*self & (UINT32_C(1)<<3)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<3"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<3"); empty = false; } if (*self & (UINT32_C(1)<<2)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "1<<2"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "1<<2"); empty = false; } if (*self & (UINT32_C(1)<<1)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "RECLAIM"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "RECLAIM"); empty = false; } if (*self & (UINT32_C(1)<<0)) { if (!empty) - fmt_state_putchar(state, '|'); - fmt_state_puts(state, "BLOCK"); + fmt_print_byte(w, '|'); + fmt_print_str(w, "BLOCK"); empty = false; } if (empty) - fmt_state_putchar(state, '0'); - fmt_state_putchar(state, ')'); + fmt_print_byte(w, '0'); + fmt_print_byte(w, ')'); } -static void lib9p_lock_status_format(lib9p_lock_status_t *self, struct fmt_state *state) { +[[maybe_unused]] static void fmt_print_lock_status(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_lock_status_t *self) { switch (*self) { case LIB9P_LOCK_STATUS_SUCCESS: - fmt_state_puts(state, "SUCCESS"); + fmt_print_str(w, "SUCCESS"); break; case LIB9P_LOCK_STATUS_BLOCKED: - fmt_state_puts(state, "BLOCKED"); + fmt_print_str(w, "BLOCKED"); break; case LIB9P_LOCK_STATUS_ERROR: - fmt_state_puts(state, "ERROR"); + fmt_print_str(w, "ERROR"); break; case LIB9P_LOCK_STATUS_GRACE: - fmt_state_puts(state, "GRACE"); + fmt_print_str(w, "GRACE"); break; default: - fmt_state_printf(state, "%"PRIu8, *self); - } -} - -static void lib9p_msg_Rlerror_format(struct lib9p_msg_Rlerror *self, struct fmt_state *state) { - fmt_state_puts(state, "Rlerror {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " errnum="); - lib9p_errno_format(&self->errnum, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tstatfs_format(struct lib9p_msg_Tstatfs *self, struct fmt_state *state) { - fmt_state_puts(state, "Tstatfs {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rstatfs_format(struct lib9p_msg_Rstatfs *self, struct fmt_state *state) { - fmt_state_puts(state, "Rstatfs {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " type="); - lib9p_super_magic_format(&self->type, state); - fmt_state_puts(state, " bsize="); - fmt_state_printf(state, "%"PRIu32, self->bsize); - fmt_state_puts(state, " blocks="); - fmt_state_printf(state, "%"PRIu64, self->blocks); - fmt_state_puts(state, " bfree="); - fmt_state_printf(state, "%"PRIu64, self->bfree); - fmt_state_puts(state, " bavail="); - fmt_state_printf(state, "%"PRIu64, self->bavail); - fmt_state_puts(state, " files="); - fmt_state_printf(state, "%"PRIu64, self->files); - fmt_state_puts(state, " ffree="); - fmt_state_printf(state, "%"PRIu64, self->ffree); - fmt_state_puts(state, " fsid="); - fmt_state_printf(state, "%"PRIu64, self->fsid); - fmt_state_puts(state, " namelen="); - fmt_state_printf(state, "%"PRIu32, self->namelen); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tlopen_format(struct lib9p_msg_Tlopen *self, struct fmt_state *state) { - fmt_state_puts(state, "Tlopen {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " flags="); - lib9p_lo_format(&self->flags, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rlopen_format(struct lib9p_msg_Rlopen *self, struct fmt_state *state) { - fmt_state_puts(state, "Rlopen {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " iounit="); - fmt_state_printf(state, "%"PRIu32, self->iounit); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tlcreate_format(struct lib9p_msg_Tlcreate *self, struct fmt_state *state) { - fmt_state_puts(state, "Tlcreate {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " flags="); - lib9p_lo_format(&self->flags, state); - fmt_state_puts(state, " mode="); - lib9p_mode_format(&self->mode, state); - fmt_state_puts(state, " gid="); - lib9p_nuid_format(&self->gid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rlcreate_format(struct lib9p_msg_Rlcreate *self, struct fmt_state *state) { - fmt_state_puts(state, "Rlcreate {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " iounit="); - fmt_state_printf(state, "%"PRIu32, self->iounit); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tsymlink_format(struct lib9p_msg_Tsymlink *self, struct fmt_state *state) { - fmt_state_puts(state, "Tsymlink {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " symtgt="); - lib9p_s_format(&self->symtgt, state); - fmt_state_puts(state, " gid="); - lib9p_nuid_format(&self->gid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rsymlink_format(struct lib9p_msg_Rsymlink *self, struct fmt_state *state) { - fmt_state_puts(state, "Rsymlink {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tmknod_format(struct lib9p_msg_Tmknod *self, struct fmt_state *state) { - fmt_state_puts(state, "Tmknod {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " dfid="); - lib9p_fid_format(&self->dfid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " mode="); - lib9p_mode_format(&self->mode, state); - fmt_state_puts(state, " major="); - fmt_state_printf(state, "%"PRIu32, self->major); - fmt_state_puts(state, " minor="); - fmt_state_printf(state, "%"PRIu32, self->minor); - fmt_state_puts(state, " gid="); - lib9p_nuid_format(&self->gid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rmknod_format(struct lib9p_msg_Rmknod *self, struct fmt_state *state) { - fmt_state_puts(state, "Rmknod {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Trename_format(struct lib9p_msg_Trename *self, struct fmt_state *state) { - fmt_state_puts(state, "Trename {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " dfid="); - lib9p_fid_format(&self->dfid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rrename_format(struct lib9p_msg_Rrename *self, struct fmt_state *state) { - fmt_state_puts(state, "Rrename {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Treadlink_format(struct lib9p_msg_Treadlink *self, struct fmt_state *state) { - fmt_state_puts(state, "Treadlink {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rreadlink_format(struct lib9p_msg_Rreadlink *self, struct fmt_state *state) { - fmt_state_puts(state, "Rreadlink {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " target="); - lib9p_s_format(&self->target, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tgetattr_format(struct lib9p_msg_Tgetattr *self, struct fmt_state *state) { - fmt_state_puts(state, "Tgetattr {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " request_mask="); - lib9p_getattr_format(&self->request_mask, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rgetattr_format(struct lib9p_msg_Rgetattr *self, struct fmt_state *state) { - fmt_state_puts(state, "Rgetattr {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " valid="); - lib9p_getattr_format(&self->valid, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " mode="); - lib9p_mode_format(&self->mode, state); - fmt_state_puts(state, " uid="); - lib9p_nuid_format(&self->uid, state); - fmt_state_puts(state, " gid="); - lib9p_nuid_format(&self->gid, state); - fmt_state_puts(state, " nlink="); - fmt_state_printf(state, "%"PRIu64, self->nlink); - fmt_state_puts(state, " rdev="); - fmt_state_printf(state, "%"PRIu64, self->rdev); - fmt_state_puts(state, " filesize="); - fmt_state_printf(state, "%"PRIu64, self->filesize); - fmt_state_puts(state, " blksize="); - fmt_state_printf(state, "%"PRIu64, self->blksize); - fmt_state_puts(state, " blocks="); - fmt_state_printf(state, "%"PRIu64, self->blocks); - fmt_state_puts(state, " atime_sec="); - fmt_state_printf(state, "%"PRIu64, self->atime_sec); - fmt_state_puts(state, " atime_nsec="); - fmt_state_printf(state, "%"PRIu64, self->atime_nsec); - fmt_state_puts(state, " mtime_sec="); - fmt_state_printf(state, "%"PRIu64, self->mtime_sec); - fmt_state_puts(state, " mtime_nsec="); - fmt_state_printf(state, "%"PRIu64, self->mtime_nsec); - fmt_state_puts(state, " ctime_sec="); - fmt_state_printf(state, "%"PRIu64, self->ctime_sec); - fmt_state_puts(state, " ctime_nsec="); - fmt_state_printf(state, "%"PRIu64, self->ctime_nsec); - fmt_state_puts(state, " btime_sec="); - fmt_state_printf(state, "%"PRIu64, self->btime_sec); - fmt_state_puts(state, " btime_nsec="); - fmt_state_printf(state, "%"PRIu64, self->btime_nsec); - fmt_state_puts(state, " gen="); - fmt_state_printf(state, "%"PRIu64, self->gen); - fmt_state_puts(state, " data_version="); - fmt_state_printf(state, "%"PRIu64, self->data_version); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tsetattr_format(struct lib9p_msg_Tsetattr *self, struct fmt_state *state) { - fmt_state_puts(state, "Tsetattr {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " valid="); - lib9p_setattr_format(&self->valid, state); - fmt_state_puts(state, " mode="); - lib9p_mode_format(&self->mode, state); - fmt_state_puts(state, " uid="); - lib9p_nuid_format(&self->uid, state); - fmt_state_puts(state, " gid="); - lib9p_nuid_format(&self->gid, state); - fmt_state_puts(state, " filesize="); - fmt_state_printf(state, "%"PRIu64, self->filesize); - fmt_state_puts(state, " atime_sec="); - fmt_state_printf(state, "%"PRIu64, self->atime_sec); - fmt_state_puts(state, " atime_nsec="); - fmt_state_printf(state, "%"PRIu64, self->atime_nsec); - fmt_state_puts(state, " mtime_sec="); - fmt_state_printf(state, "%"PRIu64, self->mtime_sec); - fmt_state_puts(state, " mtime_nsec="); - fmt_state_printf(state, "%"PRIu64, self->mtime_nsec); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rsetattr_format(struct lib9p_msg_Rsetattr *self, struct fmt_state *state) { - fmt_state_puts(state, "Rsetattr {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Txattrwalk_format(struct lib9p_msg_Txattrwalk *self, struct fmt_state *state) { - fmt_state_puts(state, "Txattrwalk {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " newfid="); - lib9p_fid_format(&self->newfid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rxattrwalk_format(struct lib9p_msg_Rxattrwalk *self, struct fmt_state *state) { - fmt_state_puts(state, "Rxattrwalk {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " attr_size="); - fmt_state_printf(state, "%"PRIu64, self->attr_size); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Txattrcreate_format(struct lib9p_msg_Txattrcreate *self, struct fmt_state *state) { - fmt_state_puts(state, "Txattrcreate {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " attr_size="); - fmt_state_printf(state, "%"PRIu64, self->attr_size); - fmt_state_puts(state, " flags="); - fmt_state_printf(state, "%"PRIu32, self->flags); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rxattrcreate_format(struct lib9p_msg_Rxattrcreate *self, struct fmt_state *state) { - fmt_state_puts(state, "Rxattrcreate {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Treaddir_format(struct lib9p_msg_Treaddir *self, struct fmt_state *state) { - fmt_state_puts(state, "Treaddir {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " offset="); - fmt_state_printf(state, "%"PRIu64, self->offset); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rreaddir_format(struct lib9p_msg_Rreaddir *self, struct fmt_state *state) { - fmt_state_puts(state, "Rreaddir {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); + fmt_print_base10(w, *self); + } +} + +#endif /* CONFIG_9P_ENABLE_9P2000_L */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized +[[maybe_unused]] static void fmt_print_s(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_s *self) { + fmt_print_qmem(w, self->utf8, self->len); +} + +[[maybe_unused]] static void fmt_print_qid(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_qid *self) { + fmt_print_byte(w, '{'); + fmt_print_str(w, " type="); + fmt_print_qt(w, ctx, &self->type); + fmt_print_str(w, " vers="); + fmt_print_base10(w, self->vers); + fmt_print_str(w, " path="); + fmt_print_base10(w, self->path); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] static void fmt_print_Tflush(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *self) { + fmt_print_str(w, "Tflush {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " oldtag="); + fmt_print_base10(w, self->oldtag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rflush(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *self) { + fmt_print_str(w, "Rflush {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] static void fmt_print_Topen(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Topen *self) { + fmt_print_str(w, "Topen {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " mode="); + fmt_print_o(w, ctx, &self->mode); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] static void fmt_print_Tread(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tread *self) { + fmt_print_str(w, "Tread {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " offset="); + fmt_print_base10(w, self->offset); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rread(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rread *self) { + fmt_print_str(w, "Rread {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); + if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) { + fmt_print_str(w, " data="); + fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50); + if (self->count > 50) + fmt_print_str(w, "..."); + } else { + fmt_print_str(w, " data=<bytedata>"); + } + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Twrite(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *self) { + fmt_print_str(w, "Twrite {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " offset="); + fmt_print_base10(w, self->offset); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); + if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) { + fmt_print_str(w, " data="); + fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50); + if (self->count > 50) + fmt_print_str(w, "..."); + } else { + fmt_print_str(w, " data=<bytedata>"); + } + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rwrite(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *self) { + fmt_print_str(w, "Rwrite {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tclunk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *self) { + fmt_print_str(w, "Tclunk {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rclunk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *self) { + fmt_print_str(w, "Rclunk {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tremove(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *self) { + fmt_print_str(w, "Tremove {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rremove(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *self) { + fmt_print_str(w, "Rremove {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] static void fmt_print_Tstat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *self) { + fmt_print_str(w, "Tstat {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rwstat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *self) { + fmt_print_str(w, "Rwstat {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_p9p +[[maybe_unused]] static void fmt_print_Topenfd(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *self) { + fmt_print_str(w, "Topenfd {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " mode="); + fmt_print_o(w, ctx, &self->mode); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ +#if CONFIG_9P_ENABLE_9P2000_L +[[maybe_unused]] static void fmt_print_Rlerror(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *self) { + fmt_print_str(w, "Rlerror {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " errnum="); + fmt_print_errno(w, ctx, &self->errnum); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tstatfs(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *self) { + fmt_print_str(w, "Tstatfs {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rstatfs(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *self) { + fmt_print_str(w, "Rstatfs {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " type="); + fmt_print_super_magic(w, ctx, &self->type); + fmt_print_str(w, " bsize="); + fmt_print_base10(w, self->bsize); + fmt_print_str(w, " blocks="); + fmt_print_base10(w, self->blocks); + fmt_print_str(w, " bfree="); + fmt_print_base10(w, self->bfree); + fmt_print_str(w, " bavail="); + fmt_print_base10(w, self->bavail); + fmt_print_str(w, " files="); + fmt_print_base10(w, self->files); + fmt_print_str(w, " ffree="); + fmt_print_base10(w, self->ffree); + fmt_print_str(w, " fsid="); + fmt_print_base10(w, self->fsid); + fmt_print_str(w, " namelen="); + fmt_print_base10(w, self->namelen); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tlopen(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *self) { + fmt_print_str(w, "Tlopen {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " flags="); + fmt_print_lo(w, ctx, &self->flags); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rrename(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *self) { + fmt_print_str(w, "Rrename {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Treadlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink *self) { + fmt_print_str(w, "Treadlink {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tgetattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *self) { + fmt_print_str(w, "Tgetattr {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " request_mask="); + fmt_print_getattr(w, ctx, &self->request_mask); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tsetattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *self) { + fmt_print_str(w, "Tsetattr {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " valid="); + fmt_print_setattr(w, ctx, &self->valid); + fmt_print_str(w, " mode="); + fmt_print_mode(w, ctx, &self->mode); + fmt_print_str(w, " uid="); + fmt_print_nuid(w, ctx, &self->uid); + fmt_print_str(w, " gid="); + fmt_print_nuid(w, ctx, &self->gid); + fmt_print_str(w, " filesize="); + fmt_print_base10(w, self->filesize); + fmt_print_str(w, " atime_sec="); + fmt_print_base10(w, self->atime_sec); + fmt_print_str(w, " atime_nsec="); + fmt_print_base10(w, self->atime_nsec); + fmt_print_str(w, " mtime_sec="); + fmt_print_base10(w, self->mtime_sec); + fmt_print_str(w, " mtime_nsec="); + fmt_print_base10(w, self->mtime_nsec); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rsetattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *self) { + fmt_print_str(w, "Rsetattr {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rxattrwalk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwalk *self) { + fmt_print_str(w, "Rxattrwalk {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " attr_size="); + fmt_print_base10(w, self->attr_size); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rxattrcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrcreate *self) { + fmt_print_str(w, "Rxattrcreate {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Treaddir(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *self) { + fmt_print_str(w, "Treaddir {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " offset="); + fmt_print_base10(w, self->offset); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rreaddir(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *self) { + fmt_print_str(w, "Rreaddir {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat" -#pragma GCC diagnostic ignored "-Wformat-extra-args" - fmt_state_printf(state, " data=%.*q%s", - (int)(self->count < 50 ? self->count : 50), - (char *)self->data, - self->count < 50 ? "" : "..."); -#pragma GCC diagnostic pop + fmt_print_str(w, " data="); + fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50); + if (self->count > 50) + fmt_print_str(w, "..."); } else { - fmt_state_puts(state, " data=<bytedata>"); - } - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tfsync_format(struct lib9p_msg_Tfsync *self, struct fmt_state *state) { - fmt_state_puts(state, "Tfsync {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " datasync="); - lib9p_b4_format(&self->datasync, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rfsync_format(struct lib9p_msg_Rfsync *self, struct fmt_state *state) { - fmt_state_puts(state, "Rfsync {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tlock_format(struct lib9p_msg_Tlock *self, struct fmt_state *state) { - fmt_state_puts(state, "Tlock {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " type="); - lib9p_lock_type_format(&self->type, state); - fmt_state_puts(state, " flags="); - lib9p_lock_flags_format(&self->flags, state); - fmt_state_puts(state, " start="); - fmt_state_printf(state, "%"PRIu64, self->start); - fmt_state_puts(state, " length="); - fmt_state_printf(state, "%"PRIu64, self->length); - fmt_state_puts(state, " proc_id="); - fmt_state_printf(state, "%"PRIu32, self->proc_id); - fmt_state_puts(state, " client_id="); - lib9p_s_format(&self->client_id, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rlock_format(struct lib9p_msg_Rlock *self, struct fmt_state *state) { - fmt_state_puts(state, "Rlock {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " status="); - lib9p_lock_status_format(&self->status, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tgetlock_format(struct lib9p_msg_Tgetlock *self, struct fmt_state *state) { - fmt_state_puts(state, "Tgetlock {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " type="); - lib9p_lock_type_format(&self->type, state); - fmt_state_puts(state, " start="); - fmt_state_printf(state, "%"PRIu64, self->start); - fmt_state_puts(state, " length="); - fmt_state_printf(state, "%"PRIu64, self->length); - fmt_state_puts(state, " proc_id="); - fmt_state_printf(state, "%"PRIu32, self->proc_id); - fmt_state_puts(state, " client_id="); - lib9p_s_format(&self->client_id, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rgetlock_format(struct lib9p_msg_Rgetlock *self, struct fmt_state *state) { - fmt_state_puts(state, "Rgetlock {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " type="); - lib9p_lock_type_format(&self->type, state); - fmt_state_puts(state, " start="); - fmt_state_printf(state, "%"PRIu64, self->start); - fmt_state_puts(state, " length="); - fmt_state_printf(state, "%"PRIu64, self->length); - fmt_state_puts(state, " proc_id="); - fmt_state_printf(state, "%"PRIu32, self->proc_id); - fmt_state_puts(state, " client_id="); - lib9p_s_format(&self->client_id, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tlink_format(struct lib9p_msg_Tlink *self, struct fmt_state *state) { - fmt_state_puts(state, "Tlink {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " dfid="); - lib9p_fid_format(&self->dfid, state); - fmt_state_puts(state, " fid="); - lib9p_fid_format(&self->fid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rlink_format(struct lib9p_msg_Rlink *self, struct fmt_state *state) { - fmt_state_puts(state, "Rlink {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tmkdir_format(struct lib9p_msg_Tmkdir *self, struct fmt_state *state) { - fmt_state_puts(state, "Tmkdir {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " dfid="); - lib9p_fid_format(&self->dfid, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " mode="); - lib9p_mode_format(&self->mode, state); - fmt_state_puts(state, " gid="); - lib9p_nuid_format(&self->gid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rmkdir_format(struct lib9p_msg_Rmkdir *self, struct fmt_state *state) { - fmt_state_puts(state, "Rmkdir {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " qid="); - lib9p_qid_format(&self->qid, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Trenameat_format(struct lib9p_msg_Trenameat *self, struct fmt_state *state) { - fmt_state_puts(state, "Trenameat {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " olddirfid="); - lib9p_fid_format(&self->olddirfid, state); - fmt_state_puts(state, " oldname="); - lib9p_s_format(&self->oldname, state); - fmt_state_puts(state, " newdirfid="); - lib9p_fid_format(&self->newdirfid, state); - fmt_state_puts(state, " newname="); - lib9p_s_format(&self->newname, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rrenameat_format(struct lib9p_msg_Rrenameat *self, struct fmt_state *state) { - fmt_state_puts(state, "Rrenameat {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tunlinkat_format(struct lib9p_msg_Tunlinkat *self, struct fmt_state *state) { - fmt_state_puts(state, "Tunlinkat {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " dirfd="); - lib9p_fid_format(&self->dirfd, state); - fmt_state_puts(state, " name="); - lib9p_s_format(&self->name, state); - fmt_state_puts(state, " flags="); - fmt_state_printf(state, "%"PRIu32, self->flags); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Runlinkat_format(struct lib9p_msg_Runlinkat *self, struct fmt_state *state) { - fmt_state_puts(state, "Runlinkat {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); + fmt_print_str(w, " data=<bytedata>"); + } + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tfsync(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *self) { + fmt_print_str(w, "Tfsync {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " datasync="); + fmt_print_b4(w, ctx, &self->datasync); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rfsync(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *self) { + fmt_print_str(w, "Rfsync {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rlock(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *self) { + fmt_print_str(w, "Rlock {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " status="); + fmt_print_lock_status(w, ctx, &self->status); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *self) { + fmt_print_str(w, "Rlink {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rrenameat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat *self) { + fmt_print_str(w, "Rrenameat {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Runlinkat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat *self) { + fmt_print_str(w, "Runlinkat {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); } #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000_e -static void lib9p_msg_Tsession_format(struct lib9p_msg_Tsession *self, struct fmt_state *state) { - fmt_state_puts(state, "Tsession {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " key="); - fmt_state_printf(state, "%"PRIu64, self->key); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Rsession_format(struct lib9p_msg_Rsession *self, struct fmt_state *state) { - fmt_state_puts(state, "Rsession {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " }"); -} - -static void lib9p_msg_Tsread_format(struct lib9p_msg_Tsread *self, struct fmt_state *state) { - fmt_state_puts(state, "Tsread {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - fmt_state_printf(state, "%"PRIu32, self->fid); - fmt_state_puts(state, " nwname="); - fmt_state_printf(state, "%"PRIu16, self->nwname); - fmt_state_puts(state, " wname=["); +[[maybe_unused]] static void fmt_print_Tsession(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *self) { + fmt_print_str(w, "Tsession {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " key="); + fmt_print_base10(w, self->key); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rsession(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *self) { + fmt_print_str(w, "Rsession {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rsread(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *self) { + fmt_print_str(w, "Rsread {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); + if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) { + fmt_print_str(w, " data="); + fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50); + if (self->count > 50) + fmt_print_str(w, "..."); + } else { + fmt_print_str(w, " data=<bytedata>"); + } + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rswrite(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *self) { + fmt_print_str(w, "Rswrite {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] void fmt_print_stat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_stat *self) { + fmt_print_byte(w, '{'); + fmt_print_str(w, " fstype="); + fmt_print_base10(w, self->fstype); + fmt_print_str(w, " fsdev="); + fmt_print_base10(w, self->fsdev); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " mode="); + fmt_print_dm(w, ctx, &self->mode); + fmt_print_str(w, " atime="); + fmt_print_base10(w, self->atime); + fmt_print_str(w, " mtime="); + fmt_print_base10(w, self->mtime); + fmt_print_str(w, " length="); + fmt_print_base10(w, self->length); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " owner_uname="); + fmt_print_s(w, ctx, &self->owner_uname); + fmt_print_str(w, " owner_gname="); + fmt_print_s(w, ctx, &self->owner_gname); + fmt_print_str(w, " last_modifier_uname="); + fmt_print_s(w, ctx, &self->last_modifier_uname); +#if CONFIG_9P_ENABLE_9P2000_u + fmt_print_str(w, " extension="); + fmt_print_s(w, ctx, &self->extension); + fmt_print_str(w, " owner_unum="); + fmt_print_nuid(w, ctx, &self->owner_unum); + fmt_print_str(w, " owner_gnum="); + fmt_print_nuid(w, ctx, &self->owner_gnum); + fmt_print_str(w, " last_modifier_unum="); + fmt_print_nuid(w, ctx, &self->last_modifier_unum); +#endif /* CONFIG_9P_ENABLE_9P2000_u */ + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized +[[maybe_unused]] static void fmt_print_Tversion(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *self) { + fmt_print_str(w, "Tversion {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " max_msg_size="); + fmt_print_base10(w, self->max_msg_size); + fmt_print_str(w, " version="); + fmt_print_s(w, ctx, &self->version); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rversion(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *self) { + fmt_print_str(w, "Rversion {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " max_msg_size="); + fmt_print_base10(w, self->max_msg_size); + fmt_print_str(w, " version="); + fmt_print_s(w, ctx, &self->version); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] static void fmt_print_Tauth(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *self) { + fmt_print_str(w, "Tauth {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " afid="); + fmt_print_fid(w, ctx, &self->afid); + fmt_print_str(w, " uname="); + fmt_print_s(w, ctx, &self->uname); + fmt_print_str(w, " aname="); + fmt_print_s(w, ctx, &self->aname); +#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u + fmt_print_str(w, " unum="); + fmt_print_nuid(w, ctx, &self->unum); +#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rauth(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *self) { + fmt_print_str(w, "Rauth {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " aqid="); + fmt_print_qid(w, ctx, &self->aqid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tattach(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *self) { + fmt_print_str(w, "Tattach {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " afid="); + fmt_print_fid(w, ctx, &self->afid); + fmt_print_str(w, " uname="); + fmt_print_s(w, ctx, &self->uname); + fmt_print_str(w, " aname="); + fmt_print_s(w, ctx, &self->aname); +#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u + fmt_print_str(w, " unum="); + fmt_print_nuid(w, ctx, &self->unum); +#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rattach(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *self) { + fmt_print_str(w, "Rattach {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized +[[maybe_unused]] static void fmt_print_Rerror(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *self) { + fmt_print_str(w, "Rerror {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " errstr="); + fmt_print_s(w, ctx, &self->errstr); +#if CONFIG_9P_ENABLE_9P2000_u + fmt_print_str(w, " errnum="); + fmt_print_errno(w, ctx, &self->errnum); +#endif /* CONFIG_9P_ENABLE_9P2000_u */ + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] static void fmt_print_Twalk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *self) { + fmt_print_str(w, "Twalk {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " newfid="); + fmt_print_fid(w, ctx, &self->newfid); + fmt_print_str(w, " nwname="); + fmt_print_base10(w, self->nwname); + fmt_print_str(w, " wname=["); for (uint16_t i = 0; i < self->nwname; i++) { if (i) - fmt_state_putchar(state, ','); - fmt_state_putchar(state, ' '); - lib9p_s_format(&self->wname[i], state); + fmt_print_byte(w, ','); + fmt_print_byte(w, ' '); + fmt_print_s(w, ctx, &self->wname[i]); } - fmt_state_puts(state, " ]"); - fmt_state_puts(state, " }"); + fmt_print_str(w, " ]"); + fmt_print_str(w, " }"); } -static void lib9p_msg_Rsread_format(struct lib9p_msg_Rsread *self, struct fmt_state *state) { - fmt_state_puts(state, "Rsread {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); - if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat" -#pragma GCC diagnostic ignored "-Wformat-extra-args" - fmt_state_printf(state, " data=%.*q%s", - (int)(self->count < 50 ? self->count : 50), - (char *)self->data, - self->count < 50 ? "" : "..."); -#pragma GCC diagnostic pop - } else { - fmt_state_puts(state, " data=<bytedata>"); +[[maybe_unused]] static void fmt_print_Rwalk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *self) { + fmt_print_str(w, "Rwalk {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " nwqid="); + fmt_print_base10(w, self->nwqid); + fmt_print_str(w, " wqid=["); + for (uint16_t i = 0; i < self->nwqid; i++) { + if (i) + fmt_print_byte(w, ','); + fmt_print_byte(w, ' '); + fmt_print_qid(w, ctx, &self->wqid[i]); } - fmt_state_puts(state, " }"); + fmt_print_str(w, " ]"); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] static void fmt_print_Ropen(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *self) { + fmt_print_str(w, "Ropen {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " iounit="); + fmt_print_base10(w, self->iounit); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *self) { + fmt_print_str(w, "Tcreate {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " perm="); + fmt_print_dm(w, ctx, &self->perm); + fmt_print_str(w, " mode="); + fmt_print_o(w, ctx, &self->mode); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *self) { + fmt_print_str(w, "Rcreate {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " iounit="); + fmt_print_base10(w, self->iounit); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_p9p +[[maybe_unused]] static void fmt_print_Ropenfd(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *self) { + fmt_print_str(w, "Ropenfd {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " iounit="); + fmt_print_base10(w, self->iounit); + fmt_print_str(w, " unixfd="); + fmt_print_base10(w, self->unixfd); + fmt_print_str(w, " }"); } -static void lib9p_msg_Tswrite_format(struct lib9p_msg_Tswrite *self, struct fmt_state *state) { - fmt_state_puts(state, "Tswrite {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " fid="); - fmt_state_printf(state, "%"PRIu32, self->fid); - fmt_state_puts(state, " nwname="); - fmt_state_printf(state, "%"PRIu16, self->nwname); - fmt_state_puts(state, " wname=["); +#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ +#if CONFIG_9P_ENABLE_9P2000_L +[[maybe_unused]] static void fmt_print_Rlopen(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *self) { + fmt_print_str(w, "Rlopen {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " iounit="); + fmt_print_base10(w, self->iounit); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tlcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *self) { + fmt_print_str(w, "Tlcreate {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " flags="); + fmt_print_lo(w, ctx, &self->flags); + fmt_print_str(w, " mode="); + fmt_print_mode(w, ctx, &self->mode); + fmt_print_str(w, " gid="); + fmt_print_nuid(w, ctx, &self->gid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rlcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *self) { + fmt_print_str(w, "Rlcreate {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " iounit="); + fmt_print_base10(w, self->iounit); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tsymlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *self) { + fmt_print_str(w, "Tsymlink {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " symtgt="); + fmt_print_s(w, ctx, &self->symtgt); + fmt_print_str(w, " gid="); + fmt_print_nuid(w, ctx, &self->gid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rsymlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *self) { + fmt_print_str(w, "Rsymlink {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tmknod(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *self) { + fmt_print_str(w, "Tmknod {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " dfid="); + fmt_print_fid(w, ctx, &self->dfid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " mode="); + fmt_print_mode(w, ctx, &self->mode); + fmt_print_str(w, " major="); + fmt_print_base10(w, self->major); + fmt_print_str(w, " minor="); + fmt_print_base10(w, self->minor); + fmt_print_str(w, " gid="); + fmt_print_nuid(w, ctx, &self->gid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rmknod(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *self) { + fmt_print_str(w, "Rmknod {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Trename(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Trename *self) { + fmt_print_str(w, "Trename {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " dfid="); + fmt_print_fid(w, ctx, &self->dfid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rreadlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink *self) { + fmt_print_str(w, "Rreadlink {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " target="); + fmt_print_s(w, ctx, &self->target); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rgetattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *self) { + fmt_print_str(w, "Rgetattr {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " valid="); + fmt_print_getattr(w, ctx, &self->valid); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " mode="); + fmt_print_mode(w, ctx, &self->mode); + fmt_print_str(w, " uid="); + fmt_print_nuid(w, ctx, &self->uid); + fmt_print_str(w, " gid="); + fmt_print_nuid(w, ctx, &self->gid); + fmt_print_str(w, " nlink="); + fmt_print_base10(w, self->nlink); + fmt_print_str(w, " rdev="); + fmt_print_base10(w, self->rdev); + fmt_print_str(w, " filesize="); + fmt_print_base10(w, self->filesize); + fmt_print_str(w, " blksize="); + fmt_print_base10(w, self->blksize); + fmt_print_str(w, " blocks="); + fmt_print_base10(w, self->blocks); + fmt_print_str(w, " atime_sec="); + fmt_print_base10(w, self->atime_sec); + fmt_print_str(w, " atime_nsec="); + fmt_print_base10(w, self->atime_nsec); + fmt_print_str(w, " mtime_sec="); + fmt_print_base10(w, self->mtime_sec); + fmt_print_str(w, " mtime_nsec="); + fmt_print_base10(w, self->mtime_nsec); + fmt_print_str(w, " ctime_sec="); + fmt_print_base10(w, self->ctime_sec); + fmt_print_str(w, " ctime_nsec="); + fmt_print_base10(w, self->ctime_nsec); + fmt_print_str(w, " btime_sec="); + fmt_print_base10(w, self->btime_sec); + fmt_print_str(w, " btime_nsec="); + fmt_print_base10(w, self->btime_nsec); + fmt_print_str(w, " gen="); + fmt_print_base10(w, self->gen); + fmt_print_str(w, " data_version="); + fmt_print_base10(w, self->data_version); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Txattrwalk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwalk *self) { + fmt_print_str(w, "Txattrwalk {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " newfid="); + fmt_print_fid(w, ctx, &self->newfid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Txattrcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Txattrcreate *self) { + fmt_print_str(w, "Txattrcreate {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " attr_size="); + fmt_print_base10(w, self->attr_size); + fmt_print_str(w, " flags="); + fmt_print_base10(w, self->flags); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tlock(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *self) { + fmt_print_str(w, "Tlock {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " type="); + fmt_print_lock_type(w, ctx, &self->type); + fmt_print_str(w, " flags="); + fmt_print_lock_flags(w, ctx, &self->flags); + fmt_print_str(w, " start="); + fmt_print_base10(w, self->start); + fmt_print_str(w, " length="); + fmt_print_base10(w, self->length); + fmt_print_str(w, " proc_id="); + fmt_print_base10(w, self->proc_id); + fmt_print_str(w, " client_id="); + fmt_print_s(w, ctx, &self->client_id); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tgetlock(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *self) { + fmt_print_str(w, "Tgetlock {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " type="); + fmt_print_lock_type(w, ctx, &self->type); + fmt_print_str(w, " start="); + fmt_print_base10(w, self->start); + fmt_print_str(w, " length="); + fmt_print_base10(w, self->length); + fmt_print_str(w, " proc_id="); + fmt_print_base10(w, self->proc_id); + fmt_print_str(w, " client_id="); + fmt_print_s(w, ctx, &self->client_id); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rgetlock(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *self) { + fmt_print_str(w, "Rgetlock {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " type="); + fmt_print_lock_type(w, ctx, &self->type); + fmt_print_str(w, " start="); + fmt_print_base10(w, self->start); + fmt_print_str(w, " length="); + fmt_print_base10(w, self->length); + fmt_print_str(w, " proc_id="); + fmt_print_base10(w, self->proc_id); + fmt_print_str(w, " client_id="); + fmt_print_s(w, ctx, &self->client_id); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *self) { + fmt_print_str(w, "Tlink {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " dfid="); + fmt_print_fid(w, ctx, &self->dfid); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tmkdir(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *self) { + fmt_print_str(w, "Tmkdir {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " dfid="); + fmt_print_fid(w, ctx, &self->dfid); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " mode="); + fmt_print_mode(w, ctx, &self->mode); + fmt_print_str(w, " gid="); + fmt_print_nuid(w, ctx, &self->gid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Rmkdir(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *self) { + fmt_print_str(w, "Rmkdir {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " qid="); + fmt_print_qid(w, ctx, &self->qid); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Trenameat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat *self) { + fmt_print_str(w, "Trenameat {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " olddirfid="); + fmt_print_fid(w, ctx, &self->olddirfid); + fmt_print_str(w, " oldname="); + fmt_print_s(w, ctx, &self->oldname); + fmt_print_str(w, " newdirfid="); + fmt_print_fid(w, ctx, &self->newdirfid); + fmt_print_str(w, " newname="); + fmt_print_s(w, ctx, &self->newname); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tunlinkat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat *self) { + fmt_print_str(w, "Tunlinkat {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " dirfd="); + fmt_print_fid(w, ctx, &self->dirfd); + fmt_print_str(w, " name="); + fmt_print_s(w, ctx, &self->name); + fmt_print_str(w, " flags="); + fmt_print_base10(w, self->flags); + fmt_print_str(w, " }"); +} + +#endif /* CONFIG_9P_ENABLE_9P2000_L */ +#if CONFIG_9P_ENABLE_9P2000_e +[[maybe_unused]] static void fmt_print_Tsread(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *self) { + fmt_print_str(w, "Tsread {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_base10(w, self->fid); + fmt_print_str(w, " nwname="); + fmt_print_base10(w, self->nwname); + fmt_print_str(w, " wname=["); + for (uint16_t i = 0; i < self->nwname; i++) { + if (i) + fmt_print_byte(w, ','); + fmt_print_byte(w, ' '); + fmt_print_s(w, ctx, &self->wname[i]); + } + fmt_print_str(w, " ]"); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Tswrite(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *self) { + fmt_print_str(w, "Tswrite {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_base10(w, self->fid); + fmt_print_str(w, " nwname="); + fmt_print_base10(w, self->nwname); + fmt_print_str(w, " wname=["); for (uint16_t i = 0; i < self->nwname; i++) { if (i) - fmt_state_putchar(state, ','); - fmt_state_putchar(state, ' '); - lib9p_s_format(&self->wname[i], state); + fmt_print_byte(w, ','); + fmt_print_byte(w, ' '); + fmt_print_s(w, ctx, &self->wname[i]); } - fmt_state_puts(state, " ]"); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); + fmt_print_str(w, " ]"); + fmt_print_str(w, " count="); + fmt_print_base10(w, self->count); if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat" -#pragma GCC diagnostic ignored "-Wformat-extra-args" - fmt_state_printf(state, " data=%.*q%s", - (int)(self->count < 50 ? self->count : 50), - (char *)self->data, - self->count < 50 ? "" : "..."); -#pragma GCC diagnostic pop + fmt_print_str(w, " data="); + fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50); + if (self->count > 50) + fmt_print_str(w, "..."); } else { - fmt_state_puts(state, " data=<bytedata>"); + fmt_print_str(w, " data=<bytedata>"); } - fmt_state_puts(state, " }"); + fmt_print_str(w, " }"); } -static void lib9p_msg_Rswrite_format(struct lib9p_msg_Rswrite *self, struct fmt_state *state) { - fmt_state_puts(state, "Rswrite {"); - fmt_state_puts(state, " tag="); - lib9p_tag_format(&self->tag, state); - fmt_state_puts(state, " count="); - fmt_state_printf(state, "%"PRIu32, self->count); - fmt_state_puts(state, " }"); -} #endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +[[maybe_unused]] static void fmt_print_Rstat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *self) { + fmt_print_str(w, "Rstat {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " stat="); + fmt_print_stat(w, ctx, &self->stat); + fmt_print_str(w, " }"); +} + +[[maybe_unused]] static void fmt_print_Twstat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *self) { + fmt_print_str(w, "Twstat {"); + fmt_print_str(w, " tag="); + fmt_print_tag(w, ctx, &self->tag); + fmt_print_str(w, " fid="); + fmt_print_fid(w, ctx, &self->fid); + fmt_print_str(w, " stat="); + fmt_print_stat(w, ctx, &self->stat); + fmt_print_str(w, " }"); +} +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ /* tables.h *******************************************************************/ @@ -7869,9 +7502,9 @@ const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM] = { #endif /* CONFIG_9P_ENABLE_uninitialized */ }; -#define _MSG(typ) [LIB9P_TYP_##typ] = { \ - .name = #typ, \ - .box_as_fmt_formatter = (_box_as_fmt_formatter_fn_t)lo_box_lib9p_msg_##typ##_as_fmt_formatter, \ +#define _MSG(typ) [LIB9P_TYP_##typ] = { \ + .name = #typ, \ + .print = (_print_fn_t)fmt_print_##typ, \ } const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100] = { #if CONFIG_9P_ENABLE_9P2000 |