summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--cmd/sbc_harness/fs_harness_flash_bin.c14
-rw-r--r--cmd/sbc_harness/fs_harness_uptime_txt.c6
-rw-r--r--lib9p/core.c21
-rw-r--r--lib9p/core_gen/c_marshal.py4
-rw-r--r--lib9p/core_gen/h.py4
-rw-r--r--lib9p/core_generated.c618
-rw-r--r--lib9p/core_include/lib9p/_core_generated.h4
-rw-r--r--lib9p/core_tables.h2
-rw-r--r--lib9p/srv.c14
-rw-r--r--lib9p/tests/test_server/main.c6
-rw-r--r--lib9p/tests/testclient-sess.c11
-rw-r--r--libcr/coroutine.c2
-rw-r--r--libcr_ipc/tests/test_select.c7
-rw-r--r--libdhcp/dhcp_client.c42
-rw-r--r--libfmt/quote.c18
-rw-r--r--libhw_cr/host_util.h18
-rw-r--r--libhw_cr/rp2040_dma.h29
-rw-r--r--libhw_cr/rp2040_gpioirq.c8
-rw-r--r--libhw_cr/rp2040_hwtimer.c6
-rw-r--r--libhw_cr/w5500.c26
-rw-r--r--libmisc/include/libmisc/macro.h62
-rw-r--r--libmisc/include/libmisc/rand.h7
-rw-r--r--libmisc/map.c2
-rw-r--r--libmisc/tests/test_obj_nest.c12
-rw-r--r--libmisc/tests/test_rand.c6
-rw-r--r--libusb/usb_common.c16
27 files changed, 535 insertions, 432 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 659f530..23d4047 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@ endif()
# Use modern C...
set(CMAKE_C_STANDARD 23)
# ... but with some misfeatures disabled.
-add_compile_options(-Werror=vla)
+add_compile_options(-Werror=vla -Werror=conversion)
# Have the compiler help detect mistakes.
add_compile_options(-Wall -Wextra -Wswitch-enum -Werror)
diff --git a/cmd/sbc_harness/fs_harness_flash_bin.c b/cmd/sbc_harness/fs_harness_flash_bin.c
index f353ddd..4ca1d04 100644
--- a/cmd/sbc_harness/fs_harness_flash_bin.c
+++ b/cmd/sbc_harness/fs_harness_flash_bin.c
@@ -222,17 +222,19 @@ static void flash_file_iofree(struct flash_file *self) {
}
static void flash_file_pread(struct flash_file *self, struct lib9p_srv_ctx *ctx,
- uint32_t byte_count, uint64_t byte_offset,
+ uint32_t byte_count, uint64_t _byte_offset,
struct iovec *ret) {
assert(self);
assert(ctx);
assert(ret);
- if (byte_offset > DATA_SIZE) {
+ if (_byte_offset > DATA_SIZE) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EINVAL, "offset is past the chip size");
return;
}
+ static_assert(DATA_SIZE < SIZE_MAX);
+ size_t byte_offset = LM_SAFEDOWNCAST(size_t, _byte_offset);
/* Assume that somewhere down the line the iovec we return
* will be passed to DMA. We don't want the DMA engine to hit
@@ -270,22 +272,24 @@ static void flash_file_pread(struct flash_file *self, struct lib9p_srv_ctx *ctx,
static uint32_t flash_file_pwrite(struct flash_file *self, struct lib9p_srv_ctx *ctx,
void *buf,
uint32_t byte_count,
- uint64_t byte_offset) {
+ uint64_t _byte_offset) {
assert(self);
assert(ctx);
- if (byte_offset > DATA_HSIZE) {
+ if (_byte_offset > DATA_HSIZE) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EINVAL, "offset is past half the chip size");
return 0;
}
if (byte_count == 0)
return 0;
- if (byte_offset == DATA_HSIZE) {
+ if (_byte_offset == DATA_HSIZE) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EINVAL, "offset is at half the chip size");
return 0;
}
+ static_assert(DATA_SIZE < SIZE_MAX);
+ size_t byte_offset = LM_SAFEDOWNCAST(size_t, _byte_offset);
size_t sector_base = LM_ROUND_DOWN(byte_offset, FLASH_SECTOR_SIZE);
if (byte_offset + byte_count > sector_base + FLASH_SECTOR_SIZE)
diff --git a/cmd/sbc_harness/fs_harness_uptime_txt.c b/cmd/sbc_harness/fs_harness_uptime_txt.c
index f7b755f..6e65f34 100644
--- a/cmd/sbc_harness/fs_harness_uptime_txt.c
+++ b/cmd/sbc_harness/fs_harness_uptime_txt.c
@@ -120,16 +120,16 @@ static void uptime_fio_pread(struct uptime_fio *self, struct lib9p_srv_ctx *ctx,
if (byte_offset == 0 || self->buf_len == 0) {
uint64_t now = LO_CALL(bootclock, get_time_ns);
- self->buf_len = snprintf(self->buf, sizeof(self->buf), "%"PRIu64"ns\n", now);
+ self->buf_len = LM_SAFEDOWNCAST(size_t, snprintf(self->buf, sizeof(self->buf), "%"PRIu64"ns\n", now));
}
- if (byte_offset > (uint64_t)self->buf_len) {
+ if (byte_offset > self->buf_len) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EINVAL, "offset is past end-of-file length");
return;
}
- size_t beg_off = (size_t)byte_offset;
+ size_t beg_off = LM_SAFEDOWNCAST(size_t, byte_offset);
size_t end_off = beg_off + (size_t)byte_count;
if (end_off > self->buf_len)
end_off = self->buf_len;
diff --git a/lib9p/core.c b/lib9p/core.c
index 03cdea5..a0c2f64 100644
--- a/lib9p/core.c
+++ b/lib9p/core.c
@@ -21,16 +21,22 @@
struct lib9p_s lib9p_str(char *s) {
if (!s)
return (struct lib9p_s){0};
+ size_t len = strlen(s);
+ if (len > UINT16_MAX)
+ len = UINT16_MAX;
return (struct lib9p_s){
- .len = strlen(s),
+ .len = LM_SAFEDOWNCAST(uint16_t, len),
.utf8 = s,
};
}
struct lib9p_s lib9p_strn(char *s, size_t maxlen) {
if (maxlen == 0 || !s)
return (struct lib9p_s){0};
+ size_t len = strnlen(s, maxlen);
+ if (len > UINT16_MAX)
+ len = UINT16_MAX;
return (struct lib9p_s){
- .len = strnlen(s, maxlen),
+ .len = LM_SAFEDOWNCAST(uint16_t, len),
.utf8 = s,
};
}
@@ -84,15 +90,15 @@ int _lib9p_errorf(struct lib9p_ctx *ctx,
lib9p_errno_t linux_errno,
#endif
char const *fmt, ...) {
- int n;
+ size_t n;
va_list args;
if (lib9p_ctx_has_error(ctx))
return -1;
va_start(args, fmt);
- n = fmt_vsnprintf(ctx->err_msg, sizeof(ctx->err_msg), fmt, args);
+ n = LM_SAFEDOWNCAST(size_t, fmt_vsnprintf(ctx->err_msg, sizeof(ctx->err_msg), fmt, args));
va_end(args);
- if ((size_t)(n+1) < sizeof(ctx->err_msg))
+ if (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 || CONFIG_9P_ENABLE_9P2000_L
@@ -212,7 +218,7 @@ void lib9p_Rmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
static
bool _lib9p_marshal(const struct _lib9p_send_tentry xxx_table[LIB9P_VER_NUM][0x80],
struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
- size_t *ret_iov_cnt, struct iovec *ret_iov, uint8_t *ret_copied) {
+ int *ret_iov_cnt, struct iovec *ret_iov, uint8_t *ret_copied) {
assert_ver(ctx->version);
assert_typ(typ);
struct _marshal_ret ret = {
@@ -281,6 +287,7 @@ uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct
};
if (_lib9p_stat_marshal(&_ctx, obj, &ret))
return 0;
- return ret.net_iov[0].iov_len;
+ assert(ret.net_iov[0].iov_len);
+ return LM_SAFEDOWNCAST(uint32_t, ret.net_iov[0].iov_len);
}
#endif
diff --git a/lib9p/core_gen/c_marshal.py b/lib9p/core_gen/c_marshal.py
index 322e1ef..581ed92 100644
--- a/lib9p/core_gen/c_marshal.py
+++ b/lib9p/core_gen/c_marshal.py
@@ -78,7 +78,7 @@ class OffsetExpr:
if dsttyp:
if not oneline:
oneline.append("0")
- ret += f"{'\t'*indent_depth}{dsttyp} {dstvar} = {' + '.join(oneline)};\n"
+ ret += f"{'\t'*indent_depth}{dsttyp} {dstvar} = LM_SAFEDOWNCAST({dsttyp}, {' + '.join(oneline)});\n"
elif oneline:
ret += f"{'\t'*indent_depth}{dstvar} += {' + '.join(oneline)};\n"
ret += multiline
@@ -350,6 +350,8 @@ def gen_c_marshal(versions: set[str], typs: list[idl.UserType]) -> str:
return f"offsetof{''.join('_'+m.membname for m in path.elems[:-1])}_{sym}"
val = c9util.idl_expr(child.val, lookup_sym)
+ if child.typ.static_size < 32:
+ val = f"LM_SAFEDOWNCAST(uint{child.typ.static_size*8}_t, {val})"
else:
val = path.c_str("val->")
if isinstance(child.typ, idl.Bitfield):
diff --git a/lib9p/core_gen/h.py b/lib9p/core_gen/h.py
index 61775c1..378fc06 100644
--- a/lib9p/core_gen/h.py
+++ b/lib9p/core_gen/h.py
@@ -354,14 +354,14 @@ enum {c9util.ident('version')} {{
ret += "\n"
ret += f"struct {c9util.ident('Tmsg_send_buf')} {{\n"
- ret += "\tsize_t iov_cnt;\n"
+ ret += "\tint iov_cnt;\n"
ret += f"\tstruct iovec iov[{c9util.IDENT('TMSG_MAX_IOV')}];\n"
ret += f"\tuint8_t copied[{c9util.IDENT('TMSG_MAX_COPY')}];\n"
ret += "};\n"
ret += "\n"
ret += f"struct {c9util.ident('Rmsg_send_buf')} {{\n"
- ret += "\tsize_t iov_cnt;\n"
+ ret += "\tint iov_cnt;\n"
ret += f"\tstruct iovec iov[{c9util.IDENT('RMSG_MAX_IOV')}];\n"
ret += f"\tuint8_t copied[{c9util.IDENT('RMSG_MAX_COPY')}];\n"
ret += "};\n"
diff --git a/lib9p/core_generated.c b/lib9p/core_generated.c
index c8896b9..ffef2c4 100644
--- a/lib9p/core_generated.c
+++ b/lib9p/core_generated.c
@@ -3011,7 +3011,7 @@ static void unmarshal_Rswrite([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *n
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 49 + val->name.len + val->owner_uname.len + val->owner_gname.len + val->last_modifier_uname.len;
+ uint32_t needed_size = (uint32_t)(49 + val->name.len + val->owner_uname.len + val->owner_gname.len + val->last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
needed_size += 14 + val->extension.len;
@@ -3021,8 +3021,8 @@ static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_fstype = 2;
- MARSHAL_U16LE(ctx, offsetof_end - offsetof_fstype);
+ uint32_t offsetof_fstype = (uint32_t)(2);
+ MARSHAL_U16LE(ctx, (uint16_t)(offsetof_end - offsetof_fstype));
MARSHAL_U16LE(ctx, val->fstype);
MARSHAL_U32LE(ctx, val->fsdev);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
@@ -3055,7 +3055,7 @@ static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _
#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 bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 13 + val->version.len;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3064,9 +3064,9 @@ static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 100);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(100));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->max_msg_size);
MARSHAL_U16LE(ctx, val->version.len);
@@ -3075,7 +3075,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3084,9 +3084,9 @@ static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 101);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(101));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->max_msg_size);
MARSHAL_U16LE(ctx, val->version.len);
@@ -3097,7 +3097,7 @@ static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *v
#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 bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 15 + val->uname.len + val->aname.len;
+ uint32_t needed_size = (uint32_t)(15 + val->uname.len + val->aname.len);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
if ( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) ) {
needed_size += 4;
@@ -3111,9 +3111,9 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 102);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(102));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->afid);
MARSHAL_U16LE(ctx, val->uname.len);
@@ -3129,7 +3129,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3138,9 +3138,9 @@ static bool marshal_Rauth(struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 103);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(103));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->aqid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->aqid.vers);
@@ -3149,7 +3149,7 @@ static bool marshal_Rauth(struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *val, st
}
static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 19 + val->uname.len + val->aname.len;
+ uint32_t needed_size = (uint32_t)(19 + val->uname.len + val->aname.len);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
if ( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) ) {
needed_size += 4;
@@ -3163,9 +3163,9 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 104);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(104));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->afid);
@@ -3182,7 +3182,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3191,9 +3191,9 @@ static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 105);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(105));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -3204,7 +3204,7 @@ static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val
#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 bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 9 + val->errstr.len;
+ uint32_t needed_size = (uint32_t)(9 + val->errstr.len);
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
needed_size += 4;
@@ -3218,9 +3218,9 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 107);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(107));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U16LE(ctx, val->errstr.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->errstr.utf8, val->errstr.len);
@@ -3235,7 +3235,7 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val,
#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 bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 9;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3244,16 +3244,16 @@ static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 108);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(108));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U16LE(ctx, val->oldtag);
return false;
}
static bool marshal_Rflush(struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 7;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3262,15 +3262,15 @@ static bool marshal_Rflush(struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 109);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(109));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 17;
+ uint32_t needed_size = (uint32_t)(17);
for (uint16_t i = 0; i < val->nwname; i++) {
needed_size += 2 + val->wname[i].len;
}
@@ -3282,9 +3282,9 @@ static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 110);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(110));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->newfid);
@@ -3297,7 +3297,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3306,9 +3306,9 @@ static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 111);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(111));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U16LE(ctx, val->nwqid);
for (uint16_t i = 0; i < val->nwqid; i++) {
@@ -3322,7 +3322,7 @@ static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, st
#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 bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 12;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3331,9 +3331,9 @@ static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 112);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(112));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U8LE(ctx, val->mode & o_masks[ctx->version]);
@@ -3341,7 +3341,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3350,9 +3350,9 @@ static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 113);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(113));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -3362,7 +3362,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3371,9 +3371,9 @@ static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 114);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(114));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, val->name.len);
@@ -3384,7 +3384,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3393,9 +3393,9 @@ static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 115);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(115));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -3407,7 +3407,7 @@ static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val
#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 bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 23;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3416,9 +3416,9 @@ static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 116);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(116));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U64LE(ctx, val->offset);
@@ -3427,7 +3427,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3436,9 +3436,9 @@ static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 117);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(117));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count);
@@ -3446,7 +3446,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3455,9 +3455,9 @@ static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 118);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(118));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U64LE(ctx, val->offset);
@@ -3467,7 +3467,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3476,16 +3476,16 @@ static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 119);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(119));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
return false;
}
static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 11;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3494,16 +3494,16 @@ static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 120);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(120));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
return false;
}
static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 7;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3512,15 +3512,15 @@ static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 121);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(121));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 11;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3529,16 +3529,16 @@ static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 122);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(122));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
return false;
}
static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 7;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3547,9 +3547,9 @@ static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 123);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(123));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
@@ -3557,7 +3557,7 @@ static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val
#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 bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 11;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3566,16 +3566,16 @@ static bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 124);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(124));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
return false;
}
static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 58 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
+ uint32_t needed_size = (uint32_t)(58 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
needed_size += 14 + val->stat.extension.len;
@@ -3589,20 +3589,20 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- uint32_t offsetof_stat = 9;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 125);
+ uint32_t offsetof_size = (uint32_t)(0);
+ uint32_t offsetof_stat = (uint32_t)(9);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(125));
MARSHAL_U16LE(ctx, val->tag);
- MARSHAL_U16LE(ctx, offsetof_end - offsetof_stat);
- uint32_t offsetof_stat_end = 49 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
+ MARSHAL_U16LE(ctx, (uint16_t)(offsetof_end - offsetof_stat));
+ uint32_t offsetof_stat_end = (uint32_t)(49 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
offsetof_stat_end += 14 + val->stat.extension.len;
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- uint32_t offsetof_stat_fstype = 2;
- MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_fstype);
+ uint32_t offsetof_stat_fstype = (uint32_t)(2);
+ MARSHAL_U16LE(ctx, (uint16_t)(offsetof_stat_end - offsetof_stat_fstype));
MARSHAL_U16LE(ctx, val->stat.fstype);
MARSHAL_U32LE(ctx, val->stat.fsdev);
MARSHAL_U8LE(ctx, val->stat.qid.type & qt_masks[ctx->version]);
@@ -3633,7 +3633,7 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st
}
static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 62 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
+ uint32_t needed_size = (uint32_t)(62 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
needed_size += 14 + val->stat.extension.len;
@@ -3647,21 +3647,21 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- uint32_t offsetof_stat = 13;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 126);
+ uint32_t offsetof_size = (uint32_t)(0);
+ uint32_t offsetof_stat = (uint32_t)(13);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(126));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
- MARSHAL_U16LE(ctx, offsetof_end - offsetof_stat);
- uint32_t offsetof_stat_end = 49 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
+ MARSHAL_U16LE(ctx, (uint16_t)(offsetof_end - offsetof_stat));
+ uint32_t offsetof_stat_end = (uint32_t)(49 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
offsetof_stat_end += 14 + val->stat.extension.len;
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- uint32_t offsetof_stat_fstype = 2;
- MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_fstype);
+ uint32_t offsetof_stat_fstype = (uint32_t)(2);
+ MARSHAL_U16LE(ctx, (uint16_t)(offsetof_stat_end - offsetof_stat_fstype));
MARSHAL_U16LE(ctx, val->stat.fstype);
MARSHAL_U32LE(ctx, val->stat.fsdev);
MARSHAL_U8LE(ctx, val->stat.qid.type & qt_masks[ctx->version]);
@@ -3692,7 +3692,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3701,9 +3701,9 @@ static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 127);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(127));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
@@ -3711,7 +3711,7 @@ static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val,
#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 bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 12;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3720,9 +3720,9 @@ static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 98);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(98));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U8LE(ctx, val->mode & o_masks[ctx->version]);
@@ -3730,7 +3730,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3739,9 +3739,9 @@ static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 99);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(99));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -3754,7 +3754,7 @@ static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val
#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
#if CONFIG_9P_ENABLE_9P2000_L
static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 11;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3763,16 +3763,16 @@ static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 7);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(7));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->errnum);
return false;
}
static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 11;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3781,16 +3781,16 @@ static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 8);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(8));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
return false;
}
static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 67;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3799,9 +3799,9 @@ static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 9);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(9));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->type);
MARSHAL_U32LE(ctx, val->bsize);
@@ -3816,7 +3816,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3825,9 +3825,9 @@ static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 12);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(12));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->version]);
@@ -3835,7 +3835,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3844,9 +3844,9 @@ static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 13);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(13));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -3856,7 +3856,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3865,9 +3865,9 @@ static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 14);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(14));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, val->name.len);
@@ -3879,7 +3879,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3888,9 +3888,9 @@ static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 15);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(15));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -3900,7 +3900,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3909,9 +3909,9 @@ static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 16);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(16));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, val->name.len);
@@ -3923,7 +3923,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3932,9 +3932,9 @@ static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 17);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(17));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -3943,7 +3943,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3952,9 +3952,9 @@ static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 18);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(18));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->dfid);
MARSHAL_U16LE(ctx, val->name.len);
@@ -3967,7 +3967,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3976,9 +3976,9 @@ static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 19);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(19));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -3987,7 +3987,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -3996,9 +3996,9 @@ static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 20);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(20));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->dfid);
@@ -4008,7 +4008,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4017,15 +4017,15 @@ static bool marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 21);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(21));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 11;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4034,16 +4034,16 @@ static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 22);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(22));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
return false;
}
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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4052,9 +4052,9 @@ static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 23);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(23));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U16LE(ctx, val->target.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->target.utf8, val->target.len);
@@ -4062,7 +4062,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4071,9 +4071,9 @@ static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 24);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(24));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U64LE(ctx, val->request_mask & getattr_masks[ctx->version]);
@@ -4081,7 +4081,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4090,9 +4090,9 @@ static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 25);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(25));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U64LE(ctx, val->valid & getattr_masks[ctx->version]);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
@@ -4120,7 +4120,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4129,9 +4129,9 @@ static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 26);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(26));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->valid & setattr_masks[ctx->version]);
@@ -4147,7 +4147,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4156,15 +4156,15 @@ static bool marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 27);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(27));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4173,9 +4173,9 @@ static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwal
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 30);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(30));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->newfid);
@@ -4185,7 +4185,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4194,16 +4194,16 @@ static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwal
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 31);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(31));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U64LE(ctx, val->attr_size);
return false;
}
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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4212,9 +4212,9 @@ static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrc
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 32);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(32));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, val->name.len);
@@ -4225,7 +4225,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4234,15 +4234,15 @@ static bool marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrc
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 33);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(33));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 23;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4251,9 +4251,9 @@ static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 40);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(40));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U64LE(ctx, val->offset);
@@ -4262,7 +4262,7 @@ 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;
+ uint64_t needed_size = (uint64_t)(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",
@@ -4271,9 +4271,9 @@ static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *v
return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 41);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(41));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count);
@@ -4281,7 +4281,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4290,9 +4290,9 @@ static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 50);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(50));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->datasync);
@@ -4300,7 +4300,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4309,15 +4309,15 @@ static bool marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 51);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(51));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4326,9 +4326,9 @@ static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 52);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(52));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U8LE(ctx, val->type);
@@ -4342,7 +4342,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4351,16 +4351,16 @@ static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 53);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(53));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->status);
return false;
}
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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4369,9 +4369,9 @@ static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 54);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(54));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U8LE(ctx, val->type);
@@ -4384,7 +4384,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4393,9 +4393,9 @@ static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 55);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(55));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->type);
MARSHAL_U64LE(ctx, val->start);
@@ -4407,7 +4407,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4416,9 +4416,9 @@ static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 70);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(70));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->dfid);
MARSHAL_U32LE(ctx, val->fid);
@@ -4428,7 +4428,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4437,15 +4437,15 @@ static bool marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, st
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 71);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(71));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4454,9 +4454,9 @@ static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 72);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(72));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->dfid);
MARSHAL_U16LE(ctx, val->name.len);
@@ -4467,7 +4467,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4476,9 +4476,9 @@ static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val,
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 73);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(73));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
@@ -4487,7 +4487,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4496,9 +4496,9 @@ static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 74);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(74));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->olddirfid);
MARSHAL_U16LE(ctx, val->oldname.len);
@@ -4510,7 +4510,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4519,15 +4519,15 @@ static bool marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 75);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(75));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4536,9 +4536,9 @@ static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 76);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(76));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->dirfd);
MARSHAL_U16LE(ctx, val->name.len);
@@ -4548,7 +4548,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4557,9 +4557,9 @@ static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 77);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(77));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
@@ -4567,7 +4567,7 @@ static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000_e
static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 15;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4576,16 +4576,16 @@ static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 150);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(150));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U64LE(ctx, val->key);
return false;
}
static bool marshal_Rsession(struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 7;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4594,15 +4594,15 @@ static bool marshal_Rsession(struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *v
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 151);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(151));
MARSHAL_U16LE(ctx, val->tag);
return false;
}
static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val, struct _marshal_ret *ret) {
- uint64_t needed_size = 13;
+ uint64_t needed_size = (uint64_t)(13);
for (uint16_t i = 0; i < val->nwname; i++) {
needed_size += 2 + val->wname[i].len;
}
@@ -4614,9 +4614,9 @@ static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val,
return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 152);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(152));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, val->nwname);
@@ -4628,7 +4628,7 @@ 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;
+ uint64_t needed_size = (uint64_t)(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",
@@ -4637,9 +4637,9 @@ static bool marshal_Rsread(struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *val,
return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 153);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(153));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count);
@@ -4647,7 +4647,7 @@ static bool marshal_Rsread(struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *val,
}
static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val, struct _marshal_ret *ret) {
- uint64_t needed_size = 17 + val->count;
+ uint64_t needed_size = (uint64_t)(17 + val->count);
for (uint16_t i = 0; i < val->nwname; i++) {
needed_size += 2 + val->wname[i].len;
}
@@ -4659,9 +4659,9 @@ static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val
return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 154);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(154));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, val->nwname);
@@ -4675,7 +4675,7 @@ 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;
+ uint32_t needed_size = (uint32_t)(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",
@@ -4684,9 +4684,9 @@ static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_size = 0;
- MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
- MARSHAL_U8LE(ctx, 155);
+ uint32_t offsetof_size = (uint32_t)(0);
+ MARSHAL_U32LE(ctx, (uint32_t)(offsetof_end - offsetof_size));
+ MARSHAL_U8LE(ctx, (uint8_t)(155));
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
return false;
diff --git a/lib9p/core_include/lib9p/_core_generated.h b/lib9p/core_include/lib9p/_core_generated.h
index d3b4740..0ffab2b 100644
--- a/lib9p/core_include/lib9p/_core_generated.h
+++ b/lib9p/core_include/lib9p/_core_generated.h
@@ -1475,13 +1475,13 @@ LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twstat, lib9p_msg_Twstat);
#endif
struct lib9p_Tmsg_send_buf {
- size_t iov_cnt;
+ int iov_cnt;
struct iovec iov[LIB9P_TMSG_MAX_IOV];
uint8_t copied[LIB9P_TMSG_MAX_COPY];
};
struct lib9p_Rmsg_send_buf {
- size_t iov_cnt;
+ int iov_cnt;
struct iovec iov[LIB9P_RMSG_MAX_IOV];
uint8_t copied[LIB9P_RMSG_MAX_COPY];
};
diff --git a/lib9p/core_tables.h b/lib9p/core_tables.h
index da2027a..c410db1 100644
--- a/lib9p/core_tables.h
+++ b/lib9p/core_tables.h
@@ -35,7 +35,7 @@ struct _lib9p_recv_tentry {
};
struct _marshal_ret {
- size_t net_iov_cnt;
+ int net_iov_cnt;
struct iovec *net_iov;
size_t net_copied_size;
uint8_t *net_copied;
diff --git a/lib9p/srv.c b/lib9p/srv.c
index fc5d0f2..a4ac369 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -398,7 +398,7 @@ static void srv_respond_error(struct srv_req *req) {
/* Truncate the error-string if necessary to avoid needing to
* return LIB9P_ERRNO_L_ERANGE. */
if (((uint32_t)host.errstr.len) + overhead > sess->max_msg_size)
- host.errstr.len = sess->max_msg_size - overhead;
+ host.errstr.len = (uint16_t)(sess->max_msg_size - overhead);
struct lib9p_Rmsg_send_buf net;
@@ -409,7 +409,7 @@ static void srv_respond_error(struct srv_req *req) {
srv_msglog(req, LIB9P_TYP_Rerror, &host);
r = srv_write_Rmsg(req, &net);
if (r < 0)
- srv_nonrespond_errorf("write: %s", net_strerror(-r));
+ srv_nonrespond_errorf("write: %s", net_strerror(LM_SAFEDOWNCAST(int, -r)));
}
/* read coroutine *************************************************************/
@@ -421,14 +421,14 @@ static inline bool srv_read_exactly(lo_interface net_stream_conn fd, uint8_t *bu
while (*done < goal) {
ssize_t r = io_read(fd, &buf[*done], goal - *done);
if (r < 0) {
- srv_nonrespond_errorf("read: %s", net_strerror(-r));
+ srv_nonrespond_errorf("read: %s", net_strerror(LM_SAFEDOWNCAST(int, -r)));
return true;
} else if (r == 0) {
if (*done != 0)
srv_nonrespond_errorf("read: unexpected EOF");
return true;
}
- *done += r;
+ *done += LM_SAFEDOWNCAST(size_t, r);
}
return false;
}
@@ -623,7 +623,7 @@ void lib9p_srv_worker(struct srv_req *ctx) {
srv_respond_error(ctx);
goto release;
}
- host_req = calloc(1, host_size);
+ host_req = calloc(1, LM_SAFEDOWNCAST(size_t, host_size));
assert(host_req);
enum lib9p_msg_type typ;
lib9p_Tmsg_unmarshal(&ctx->basectx, ctx->net_bytes,
@@ -1064,7 +1064,7 @@ static void handle_Topen(struct srv_req *ctx,
}
if (stat.mode & LIB9P_DM_APPEND) {
fidflags |= FIDFLAG_APPEND;
- reqmode = reqmode & ~LIB9P_O_TRUNC;
+ reqmode &= LM_BITFLIP(LIB9P_O_TRUNC);
}
uint8_t perm_bits = 0;
bool rd = false, wr = false;
@@ -1277,7 +1277,7 @@ static void handle_Tread(struct srv_req *ctx,
struct iovec iov;
LO_CALL(fidinfo->file.io, pread, ctx, req->count, req->offset, &iov);
if (!lib9p_ctx_has_error(&ctx->basectx) && !ctx->flush_acknowledged) {
- resp.count = iov.iov_len;
+ resp.count = LM_SAFEDOWNCAST(iov.iov_len);
resp.data = iov.iov_base;
if (resp.count > req->count)
resp.count = req->count;
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c
index d7819eb..8490d62 100644
--- a/lib9p/tests/test_server/main.c
+++ b/lib9p/tests/test_server/main.c
@@ -151,7 +151,11 @@ int main(int argc, char *argv[]) {
if (argc != 3)
error(2, 0, "usage: %s PORT_NUMBER LOGFILE", argv[0]);
- globals.port = atoi(argv[1]);
+ int _port = atoi(argv[1]);
+ if (_port == 0 || _port > UINT16_MAX)
+ error(2, 0, "usage: %s PORT_NUMBER LOGFILE", argv[0]);
+
+ globals.port = (uint16_t)_port;
globals.logstream = fopen(argv[2], "w");
if (!globals.logstream)
error(2, errno, "fopen");
diff --git a/lib9p/tests/testclient-sess.c b/lib9p/tests/testclient-sess.c
index 7cb7f97..3e2ba19 100644
--- a/lib9p/tests/testclient-sess.c
+++ b/lib9p/tests/testclient-sess.c
@@ -24,7 +24,7 @@ static void _send9p(int fd, struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void
bool err = lib9p_Tmsg_marshal(ctx, typ, body, &buf);
assert(!err);
size_t exp = 0;
- for (size_t i = 0; i < buf.iov_cnt; i++)
+ for (int i = 0; i < buf.iov_cnt; i++)
exp += buf.iov[i].iov_len;
ssize_t act = writev(fd, buf.iov, buf.iov_cnt);
if (act < 0)
@@ -42,7 +42,7 @@ static void _recv9p(int fd) {
ssize_t n = read(fd, &buf[done], goal-done);
if (n < 0)
error(1, errno, "read");
- done += n;
+ done += (size_t)n;
}
goal = uint32le_decode(buf);
assert(goal <= MAX_MSG_SIZE);
@@ -50,7 +50,7 @@ static void _recv9p(int fd) {
ssize_t n = read(fd, &buf[done], goal-done);
if (n < 0)
error(1, errno, "read");
- done += n;
+ done += (size_t)n;
}
}
@@ -59,7 +59,10 @@ static void _recv9p(int fd) {
int main(int argc, char *argv[]) {
if (argc != 2)
error(2, 0, "Usage: %s SERVER_PORT", argv[0]);
- uint16_t server_port = atoi(argv[1]);
+ int _server_port = atoi(argv[1]);
+ if (_server_port == 0 || _server_port > UINT16_MAX)
+ error(2, 0, "Usage: %s SERVER_PORT", argv[0]);
+ uint16_t server_port = (uint16_t)_server_port;
union {
struct sockaddr gen;
diff --git a/libcr/coroutine.c b/libcr/coroutine.c
index cf63122..7915dcb 100644
--- a/libcr/coroutine.c
+++ b/libcr/coroutine.c
@@ -805,7 +805,7 @@ void cr_cid_info(cid_t cid, struct cr_cid_info *ret) {
uint8_t *stack_hi = stack + coroutine_table[cid-1].stack_size - CR_STACK_GUARD_SIZE;
/* stack_cap */
- ret->stack_cap = stack_hi - stack_lo;
+ ret->stack_cap = (uintptr_t)stack_hi - (uintptr_t)stack_lo;
/* stack_max */
ret->stack_max = ret->stack_cap;
diff --git a/libcr_ipc/tests/test_select.c b/libcr_ipc/tests/test_select.c
index 9b5d117..d8a28c3 100644
--- a/libcr_ipc/tests/test_select.c
+++ b/libcr_ipc/tests/test_select.c
@@ -23,7 +23,7 @@ COROUTINE consumer_cr(void *) {
int arg2ch[10];
for (;;) {
int ret_ch;
- int i_arg = 0;
+ size_t i_arg = 0;
for (int i_ch = 0; i_ch < 10; i_ch++) {
if (!chdone[i_ch]) {
args[i_arg] = CR_SELECT_RECV(&ch[i_ch], &ret_ch);
@@ -35,12 +35,13 @@ COROUTINE consumer_cr(void *) {
break;
args[i_arg] = CR_SELECT_DEFAULT; /* check that default doesn't trigger */
test_assert(i_arg <= 10);
- int ret_arg = cr_select_v(i_arg+1, args);
+ size_t ret_arg = cr_select_v(i_arg+1, args);
test_assert(ret_arg < i_arg);
test_assert(arg2ch[ret_arg] == ret_ch);
chdone[ret_ch] = true;
}
- int ret_ch, ret_arg;
+ int ret_ch;
+ size_t ret_arg;
args[0] = CR_SELECT_RECV(&ch[0], &ret_ch);
args[1] = CR_SELECT_DEFAULT;
ret_arg = cr_select_v(2, args);
diff --git a/libdhcp/dhcp_client.c b/libdhcp/dhcp_client.c
index 2d0ebe6..2c9bd40 100644
--- a/libdhcp/dhcp_client.c
+++ b/libdhcp/dhcp_client.c
@@ -312,7 +312,9 @@ static bool dhcp_client_send(struct dhcp_client *client, uint8_t msgtyp, const c
switch (msgtyp) {
case DHCP_MSGTYP_DISCOVER: case DHCP_MSGTYP_INFORM:
case DHCP_MSGTYP_REQUEST:
- secs = (LO_CALL(bootclock, get_time_ns) - client->time_ns_init)/NS_PER_S;
+ uint64_t secs64 = (LO_CALL(bootclock, get_time_ns) - client->time_ns_init)/NS_PER_S;
+ assert(secs64 < UINT16_MAX); /* 18 hours */
+ secs = LM_SAFEDOWNCAST(uint16_t, secs64);
if (!secs)
/* systemd's sd-dhcp-client.c asserts that some
* servers are broken and require .secs to be
@@ -438,15 +440,16 @@ static bool dhcp_client_send(struct dhcp_client *client, uint8_t msgtyp, const c
assert(val.len);
if (val.len) {
assert(val.len <= UINT16_MAX);
- for (size_t done = 0; done < val.len;) {
- uint8_t len = val.len - done > UINT8_MAX
+ uint16_t len16 = (uint16_t)val.len;
+ for (uint16_t done = 0; done < len16;) {
+ uint8_t len8 = (len16 - done > UINT8_MAX)
? UINT8_MAX
- : val.len - done;
+ : LM_SAFEDOWNCAST(uint8_t, len16 - done);
scratch_msg->options[optlen++] = opt;
- scratch_msg->options[optlen++] = len;
- memcpy(&scratch_msg->options[optlen], &((char*)val.ptr)[done], len);
- optlen += len;
- done += len;
+ scratch_msg->options[optlen++] = len8;
+ memcpy(&scratch_msg->options[optlen], &((char*)val.ptr)[done], len8);
+ optlen += len8;
+ done += len8;
}
}
break;
@@ -484,7 +487,8 @@ struct dhcp_recv_msg {
/** @return whether there is an error */
static inline bool _dhcp_client_recv_measure_opts(struct dhcp_recv_msg *ret, uint8_t *optoverload, uint8_t *dat, size_t len, bool require_pad) {
- for (size_t pos = 0, opt_len; pos < len; pos += opt_len) {
+ uint8_t opt_len;
+ for (size_t pos = 0; pos < len; pos += opt_len) {
uint8_t opt_typ = dat[pos++];
switch (opt_typ) {
case DHCP_OPT_END:
@@ -511,7 +515,8 @@ static inline bool _dhcp_client_recv_measure_opts(struct dhcp_recv_msg *ret, uin
}
static inline void _dhcp_client_recv_consolidate_opts(struct dhcp_recv_msg *ret, uint8_t *dat, size_t len) {
- for (size_t pos = 0, opt_len; pos < len; pos += opt_len) {
+ uint8_t opt_len;
+ for (size_t pos = 0; pos < len; pos += opt_len) {
uint8_t opt_typ = dat[pos++];
switch (opt_typ) {
case DHCP_OPT_END:
@@ -573,15 +578,17 @@ static inline enum requirement dhcp_table3(uint8_t req_msgtyp, uint8_t resp_msgt
static ssize_t dhcp_client_recv(struct dhcp_client *client, struct dhcp_recv_msg *ret) {
struct net_ip4_addr srv_addr;
uint16_t srv_port;
- ssize_t msg_len;
+ ssize_t _msg_len;
+ size_t msg_len;
assert(client);
ignore:
- msg_len = LO_CALL(client->sock, recvfrom, &ret->raw, sizeof(ret->raw), &srv_addr, &srv_port);
- if (msg_len < 0)
+ _msg_len = LO_CALL(client->sock, recvfrom, &ret->raw, sizeof(ret->raw), &srv_addr, &srv_port);
+ if (_msg_len < 0)
/* msg_len is -errno */
- return msg_len;
+ return _msg_len;
+ msg_len = LM_SAFEDOWNCAST(size_t, _msg_len);
/* Validate L3: IP */
/* Don't validate that srv_addr matches client->server_id
@@ -594,10 +601,10 @@ static ssize_t dhcp_client_recv(struct dhcp_client *client, struct dhcp_recv_msg
goto ignore;
/* Validate L5: DHCP. */
- if ((size_t)msg_len < DHCP_MSG_BASE_SIZE + sizeof(dhcp_magic_cookie))
+ if (msg_len < DHCP_MSG_BASE_SIZE + sizeof(dhcp_magic_cookie))
/* ignore impossibly short message */
goto ignore;
- if ((size_t)msg_len > sizeof(ret->raw))
+ if (msg_len > sizeof(ret->raw))
/* ignore message that is larger than the specified
* DHCP_OPT_DHCP_MAX_MSG_SIZE */
goto ignore;
@@ -646,7 +653,8 @@ static ssize_t dhcp_client_recv(struct dhcp_client *client, struct dhcp_recv_msg
true))
goto ignore;
/* Validate sizes, allocate buffers. */
- for (uint8_t opt = 1, allocated = 0; opt < 255; opt++) {
+ uint16_t allocated = 0;
+ for (uint8_t opt = 1; opt < 255; opt++) {
if (!ret->options[opt].len)
continue;
if (!dhcp_opt_length_is_valid(opt, ret->options[opt].len))
diff --git a/libfmt/quote.c b/libfmt/quote.c
index c91e0b0..36e1556 100644
--- a/libfmt/quote.c
+++ b/libfmt/quote.c
@@ -99,7 +99,7 @@ static void libfmt_conv_quote(struct fmt_state *state) {
switch (needs_quote(ch)) {
case QUOTE_NONE:
- fmt_state_putchar(state, ch);
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, ch));
break;
case QUOTE_SIMPLE:
fmt_state_putchar(state, '\\');
@@ -128,14 +128,14 @@ static void libfmt_conv_quote(struct fmt_state *state) {
case QUOTE_U8:
fmt_state_putchar(state, '\\');
fmt_state_putchar(state, 'U');
- fmt_state_putchar(state, (ch >> 28) & 0xF);
- fmt_state_putchar(state, (ch >> 24) & 0xF);
- fmt_state_putchar(state, (ch >> 20) & 0xF);
- fmt_state_putchar(state, (ch >> 16) & 0xF);
- fmt_state_putchar(state, (ch >> 12) & 0xF);
- fmt_state_putchar(state, (ch >> 8) & 0xF);
- fmt_state_putchar(state, (ch >> 4) & 0xF);
- fmt_state_putchar(state, (ch >> 0) & 0xF);
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, (ch >> 28) & 0xF));
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, (ch >> 24) & 0xF));
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, (ch >> 20) & 0xF));
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, (ch >> 16) & 0xF));
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, (ch >> 12) & 0xF));
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, (ch >> 8) & 0xF));
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, (ch >> 4) & 0xF));
+ fmt_state_putchar(state, LM_SAFEDOWNCAST(char, (ch >> 0) & 0xF));
break;
}
continue;
diff --git a/libhw_cr/host_util.h b/libhw_cr/host_util.h
index 02c04dc..3d56e97 100644
--- a/libhw_cr/host_util.h
+++ b/libhw_cr/host_util.h
@@ -19,18 +19,22 @@ typedef struct timespec host_ns_time_t;
static inline host_us_time_t ns_to_host_us_time(uint64_t time_ns) {
host_us_time_t ret;
- ret.tv_sec = time_ns
- /NS_PER_S;
- ret.tv_usec = (time_ns - ((uint64_t)ret.tv_sec)*NS_PER_S)
- /(NS_PER_S/US_PER_S);
+ ret.tv_sec = LM_SAFEDOWNCAST(typeof(ret.tv_sec),
+ time_ns
+ /NS_PER_S);
+ ret.tv_usec = LM_SAFEDOWNCAST(typeof(ret.tv_usec),
+ (time_ns - ((uint64_t)ret.tv_sec)*NS_PER_S)
+ /(NS_PER_S/US_PER_S));
return ret;
}
static inline host_ns_time_t ns_to_host_ns_time(uint64_t time_ns) {
host_ns_time_t ret;
- ret.tv_sec = time_ns
- /NS_PER_S;
- ret.tv_nsec = time_ns - ((uint64_t)ret.tv_sec)*NS_PER_S;
+ ret.tv_sec = LM_SAFEDOWNCAST(typeof(ret.tv_sec),
+ time_ns
+ /NS_PER_S);
+ ret.tv_nsec = LM_SAFEDOWNCAST(typeof(ret.tv_nsec),
+ time_ns - ((uint64_t)ret.tv_sec)*NS_PER_S);
return ret;
}
diff --git a/libhw_cr/rp2040_dma.h b/libhw_cr/rp2040_dma.h
index c7f5a8f..a6f4ae3 100644
--- a/libhw_cr/rp2040_dma.h
+++ b/libhw_cr/rp2040_dma.h
@@ -17,6 +17,7 @@
#include <hardware/regs/dreq.h> /* for DREQ_* for use with DMA_CTRL_TREQ_SEL() */
#include <hardware/structs/dma.h> /* for dma_hw, dma_channel_hw_t, DMA_NUM_CHANNELS */
+#include <libmisc/assert.h>
#include <libmisc/macro.h> /* for LM_FLOORLOG2() */
/* Borrowed from <hardware/dma.h> *********************************************/
@@ -52,20 +53,20 @@ typedef void (*dmairq_handler_t)(void *arg, enum dmairq irq, uint channel);
*/
void dmairq_set_and_enable_exclusive_handler(enum dmairq irq, uint channel, dmairq_handler_t fn, void *arg);
-#define DMA_CTRL_ENABLE (1<<0)
-#define DMA_CTRL_HI_PRIO (1<<1)
-#define DMA_CTRL_DATA_SIZE(sz) ((sz)<<2)
-#define DMA_CTRL_INCR_READ (1<<4)
-#define DMA_CTRL_INCR_WRITE (1<<5)
-#define _DMA_CTRL_RING_BITS(b) ((b)<<6)
-#define _DMA_CTRL_RING_RD (0)
-#define _DMA_CTRL_RING_WR (1<<10)
-#define DMA_CTRL_RING(rdwr, bits) (_DMA_CTRL_RING_##rdwr | _DMA_CTRL_RING_BITS(bits))
-#define DMA_CTRL_CHAIN_TO(ch) ((ch)<<11)
-#define DMA_CTRL_TREQ_SEL(dreq) ((dreq)<<15)
-#define DMA_CTRL_IRQ_QUIET (1<<21)
-#define DMA_CTRL_BSWAP (1<<22)
-#define DMA_CTRL_SNIFF_EN (1<<23)
+#define DMA_CTRL_ENABLE (((uint32_t)1)<<0)
+#define DMA_CTRL_HI_PRIO (((uint32_t)1)<<1)
+#define DMA_CTRL_DATA_SIZE(sz) (((uint32_t)(sz))<<(2 + static_assert_as_expr((sz) <= 0b11)))
+#define DMA_CTRL_INCR_READ (((uint32_t)1)<<4)
+#define DMA_CTRL_INCR_WRITE (((uint32_t)1)<<5)
+#define _DMA_CTRL_RING_BITS(bitcnt) (((uint32_t)(bitcnt))<<(6 + static_assert_as_expr((bitcnt) <= 0b1111)))
+#define _DMA_CTRL_RING_RD ((uint32_t)0)
+#define _DMA_CTRL_RING_WR (((uint32_t)1)<<10)
+#define DMA_CTRL_RING(rdwr, bitcnt) (_DMA_CTRL_RING_##rdwr | _DMA_CTRL_RING_BITS(bitcnt))
+#define DMA_CTRL_CHAIN_TO(ch) (((uint32_t)(ch))<<11)
+#define DMA_CTRL_TREQ_SEL(dreq) (((uint32_t)(dreq))<<(15 + static_assert_as_expr((dreq) <= 0b111111)))
+#define DMA_CTRL_IRQ_QUIET (((uint32_t)1)<<21)
+#define DMA_CTRL_BSWAP (((uint32_t)1)<<22)
+#define DMA_CTRL_SNIFF_EN (((uint32_t)1)<<23)
/* | elem | val | name */
#define READ_ADDR /*|*/volatile const void/*|*/ * /*|*/read_addr
diff --git a/libhw_cr/rp2040_gpioirq.c b/libhw_cr/rp2040_gpioirq.c
index 1ae74f9..8d406c6 100644
--- a/libhw_cr/rp2040_gpioirq.c
+++ b/libhw_cr/rp2040_gpioirq.c
@@ -17,8 +17,6 @@ struct gpioirq_handler_entry {
};
struct gpioirq_handler_entry gpioirq_handlers[NUM_BANK0_GPIOS][4] = {0};
-int gpioirq_core = -1;
-
static void gpioirq_handler(void) {
uint core = get_core_num();
io_bank0_irq_ctrl_hw_t *irq_ctrl_base;
@@ -44,6 +42,8 @@ static void gpioirq_handler(void) {
}
void gpioirq_set_and_enable_exclusive_handler(uint gpio, enum gpio_irq_level event, gpioirq_handler_t fn, void *arg) {
+ static uint gpioirq_core = ~0U;
+
assert(gpio < NUM_BANK0_GPIOS);
assert(event == GPIO_IRQ_LEVEL_LOW ||
event == GPIO_IRQ_LEVEL_HIGH ||
@@ -55,7 +55,7 @@ void gpioirq_set_and_enable_exclusive_handler(uint gpio, enum gpio_irq_level eve
assert(gpioirq_handlers[gpio][event_idx].fn == NULL);
uint core = get_core_num();
- assert(gpioirq_core == -1 || gpioirq_core == (int)core);
+ assert(gpioirq_core == ~0U || gpioirq_core == core);
io_bank0_irq_ctrl_hw_t *irq_ctrl_base;
switch (core) {
@@ -67,7 +67,7 @@ void gpioirq_set_and_enable_exclusive_handler(uint gpio, enum gpio_irq_level eve
gpioirq_handlers[gpio][event_idx].fn = fn;
gpioirq_handlers[gpio][event_idx].arg = arg;
hw_set_bits(&irq_ctrl_base->inte[gpio/8], 1u<<((4*(gpio%8))+event_idx));
- if (gpioirq_core == -1) {
+ if (gpioirq_core == ~0U) {
irq_set_exclusive_handler(IO_IRQ_BANK0, gpioirq_handler);
irq_set_enabled(IO_IRQ_BANK0, true);
gpioirq_core = core;
diff --git a/libhw_cr/rp2040_hwtimer.c b/libhw_cr/rp2040_hwtimer.c
index 8227abb..7813dfa 100644
--- a/libhw_cr/rp2040_hwtimer.c
+++ b/libhw_cr/rp2040_hwtimer.c
@@ -109,9 +109,9 @@ static bool rp2040_hwtimer_add_trigger(struct rp2040_hwtimer *alarmclock,
*dst = trigger;
if (!alarmclock->initialized) {
hw_set_bits(&timer_hw->inte, 1 << alarmclock->alarm_num);
- irq_set_exclusive_handler(TIMER_ALARM_IRQ_NUM(timer_hw, alarmclock->alarm_num),
- rp2040_hwtimer_intrhandler);
- irq_set_enabled(TIMER_ALARM_IRQ_NUM(timer_hw, alarmclock->alarm_num), true);
+ uint irq_num = (uint)TIMER_ALARM_IRQ_NUM(timer_hw, alarmclock->alarm_num);
+ irq_set_exclusive_handler(irq_num, rp2040_hwtimer_intrhandler);
+ irq_set_enabled(irq_num, true);
alarmclock->initialized = true;
}
if (alarmclock->queue == trigger) {
diff --git a/libhw_cr/w5500.c b/libhw_cr/w5500.c
index e676364..8ec3f4d 100644
--- a/libhw_cr/w5500.c
+++ b/libhw_cr/w5500.c
@@ -68,6 +68,10 @@
*/
#include <inttypes.h> /* for PRIu{n} */
+#include <limits.h> /* for SSIZE_MAX, not set by newlib */
+#ifndef SSIZE_MAX
+#define SSIZE_MAX (SIZE_MAX >> 1)
+#endif
/* TODO: Write a <libhw/generic/gpio.h> to avoid w5500.c being
* pico-sdk-specific. */
@@ -318,14 +322,15 @@ void _w5500_init(struct w5500 *chip,
#if CONFIG_W5500_VALIDATE_SPI
/* Validate that SPI works correctly. */
bool spi_ok = true;
- for (uint16_t a = 0; a < 0x100; a++) {
+ uint8_t a = 0;
+ do {
w5500ll_write_sock_reg(chip->spidev, 0, mode, a);
uint8_t b = w5500ll_read_sock_reg(chip->spidev, 0, mode);
if (b != a) {
log_errorf("SPI to W5500 does not appear to be functional: wrote:0x%02"PRIx16" != read:0x%02"PRIx8, a, b);
spi_ok = false;
}
- }
+ } while (a++ != 0xff);
if (!spi_ok)
__lm_abort();
w5500ll_write_sock_reg(chip->spidev, 0, mode, 0);
@@ -612,6 +617,7 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec
ASSERT_SELF(stream_conn, TCP);
if (count == 0)
return 0;
+ assert(count <= SSIZE_MAX);
/* What we really want is to pause until we receive an ACK for
* some data we just queued, so that we can line up some new
@@ -657,7 +663,7 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec
/* Queue data to be sent. */
if ((size_t)freesize > count-done)
- freesize = count-done;
+ freesize = (uint16_t)(count-done);
uint16_t ptr = uint16be_unmarshal(w5500ll_read_sock_reg(chip->spidev, socknum, tx_write_pointer));
w5500ll_writev(chip->spidev, ptr, CTL_BLOCK_SOCK(socknum, TX), iov, iovcnt, done, freesize);
w5500ll_write_sock_reg(chip->spidev, socknum, tx_write_pointer, uint16be_marshal(ptr+freesize));
@@ -681,7 +687,8 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec
}
}
log_debugf(" => send finished");
- return done;
+ assert(done <= count); /* because we validated that count <= SSIZE_MAX */
+ return (ssize_t)done;
}
static void w5500_tcp_set_read_deadline(struct _w5500_socket *socket, uint64_t ns) {
@@ -759,7 +766,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec
uint16_t ptr = uint16be_unmarshal(w5500ll_read_sock_reg(chip->spidev, socknum, rx_read_pointer));
/* Read the data. */
if ((size_t)avail > count)
- avail = count;
+ avail = (uint16_t)count;
w5500ll_readv(chip->spidev, ptr, CTL_BLOCK_SOCK(socknum, RX), iov, iovcnt, avail);
/* Tell the chip that we read the data. */
w5500ll_write_sock_reg(chip->spidev, socknum, rx_read_pointer, uint16be_marshal(ptr+avail));
@@ -807,18 +814,19 @@ static int w5500_tcp_close_write(struct _w5500_socket *socket) { return w5500_tc
/* udp_conn methods ***********************************************************/
-static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t count,
+static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t _count,
struct net_ip4_addr node, uint16_t port) {
log_debugf("udp_conn.sendto()");
ASSERT_SELF(packet_conn, UDP);
assert(buf);
- assert(count);
+ assert(_count);
uint16_t bufsize = ((uint16_t)w5500ll_read_sock_reg(chip->spidev, socknum, tx_buf_size))*1024;
- if (count > bufsize) {
+ if (_count > (size_t)bufsize) {
log_debugf(" => msg too large");
return -NET_EMSGSIZE;
}
+ uint16_t count = (uint16_t)_count;
for (;;) {
cr_mutex_lock(&chip->mu);
@@ -944,7 +952,7 @@ static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_
.iov_len = len,
}), 1, 0);
/* Tell the chip that we read the data. */
- w5500ll_write_sock_reg(chip->spidev, socknum, rx_read_pointer, uint16be_marshal(ptr+8+len));
+ w5500ll_write_sock_reg(chip->spidev, socknum, rx_read_pointer, uint16be_marshal((uint16_t)(ptr+len+8)));
w5500_socket_cmd(socket, CMD_RECV);
/* Return. */
LO_CALL(bootclock, del_trigger, &trigger);
diff --git a/libmisc/include/libmisc/macro.h b/libmisc/include/libmisc/macro.h
index 1712f7d..43a00f6 100644
--- a/libmisc/include/libmisc/macro.h
+++ b/libmisc/include/libmisc/macro.h
@@ -120,11 +120,63 @@
#define LM_BIT_XOR(a, b) ((typeof(a))(((a)^(b)) + static_assert_as_expr(__builtin_types_compatible_p(typeof(a), typeof(b)))))
#define LM_BIT_FLIP(a) ((typeof(a))(~(a)))
-#define LM_CEILDIV(n, d) ( ((n)+(d)-1) / (d) ) /** Return ceil(n/d) */
-#define LM_ROUND_UP(n, d) ( LM_CEILDIV(n, d) * (d) ) /** Return `n` rounded up to the nearest multiple of `d` */
-#define LM_ROUND_DOWN(n, d) ( ((n)/(d)) * (d) ) /** Return `n` rounded down to the nearest multiple of `d` */
-#define LM_NEXT_POWER_OF_2(x) ( (x) ? 1ULL<<((sizeof(unsigned long long)*8)-__builtin_clzll(x)) : 1) /** Return the lowest power of 2 that is > x */
-#define LM_FLOORLOG2(x) ((sizeof(unsigned long long)*8)-__builtin_clzll(x)-1) /** Return floor(log_2(x) */
+#define LM_CEILDIV(n, d) ( ((n)+(d)-1) / (d) ) /** Return ceil(n/d) */
+#define LM_ROUND_UP(n, d) ( LM_CEILDIV(n, d) * (d) ) /** Return `n` rounded up to the nearest multiple of `d` */
+#define LM_ROUND_DOWN(n, d) ( ((n)/(d)) * (d) ) /** Return `n` rounded down to the nearest multiple of `d` */
+#define LM_NEXT_POWER_OF_2(x) ( (x) ? 1ULL<<((sizeof(unsigned long long)*8)-(unsigned)__builtin_clzll(x)) : 1) /** Return the lowest power of 2 that is > x */
+#define LM_FLOORLOG2(x) ((sizeof(unsigned long long)*8)-(unsigned)__builtin_clzll(x)-1) /** Return floor(log_2(x) */
+
+#define _LM_PROP_SIGNED(TYP) _Generic((TYP)0, \
+ unsigned char : 0, \
+ unsigned short : 0, \
+ unsigned : 0, \
+ unsigned long : 0, \
+ unsigned long long : 0, \
+ signed char : 1, \
+ short : 1, \
+ int : 1, \
+ long : 1, \
+ long long : 1)
+#define _LM_PROP_MIN(TYP) _Generic((TYP)0, \
+ unsigned char : 0, \
+ unsigned short : 0, \
+ unsigned : 0, \
+ unsigned long : 0, \
+ unsigned long long : 0, \
+ signed char : SCHAR_MIN, \
+ short : SHRT_MIN, \
+ int : INT_MIN, \
+ long : LONG_MIN, \
+ long long : LLONG_MIN)
+#define _LM_PROP_MAX(TYP) _Generic((TYP)0, \
+ unsigned char : UCHAR_MAX, \
+ unsigned short : USHRT_MAX, \
+ unsigned : UINT_MAX, \
+ unsigned long : ULONG_MAX, \
+ unsigned long long : ULLONG_MAX, \
+ signed char : SCHAR_MAX, \
+ short : SHRT_MAX, \
+ int : INT_MAX, \
+ long : LONG_MAX, \
+ long long : LLONG_MAX)
+
+#define LM_SAFEDOWNCAST(TYP, x) ({ \
+ typeof(x) _x = (x); \
+ /* Assert that it's a downcast (that this macro is being used \
+ * correctly). We're a little forgiving (<= instead of <) to allow \
+ * this to be used for types that are different relative sizes on \
+ * different architectures. */ \
+ static_assert(sizeof((TYP)0) <= sizeof(_x) || \
+ _LM_PROP_SIGNED(TYP) != _LM_PROP_SIGNED(typeof(_x))); \
+ /* Assert that x is within the new bounds. */ \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \
+ assert(_LM_PROP_MIN(TYP) <= _x && _x <= _LM_PROP_MAX(TYP)); \
+ _Pragma("GCC diagnostic pop") \
+ (TYP)_x; \
+})
+
+LM_BITFLIP(TYP, x) ({ TYP _x = x; (TYP)~_x; })
/* strings */
diff --git a/libmisc/include/libmisc/rand.h b/libmisc/include/libmisc/rand.h
index 784e580..b54dee0 100644
--- a/libmisc/include/libmisc/rand.h
+++ b/libmisc/include/libmisc/rand.h
@@ -17,13 +17,13 @@
* Return a psuedo-random number in the half-open interval [0,cnt).
* `cnt` must not be greater than 1<<63.
*/
-static inline uint64_t rand_uint63n(uint64_t cnt) {
+static inline uint64_t _rand_uint63n(uint64_t cnt) {
assert(cnt != 0 && ((cnt-1) & 0x8000000000000000) == 0);
if (cnt <= LM_BIT(uint64_t, 31)) {
uint32_t fair_cnt = LM_ROUND_DOWN(LM_BIT(uint32_t, 31), cnt);
uint32_t rnd;
do {
- rnd = random();
+ rnd = LM_UPCAST(uint32_t, random());
} while (rnd >= fair_cnt);
return rnd % cnt;
} else if (cnt <= LM_BIT(uint64_t, 62)) {
@@ -37,11 +37,12 @@ static inline uint64_t rand_uint63n(uint64_t cnt) {
uint64_t fair_cnt = LM_ROUND_DOWN(LM_BIT(uint64_t, 63), cnt);
uint64_t rnd;
do {
- rnd = (LM_UPCAST(uint64_t, random()) << 62) | (LM_UPCAST(uint64_t, random()) << 31) | LM_UPCAST(random();
+ rnd = (LM_UPCAST(uint64_t, random()) << 62) | (LM_UPCAST(uint64_t, random()) << 31) | LM_UPCAST(uint64_t, random());
} while (rnd >= fair_cnt);
return rnd % cnt;
}
assert_notreached("cnt is out of bounds");
}
+#define rand_uint63n(cnt) ((typeof(cnt))_rand_uint63n(cnt))
#endif /* _LIBMISC_RAND_H_ */
diff --git a/libmisc/map.c b/libmisc/map.c
index d703966..f354f07 100644
--- a/libmisc/map.c
+++ b/libmisc/map.c
@@ -211,7 +211,7 @@ bool _map_iter_next(struct _map_iter *state) {
struct _map_kv_list_node *old_kv = state->kv;
state->kv = old_kv->rear;
- old_kv->val.flags &= ~FLAG_ITER;
+ old_kv->val.flags &= flip8(FLAG_ITER);
if (old_kv->val.flags & FLAG_DEL) {
dlist_remove(&state->m->buckets[state->i], old_kv);
free(old_kv);
diff --git a/libmisc/tests/test_obj_nest.c b/libmisc/tests/test_obj_nest.c
index bb9d6de..be303f2 100644
--- a/libmisc/tests/test_obj_nest.c
+++ b/libmisc/tests/test_obj_nest.c
@@ -5,6 +5,10 @@
*/
#include <string.h> /* for memcpy() */
+#include <limits.h> /* for SSIZE_MAX, not set by newlib */
+#ifndef SSIZE_MAX
+#define SSIZE_MAX (SIZE_MAX >> 1)
+#endif
#include <libmisc/obj.h>
@@ -45,8 +49,10 @@ static ssize_t myclass_read(struct myclass *self, void *buf, size_t count) {
test_assert(self);
if (count > self->len)
count = self->len;
+ if (count > SSIZE_MAX)
+ count = SSIZE_MAX;
memcpy(buf, self->buf, count);
- return count;
+ return (ssize_t)count;
}
static ssize_t myclass_write(struct myclass *self, void *buf, size_t count) {
@@ -55,9 +61,11 @@ static ssize_t myclass_write(struct myclass *self, void *buf, size_t count) {
return -1;
if (count > sizeof(self->buf))
count = sizeof(self->buf);
+ if (count > SSIZE_MAX)
+ count = SSIZE_MAX;
memcpy(self->buf, buf, count);
self->len = count;
- return count;
+ return (ssize_t)count;
}
/* main test body *************************************************************/
diff --git a/libmisc/tests/test_rand.c b/libmisc/tests/test_rand.c
index 02f4c1c..b98dacf 100644
--- a/libmisc/tests/test_rand.c
+++ b/libmisc/tests/test_rand.c
@@ -53,14 +53,14 @@ static void test_n(uint64_t cnt) {
bool seen[MAX_SEE_ALL] = {0};
for (int i = 0; i < ROUNDS; i++) {
uint64_t val = rand_uint63n(cnt);
- sum += val;
+ sum += (double)val;
test_assert(val < cnt);
if (cnt < MAX_SEE_ALL)
seen[val] = true;
}
if (cnt > 1) {
- test_assert(sum/ROUNDS > 0.45*(cnt-1));
- test_assert(sum/ROUNDS < 0.55*(cnt-1));
+ test_assert(sum/ROUNDS > 0.45*(double)(cnt-1));
+ test_assert(sum/ROUNDS < 0.55*(double)(cnt-1));
}
if (cnt < MAX_SEE_ALL) {
for (uint64_t i = 0; i < cnt; i++)
diff --git a/libusb/usb_common.c b/libusb/usb_common.c
index efd12bc..179222e 100644
--- a/libusb/usb_common.c
+++ b/libusb/usb_common.c
@@ -77,8 +77,8 @@ uint16_t const *tud_descriptor_string_cb(uint8_t strid, uint16_t langid) {
return NULL;
}
}
- assert(bytelen <= sizeof desc.bString);
- desc.bLength = bytelen + 2;
+ assert(bytelen <= sizeof(desc.bString) && sizeof(desc.bString) <= UINT8_MAX);
+ desc.bLength = (uint8_t)bytelen + 2;
desc.bDescriptorType = TUSB_DESC_STRING;
return (uint16_t *)&desc;
}
@@ -123,12 +123,12 @@ uint8_t usb_add_config(uint8_t iConfiguration, uint8_t bmAttributes, uint8_t bMa
memcpy(desc, (uint8_t[]){
/* USB configuration descriptor header (USB 2.0 ยง9.6.4 "Configuration") */
TUD_CONFIG_DESCRIPTOR(
- globals.configc, /* bConfigurationValue */
- 0, /* bNumInterfaces (will be incremented by usb_add_interface() */
- iConfiguration, /* iConfiguration */
- TUD_CONFIG_DESC_LEN, /* wTotalLength (will be incremented by usb_add_interface() */
- bmAttributes, /* bmAttributes */
- bMaxPower_mA+1), /* bMaxPower (+1 because tusb just does n/2 instead of (n+1)/2) */
+ globals.configc, /* bConfigurationValue */
+ 0, /* bNumInterfaces (will be incremented by usb_add_interface() */
+ iConfiguration, /* iConfiguration */
+ TUD_CONFIG_DESC_LEN, /* wTotalLength (will be incremented by usb_add_interface() */
+ bmAttributes, /* bmAttributes */
+ (uint8_t)(bMaxPower_mA+1)), /* bMaxPower (+1 because tusb just does n/2 instead of (n+1)/2) */
}, TUD_CONFIG_DESC_LEN);
return globals.configc;