summaryrefslogtreecommitdiff
path: root/lib9p
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-26 18:03:24 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-26 18:10:10 -0700
commit820540bd706214eee1ae27bb01e6ff5496679880 (patch)
tree80bde1c7fe15d0816b594c81ab55bcb86f9874f0 /lib9p
parent5fafccfcd54e0e309f084ff3891d0239250cfde3 (diff)
lib9p: idl.gen: Use \t instead of literal tab, to avoid mistakes
Diffstat (limited to 'lib9p')
-rw-r--r--lib9p/9p.generated.c2
-rwxr-xr-xlib9p/idl.gen110
2 files changed, 56 insertions, 56 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index 373d95e..3d296de 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -2843,5 +2843,5 @@ LM_FLATTEN void _lib9p_unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_s
unmarshal_stat(ctx, out);
}
LM_FLATTEN bool _lib9p_marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) {
- return marshal_stat(ctx, val);
+ return marshal_stat(ctx, val);
}
diff --git a/lib9p/idl.gen b/lib9p/idl.gen
index bab36af..f68d983 100755
--- a/lib9p/idl.gen
+++ b/lib9p/idl.gen
@@ -141,7 +141,7 @@ def gen_h(versions: set[str], typs: list[idl.Type]) -> str:
ret = f"""/* Generated by `{' '.join(sys.argv)}`. DO NOT EDIT! */
#ifndef _LIB9P_9P_H_
- #error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead
+\t#error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead
#endif
#include <stdint.h> /* for uint{{n}}_t types */
@@ -328,32 +328,32 @@ const char *{idprefix}version_str(enum {idprefix}version ver) {{
/* validate_* *****************************************************************/
LM_ALWAYS_INLINE static bool _validate_size_net(struct _validate_ctx *ctx, uint32_t n) {
- if (__builtin_add_overflow(ctx->net_offset, n, &ctx->net_offset))
- /* If needed-net-size overflowed uint32_t, then
- * there's no way that actual-net-size will live up to
- * that. */
- return lib9p_error(ctx->ctx, LINUX_EBADMSG, "message is too short for content");
- if (ctx->net_offset > ctx->net_size)
- return lib9p_error(ctx->ctx, LINUX_EBADMSG, "message is too short for content");
- return false;
+\tif (__builtin_add_overflow(ctx->net_offset, n, &ctx->net_offset))
+\t\t/* If needed-net-size overflowed uint32_t, then
+\t\t * there's no way that actual-net-size will live up to
+\t\t * that. */
+\t\treturn lib9p_error(ctx->ctx, LINUX_EBADMSG, "message is too short for content");
+\tif (ctx->net_offset > ctx->net_size)
+\t\treturn lib9p_error(ctx->ctx, LINUX_EBADMSG, "message is too short for content");
+\treturn false;
}
LM_ALWAYS_INLINE static bool _validate_size_host(struct _validate_ctx *ctx, size_t n) {
- if (__builtin_add_overflow(ctx->host_extra, n, &ctx->host_extra))
- /* If needed-host-size overflowed size_t, then there's
- * no way that actual-net-size will live up to
- * that. */
- return lib9p_error(ctx->ctx, LINUX_EBADMSG, "message is too short for content");
- return false;
+\tif (__builtin_add_overflow(ctx->host_extra, n, &ctx->host_extra))
+\t\t/* If needed-host-size overflowed size_t, then there's
+\t\t * no way that actual-net-size will live up to
+\t\t * that. */
+\t\treturn lib9p_error(ctx->ctx, LINUX_EBADMSG, "message is too short for content");
+\treturn false;
}
LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
size_t cnt,
_validate_fn_t item_fn, size_t item_host_size) {
- for (size_t i = 0; i < cnt; i++)
- if (_validate_size_host(ctx, item_host_size) || item_fn(ctx))
- return true;
- return false;
+\tfor (size_t i = 0; i < cnt; i++)
+\t\tif (_validate_size_host(ctx, item_host_size) || item_fn(ctx))
+\t\t\treturn true;
+\treturn false;
}
#define validate_1(ctx) _validate_size_net(ctx, 1)
@@ -495,23 +495,23 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
/* unmarshal_* ****************************************************************/
LM_ALWAYS_INLINE static void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) {
- *out = decode_u8le(&ctx->net_bytes[ctx->net_offset]);
- ctx->net_offset += 1;
+\t*out = decode_u8le(&ctx->net_bytes[ctx->net_offset]);
+\tctx->net_offset += 1;
}
LM_ALWAYS_INLINE static void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) {
- *out = decode_u16le(&ctx->net_bytes[ctx->net_offset]);
- ctx->net_offset += 2;
+\t*out = decode_u16le(&ctx->net_bytes[ctx->net_offset]);
+\tctx->net_offset += 2;
}
LM_ALWAYS_INLINE static void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) {
- *out = decode_u32le(&ctx->net_bytes[ctx->net_offset]);
- ctx->net_offset += 4;
+\t*out = decode_u32le(&ctx->net_bytes[ctx->net_offset]);
+\tctx->net_offset += 4;
}
LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) {
- *out = decode_u64le(&ctx->net_bytes[ctx->net_offset]);
- ctx->net_offset += 8;
+\t*out = decode_u64le(&ctx->net_bytes[ctx->net_offset]);
+\tctx->net_offset += 8;
}
"""
for typ in typs:
@@ -568,43 +568,43 @@ LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *o
/* marshal_* ******************************************************************/
LM_ALWAYS_INLINE static bool _marshal_too_large(struct _marshal_ctx *ctx) {
- lib9p_errorf(ctx->ctx, LINUX_ERANGE, "%s too large to marshal into %s limit (limit=%"PRIu32")",
- (ctx->net_bytes[4] % 2 == 0) ? "T-message" : "R-message",
- ctx->ctx->version ? "negotiated" : ((ctx->net_bytes[4] % 2 == 0) ? "client" : "server"),
- ctx->ctx->max_msg_size);
- return true;
+\tlib9p_errorf(ctx->ctx, LINUX_ERANGE, "%s too large to marshal into %s limit (limit=%"PRIu32")",
+\t\t(ctx->net_bytes[4] % 2 == 0) ? "T-message" : "R-message",
+\t\tctx->ctx->version ? "negotiated" : ((ctx->net_bytes[4] % 2 == 0) ? "client" : "server"),
+\t\tctx->ctx->max_msg_size);
+\treturn true;
}
LM_ALWAYS_INLINE static bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) {
- if (ctx->net_offset + 1 > ctx->ctx->max_msg_size)
- return _marshal_too_large(ctx);
- ctx->net_bytes[ctx->net_offset] = *val;
- ctx->net_offset += 1;
- return false;
+\tif (ctx->net_offset + 1 > ctx->ctx->max_msg_size)
+\t\treturn _marshal_too_large(ctx);
+\tctx->net_bytes[ctx->net_offset] = *val;
+\tctx->net_offset += 1;
+\treturn false;
}
LM_ALWAYS_INLINE static bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) {
- if (ctx->net_offset + 2 > ctx->ctx->max_msg_size)
- return _marshal_too_large(ctx);
- encode_u16le(*val, &ctx->net_bytes[ctx->net_offset]);
- ctx->net_offset += 2;
- return false;
+\tif (ctx->net_offset + 2 > ctx->ctx->max_msg_size)
+\t\treturn _marshal_too_large(ctx);
+\tencode_u16le(*val, &ctx->net_bytes[ctx->net_offset]);
+\tctx->net_offset += 2;
+\treturn false;
}
LM_ALWAYS_INLINE static bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) {
- if (ctx->net_offset + 4 > ctx->ctx->max_msg_size)
- return true;
- encode_u32le(*val, &ctx->net_bytes[ctx->net_offset]);
- ctx->net_offset += 4;
- return false;
+\tif (ctx->net_offset + 4 > ctx->ctx->max_msg_size)
+\t\treturn true;
+\tencode_u32le(*val, &ctx->net_bytes[ctx->net_offset]);
+\tctx->net_offset += 4;
+\treturn false;
}
LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) {
- if (ctx->net_offset + 8 > ctx->ctx->max_msg_size)
- return true;
- encode_u64le(*val, &ctx->net_bytes[ctx->net_offset]);
- ctx->net_offset += 8;
- return false;
+\tif (ctx->net_offset + 8 > ctx->ctx->max_msg_size)
+\t\treturn true;
+\tencode_u64le(*val, &ctx->net_bytes[ctx->net_offset]);
+\tctx->net_offset += 8;
+\treturn false;
}
"""
for typ in typs:
@@ -731,13 +731,13 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val)
ret += f"""
LM_FLATTEN bool _{idprefix}validate_stat(struct _validate_ctx *ctx) {{
- return validate_stat(ctx);
+\treturn validate_stat(ctx);
}}
LM_FLATTEN void _{idprefix}unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) {{
- unmarshal_stat(ctx, out);
+\tunmarshal_stat(ctx, out);
}}
LM_FLATTEN bool _{idprefix}marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) {{
- return marshal_stat(ctx, val);
+\treturn marshal_stat(ctx, val);
}}
"""