aboutsummaryrefslogtreecommitdiff
path: root/py/binary.c
diff options
context:
space:
mode:
authorDavid Lechner <david@lechnology.com>2020-03-20 00:10:22 -0500
committerDamien George <damien.p.george@gmail.com>2020-03-30 12:04:21 +1100
commita2110bd3fca59df8b16a2b5fe4645a4af30b06ed (patch)
tree6020938ca1fa3f9034ccef522e106c5e9255b49a /py/binary.c
parent3a0f64fc7aafe9fa39f518aec389ef5f55b40007 (diff)
all: Fix implicit casts of float/double, and signed comparison.
These were found by buiding the unix coverage variant on macOS (so clang compiler). Mostly, these are fixing implicit cast of float/double to mp_float_t which is one of those two and one mp_int_t to size_t fix for good measure.
Diffstat (limited to 'py/binary.c')
-rw-r--r--py/binary.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/binary.c b/py/binary.c
index faa413585..d4898c143 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -176,9 +176,9 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_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]);
+ return mp_obj_new_float((mp_float_t)((double *)p)[index]);
#endif
// Extension to CPython: array of objects
case 'O':
@@ -244,12 +244,12 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
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);
+ return mp_obj_new_float((mp_float_t)fpu.f);
#endif
} else if (is_signed(val_type)) {
if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) {