From 79480e66113b7654d1ed89b940222b6eee84c8b0 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 2 Oct 2024 14:51:13 -0600 Subject: bitfield versions --- lib9p/types.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib9p/types.c') diff --git a/lib9p/types.c b/lib9p/types.c index 3505a4a..18dcbfe 100644 --- a/lib9p/types.c +++ b/lib9p/types.c @@ -346,11 +346,16 @@ static ALWAYS_INLINE bool validate_s(struct _validate_ctx *ctx) { static ALWAYS_INLINE bool validate_qt(struct _validate_ctx *ctx) { if (validate_1(ctx)) return true; - const lib9p_qt_t mask = 0b11111110; + static const lib9p_qt_t masks[LIB9P_VER_NUM] = { + [LIB9P_VER_9P2000] = 0b11111100, + [LIB9P_VER_9P2000_e] = 0b11111100, + [LIB9P_VER_9P2000_u] = 0b11111110, + }; + lib9p_qt_t mask = masks[ctx->ctx->version]; lib9p_qt_t val = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); if (val & ~mask) - return lib9p_error(ctx->ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#01"PRIx8, - val & ~mask); + return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#01"PRIx8, + val & ~mask); return false; } -- cgit v1.2.3-2-g168b