Skip to content

Commit

Permalink
remove SIZE_ERROR() macro
Browse files Browse the repository at this point in the history
It's only used once and in that case it isn't necessary anyway, since
size_t must be at least 32 bits wide and
the max. length of a filename is UINT16_MAX.
  • Loading branch information
cremno committed Apr 29, 2015
1 parent 4a82b93 commit aaf2615
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/load.c
Expand Up @@ -26,10 +26,8 @@

#if SIZE_MAX < UINT32_MAX
# define SIZE_ERROR_MUL(x, y) ((x) > SIZE_MAX / (y))
# define SIZE_ERROR(x) ((x) > SIZE_MAX)
#else
# define SIZE_ERROR_MUL(x, y) (0)
# define SIZE_ERROR(x) (0)
#endif

static size_t
Expand Down Expand Up @@ -239,9 +237,6 @@ read_lineno_record_1(mrb_state *mrb, const uint8_t *bin, mrb_irep *irep, size_t
fname_len = bin_to_uint16(bin);
bin += sizeof(uint16_t);
*len += sizeof(uint16_t);
if (SIZE_ERROR(fname_len + 1)) {
return MRB_DUMP_GENERAL_FAILURE;
}
fname = (char *)mrb_malloc(mrb, fname_len + 1);
memcpy(fname, bin, fname_len);
fname[fname_len] = '\0';
Expand Down Expand Up @@ -667,7 +662,6 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
return NULL;
}

/* You don't need use SIZE_ERROR as buf_size is enough small. */
buf = (uint8_t*)mrb_malloc(mrb, header_size);
if (fread(buf, header_size, 1, fp) == 0) {
mrb_free(mrb, buf);
Expand Down

0 comments on commit aaf2615

Please sign in to comment.