Skip to content

Commit

Permalink
Fix a bunch of conversion warnings and asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Koromix committed Dec 31, 2021
1 parent 33c904c commit 1acb127
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/libty/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/libty/firmware_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libty/firmware_ihex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit 1acb127

Please sign in to comment.