diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-02-14 10:55:54 +0100 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-02-14 10:55:54 +0100 |
| commit | 18c299b13dd568669176fb1c713c79dfb4890bbe (patch) | |
| tree | 32fdb41caa0e39479abdecee1c64784ce7145b48 /py | |
| parent | 9ed3e11aec6ed40a86fa846b9fe2fa76224d8c05 (diff) | |
Make mp_float_t conversions explicit to silence warnings of converting floats to doubles.
Diffstat (limited to 'py')
| -rw-r--r-- | py/binary.c | 4 | ||||
| -rw-r--r-- | py/objarray.c | 2 | ||||
| -rw-r--r-- | py/parsenum.c | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/py/binary.c b/py/binary.c index d22e0f342..d344d7b51 100644 --- a/py/binary.c +++ b/py/binary.c @@ -138,7 +138,7 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) { #endif #if MICROPY_PY_BUILTINS_FLOAT case 'f': - return mp_obj_new_float(((float*)p)[index]); + return mp_obj_new_float((mp_float_t)((float*)p)[index]); case 'd': return mp_obj_new_float(((double*)p)[index]); #endif @@ -204,7 +204,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) { #if MICROPY_PY_BUILTINS_FLOAT } else if (val_type == 'f') { union { uint32_t i; float f; } fpu = {val}; - return mp_obj_new_float(fpu.f); + return mp_obj_new_float((mp_float_t) fpu.f); } else if (val_type == 'd') { union { uint64_t i; double f; } fpu = {val}; return mp_obj_new_float(fpu.f); diff --git a/py/objarray.c b/py/objarray.c index 8e1d32f0f..34acd15b3 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -428,7 +428,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value } #endif if (len_adj > 0) { - if (len_adj > o->free) { + if ((mp_uint_t) len_adj > o->free) { // TODO: alloc policy; at the moment we go conservative o->items = m_renew(byte, o->items, (o->len + o->free) * item_sz, (o->len + len_adj) * item_sz); o->free = 0; diff --git a/py/parsenum.c b/py/parsenum.c index 2e41801ee..f3e1aad12 100644 --- a/py/parsenum.c +++ b/py/parsenum.c @@ -197,7 +197,7 @@ mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool if (str + 2 < top && (str[1] | 0x20) == 'n' && (str[2] | 0x20) == 'f') { // inf str += 3; - dec_val = INFINITY; + dec_val = (mp_float_t) INFINITY; if (str + 4 < top && (str[0] | 0x20) == 'i' && (str[1] | 0x20) == 'n' && (str[2] | 0x20) == 'i' && (str[3] | 0x20) == 't' && (str[4] | 0x20) == 'y') { // infinity str += 5; |
