Add proper casts to silence VC warnings.

parent f1523d24
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#define sleep(x) Sleep(x * 1000) #define sleep(x) Sleep(x * 1000)
#define usleep(x) Sleep((DWORD)((x)<1000) ? 1 : ((x)/1000)) #define usleep(x) Sleep((DWORD)(((x)<1000) ? 1 : ((x)/1000)))
#else #else
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
......
...@@ -335,7 +335,7 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte ...@@ -335,7 +335,7 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte
len = i - start_pos; len = i - start_pos;
if (len > UINT16_MAX) { if (len > UINT16_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "tr pattern too long (max 65536)"); mrb_raise(mrb, E_ARGUMENT_ERROR, "tr pattern too long (max 65535)");
} }
if (pat1 == NULL && ret) { if (pat1 == NULL && ret) {
goto nomem; goto nomem;
...@@ -343,9 +343,9 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte ...@@ -343,9 +343,9 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte
pat1->type = TR_IN_ORDER; pat1->type = TR_IN_ORDER;
pat1->flag_reverse = flag_reverse; pat1->flag_reverse = flag_reverse;
pat1->flag_on_heap = !ret_uninit; pat1->flag_on_heap = !ret_uninit;
pat1->n = len; pat1->n = (uint16_t)len;
pat1->next = NULL; pat1->next = NULL;
pat1->val.start_pos = start_pos; pat1->val.start_pos = (uint16_t)start_pos;
} }
if (ret == NULL || ret_uninit) { if (ret == NULL || ret_uninit) {
......
...@@ -160,7 +160,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl, ...@@ -160,7 +160,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl,
out(f, prefix, pl); out(f, prefix, pl);
out(f, ss, 3); out(f, ss, 3);
pad(f, ' ', w, 3+pl, fl^LEFT_ADJ); pad(f, ' ', w, 3+pl, fl^LEFT_ADJ);
return MAX(w, 3+(int)pl); return (int)MAX(w, 3+pl);
} }
y = frexp((double)y, &e2) * 2; y = frexp((double)y, &e2) * 2;
...@@ -215,7 +215,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl, ...@@ -215,7 +215,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl,
pad(f, '0', l-(ebuf-estr)-(s-buf), 0, 0); pad(f, '0', l-(ebuf-estr)-(s-buf), 0, 0);
out(f, estr, ebuf-estr); out(f, estr, ebuf-estr);
pad(f, ' ', w, pl+l, fl^LEFT_ADJ); pad(f, ' ', w, pl+l, fl^LEFT_ADJ);
return MAX(w, (int)pl+(int)l); return (int)MAX(w, pl+l);
} }
if (p<0) p=6; if (p<0) p=6;
...@@ -366,7 +366,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl, ...@@ -366,7 +366,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl,
pad(f, ' ', w, pl+l, fl^LEFT_ADJ); pad(f, ' ', w, pl+l, fl^LEFT_ADJ);
return MAX(w, (int)pl+(int)l); return (int)MAX(w, pl+l);
} }
static int static int
...@@ -440,7 +440,7 @@ mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_fl ...@@ -440,7 +440,7 @@ mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_fl
mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid format string"); mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid format string");
} }
*cstr.buf = '\0'; *cstr.buf = '\0';
return cstr.buf - buf; return (int)cstr.buf - buf;
} }
#else /* MRB_DISABLE_STDIO || _WIN32 || _WIN64 */ #else /* MRB_DISABLE_STDIO || _WIN32 || _WIN64 */
#include <mruby.h> #include <mruby.h>
......
...@@ -365,7 +365,7 @@ ht_put(mrb_state *mrb, htable *t, mrb_value key, mrb_value val) ...@@ -365,7 +365,7 @@ ht_put(mrb_state *mrb, htable *t, mrb_value key, mrb_value val)
if (!seg->next && i >= t->last_len) { if (!seg->next && i >= t->last_len) {
seg->e[i].key = key; seg->e[i].key = key;
seg->e[i].val = val; seg->e[i].val = val;
t->last_len = i+1; t->last_len = (uint16_t)i+1;
t->size++; t->size++;
return; return;
} }
...@@ -407,7 +407,7 @@ ht_put(mrb_state *mrb, htable *t, mrb_value key, mrb_value val) ...@@ -407,7 +407,7 @@ ht_put(mrb_state *mrb, htable *t, mrb_value key, mrb_value val)
} }
seg->e[i].key = key; seg->e[i].key = key;
seg->e[i].val = val; seg->e[i].val = val;
t->last_len = i+1; t->last_len = (uint16_t)i+1;
if (t->index == NULL && t->size > MRB_HT_INIT_SIZE*4) { if (t->index == NULL && t->size > MRB_HT_INIT_SIZE*4) {
ht_index(mrb, t); ht_index(mrb, t);
} }
......
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