diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-04-19 12:53:51 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-04-19 12:53:51 -0600 |
commit | 59e1fc370371c8da876d6c2ce68794bb7f89e525 (patch) | |
tree | 8037e1493bfebe72cb6023f5eccb62cff0c63349 /lib9p/core.c | |
parent | 0cf05b66f94bfe02ecca37a4cbafba25b27c32ae (diff) | |
parent | 7f34046f5b27617b70c1d55f479c2a1abb8b8d8a (diff) |
Merge branch 'lukeshu/9p-tidy'
Diffstat (limited to 'lib9p/core.c')
-rw-r--r-- | lib9p/core.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib9p/core.c b/lib9p/core.c index a07461d..cb8ddee 100644 --- a/lib9p/core.c +++ b/lib9p/core.c @@ -47,7 +47,7 @@ bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b) { void lib9p_ctx_clear_error(struct lib9p_ctx *ctx) { assert(ctx); -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L ctx->err_num = 0; #endif ctx->err_msg[0] = '\0'; @@ -58,22 +58,31 @@ bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) { return ctx->err_msg[0]; } -int lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg) { +#undef lib9p_error +#undef lib9p_errorf + +int lib9p_error(struct lib9p_ctx *ctx, +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + lib9p_errno_t linux_errno, +#endif + char const *msg) { if (lib9p_ctx_has_error(ctx)) return -1; strncpy(ctx->err_msg, msg, sizeof(ctx->err_msg)); ctx->err_msg[sizeof(ctx->err_msg)-1] = '\0'; -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L ctx->err_num = linux_errno; -#else - (void)(linux_errno); #endif return -1; } -int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) { +int lib9p_errorf(struct lib9p_ctx *ctx, +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + lib9p_errno_t linux_errno, +#endif + char const *fmt, ...) { int n; va_list args; @@ -85,10 +94,8 @@ int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *f if ((size_t)(n+1) < sizeof(ctx->err_msg)) memset(&ctx->err_msg[n+1], 0, sizeof(ctx->err_msg)-(n+1)); -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L ctx->err_num = linux_errno; -#else - (void)(linux_errno); #endif return -1; |