Fix `mrb_int` and `size_t` combination warnings.

parent 4695dfdc
......@@ -52,7 +52,7 @@ MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, mrb_irep *irep, ptrdi
* get line from irep's debug info and program counter
* @return returns -1 if not found
*/
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc);
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, size_t pc);
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
......
......@@ -21,7 +21,7 @@ struct mrb_state;
#define MRB_EACH_OBJ_BREAK 1
typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data);
mrb_int mrb_objspace_page_slot_size(void);
size_t mrb_objspace_page_slot_size(void);
MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c);
#ifndef MRB_GC_ARENA_SIZE
......
......@@ -23,7 +23,7 @@ struct RHash {
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
mrb_int mrb_os_memsize_of_hash_table(mrb_value obj);
size_t mrb_os_memsize_of_hash_table(mrb_value obj);
MRB_API mrb_value mrb_hash_new_capa(mrb_state *mrb, mrb_int capa);
MRB_API mrb_value mrb_ensure_hash_type(mrb_state *mrb, mrb_value hash);
MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
......
......@@ -35,7 +35,7 @@ mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
mrb_int mrb_obj_iv_tbl_memsize(mrb_state*, mrb_value);
size_t mrb_obj_iv_tbl_memsize(mrb_state*, mrb_value);
MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
......
......@@ -6380,7 +6380,7 @@ MRB_API void
mrb_parser_set_filename(struct mrb_parser_state *p, const char *f)
{
mrb_sym sym;
size_t i;
uint16_t i;
mrb_sym* new_table;
sym = mrb_intern_cstr(p->mrb, f);
......@@ -6389,7 +6389,7 @@ mrb_parser_set_filename(struct mrb_parser_state *p, const char *f)
for (i = 0; i < p->filename_table_length; ++i) {
if (p->filename_table[i] == sym) {
p->current_filename_index = (int)i;
p->current_filename_index = i;
return;
}
}
......
......@@ -12177,7 +12177,7 @@ MRB_API void
mrb_parser_set_filename(struct mrb_parser_state *p, const char *f)
{
mrb_sym sym;
size_t i;
uint16_t i;
mrb_sym* new_table;
sym = mrb_intern_cstr(p->mrb, f);
......@@ -12186,7 +12186,7 @@ mrb_parser_set_filename(struct mrb_parser_state *p, const char *f)
for (i = 0; i < p->filename_table_length; ++i) {
if (p->filename_table[i] == sym) {
p->current_filename_index = (int)i;
p->current_filename_index = i;
return;
}
}
......
......@@ -11,16 +11,18 @@
#include <mruby/value.h>
#include <mruby/range.h>
static mrb_int
static size_t
os_memsize_of_ivars(mrb_state* mrb, mrb_value obj)
{
return mrb_obj_iv_tbl_memsize(mrb, obj);
}
static mrb_int
static size_t
os_memsize_of_irep(mrb_state* state, const struct mrb_irep *irep)
{
mrb_int size, i;
size_t size;
int i;
size = (irep->slen * sizeof(mrb_sym)) +
(irep->plen * sizeof(mrb_code)) +
(irep->ilen * sizeof(mrb_code));
......@@ -31,10 +33,10 @@ os_memsize_of_irep(mrb_state* state, const struct mrb_irep *irep)
return size;
}
static mrb_int
static size_t
os_memsize_of_method(mrb_state* mrb, mrb_value method_obj)
{
mrb_int size;
size_t size;
mrb_value proc_value = mrb_obj_iv_get(mrb, mrb_obj_ptr(method_obj),
mrb_intern_lit(mrb, "_proc"));
struct RProc *proc = mrb_proc_ptr(proc_value);
......@@ -57,10 +59,10 @@ obj_is_kind_of_checked(mrb_state *mrb, mrb_value obj, const char *classname)
return FALSE;
}
static mrb_int
static size_t
os_memsize_of_object(mrb_state* mrb, mrb_value obj)
{
mrb_int size = 0;
size_t size = 0;
switch(mrb_type(obj)) {
case MRB_TT_STRING:
......@@ -178,17 +180,17 @@ os_memsize_of_object(mrb_state* mrb, mrb_value obj)
static mrb_value
os_memsize_of(mrb_state *mrb, mrb_value self)
{
mrb_int total;
size_t total;
mrb_value obj;
mrb_get_args(mrb, "o", &obj);
total = os_memsize_of_object(mrb, obj);
return mrb_fixnum_value(total);
return mrb_fixnum_value((mrb_int)total);
}
struct os_memsize_of_all_cb_data {
mrb_int t;
size_t t;
struct RClass *type;
};
......@@ -225,7 +227,7 @@ os_memsize_of_all(mrb_state *mrb, mrb_value self)
struct os_memsize_of_all_cb_data data = { 0 };
mrb_get_args(mrb, "|c", &data.type);
mrb_objspace_each_objects(mrb, os_memsize_of_all_cb, &data);
return mrb_fixnum_value(data.t);
return mrb_fixnum_value((mrb_int)data.t);
}
void
......
......@@ -413,13 +413,13 @@ unpack_q(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, un
i64tostr(msg, sizeof(msg), sll);
mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg);
}
n = sll;
n = (mrb_int)sll;
} else {
if (!POSFIXABLE(ull)) {
u64tostr(msg, sizeof(msg), ull);
mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg);
}
n = ull;
n = (mrb_int)ull;
}
mrb_ary_push(mrb, ary, mrb_fixnum_value(n));
return 8;
......@@ -828,7 +828,7 @@ unpack_h(mrb_state *mrb, const void *src, int slen, mrb_value ary, int count, un
}
}
dst = mrb_str_resize(mrb, dst, dptr - dptr0);
dst = mrb_str_resize(mrb, dst, (mrb_int)(dptr - dptr0));
mrb_ary_push(mrb, ary, dst);
return (int)(sptr - sptr0);
}
......@@ -951,7 +951,7 @@ unpack_m(mrb_state *mrb, const void *src, int slen, mrb_value ary, unsigned int
}
done:
dst = mrb_str_resize(mrb, dst, dptr - dptr0);
dst = mrb_str_resize(mrb, dst, (mrb_int)(dptr - dptr0));
mrb_ary_push(mrb, ary, dst);
return (int)(sptr - sptr0);
}
......
......@@ -66,7 +66,7 @@ mrb_f_sleep(mrb_state *mrb, mrb_value self)
#endif
end = time(0) - beg;
return mrb_fixnum_value(end);
return mrb_fixnum_value((mrb_int)end);
}
/* mruby special; needed for mruby without float numbers */
......
......@@ -64,7 +64,7 @@ mrb_debug_get_filename(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc)
}
MRB_API int32_t
mrb_debug_get_line(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc)
mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, size_t pc)
{
if (irep && pc >= 0 && pc < irep->ilen) {
mrb_irep_debug_info_file* f = NULL;
......
......@@ -1601,11 +1601,10 @@ mrb_objspace_each_objects(mrb_state *mrb, mrb_each_object_callback *callback, vo
}
}
mrb_int
size_t
mrb_objspace_page_slot_size(void)
{
const mrb_int i = sizeof(RVALUE);
return i;
return sizeof(RVALUE);
}
#ifdef GC_TEST
......
......@@ -523,13 +523,13 @@ ht_foreach(mrb_state *mrb, htable *t, mrb_hash_foreach_func *func, void *p)
}
}
mrb_int
size_t
mrb_os_memsize_of_hash_table(mrb_value obj)
{
struct htable *h = mrb_hash_ptr(obj)->ht;
mrb_int segkv_size = 0;
size_t segkv_size = 0;
if(h->index) segkv_size = (sizeof(struct segkv) * h->index->capa);
if (h->index) segkv_size = (sizeof(struct segkv) * h->index->capa);
return sizeof(htable) +
sizeof(segindex) +
......
......@@ -54,7 +54,7 @@ str_to_double(mrb_state *mrb, const char *p, size_t len)
}
#endif
mrb_value mrb_str_len_to_inum(mrb_state *mrb, const char *str, mrb_int len, mrb_int base, int badcheck);
mrb_value mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, mrb_int base, int badcheck);
static void
tempirep_free(mrb_state *mrb, void *p)
......
......@@ -2258,7 +2258,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
}
mrb_value
mrb_str_len_to_inum(mrb_state *mrb, const char *str, mrb_int len, mrb_int base, int badcheck)
mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, mrb_int base, int badcheck)
{
const char *p = str;
const char *pend = str + len;
......
......@@ -1128,7 +1128,7 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
return path;
}
mrb_int
size_t
mrb_obj_iv_tbl_memsize(mrb_state* mrb, mrb_value obj)
{
size_t nseg = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment