diff --git a/src/libty/firmware.c b/src/libty/firmware.c index b8e82cf..9c193c1 100644 --- a/src/libty/firmware.c +++ b/src/libty/firmware.c @@ -161,10 +161,10 @@ static ssize_t read_memory(int64_t offset, uint8_t *buf, size_t len, void *udata if (offset < 0) offset = ctx->offset; - if (offset > ctx->len) + if ((size_t)offset > ctx->len) return ty_error(TY_ERROR_RANGE, "Cannot seek beyond end of file '%s'", ctx->filename); - size_t copy_len = _HS_MIN(ctx->len - offset, len); + size_t copy_len = _HS_MIN((size_t)ctx->len - (size_t)offset, (size_t)len); memcpy(buf, ctx->mem + offset, copy_len); ctx->offset += (int64_t)copy_len; diff --git a/src/libty/firmware_elf.c b/src/libty/firmware_elf.c index 8a29edc..cd4acc0 100644 --- a/src/libty/firmware_elf.c +++ b/src/libty/firmware_elf.c @@ -96,7 +96,7 @@ static int read_chunk(struct loader_context *ctx, int64_t offset, void *buf, siz r = (*ctx->func)(offset, (uint8_t *)buf, size, ctx->udata); if (r < 0) return (int)r; - if (r < size) + if ((size_t)r < size) goto truncated; return 0; diff --git a/src/libty/firmware_ihex.c b/src/libty/firmware_ihex.c index 11aa4bb..6340f8a 100644 --- a/src/libty/firmware_ihex.c +++ b/src/libty/firmware_ihex.c @@ -155,7 +155,7 @@ int ty_firmware_load_ihex(ty_firmware *fw, ty_firmware_read_func *func, void *ud { assert(fw); assert(!fw->segments_count && !fw->total_size); - assert(mem || !len); + assert(func); struct parser_context ctx = {0}; _HS_ARRAY(uint8_t) buf = {0};