summaryrefslogtreecommitdiffstatshomepage
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-16 17:47:07 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-16 17:47:07 +0000
commit963a5a3e82ded7ee75adae72ae7cb14796fa150e (patch)
tree78402c85b98c1c8f1889d7af7dc6f4828a8f55a5 /py/runtime.c
parentf12ea7c7ed1ef97ee48c4356dbbc808cc2bdee4a (diff)
downloadmicropython-963a5a3e82ded7ee75adae72ae7cb14796fa150e.tar.gz
micropython-963a5a3e82ded7ee75adae72ae7cb14796fa150e.zip
py, unix: Allow to compile with -Wsign-compare.
See issue #699.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 54d120796a..22f9289888 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -334,7 +334,7 @@ mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
if (rhs_val < 0) {
// negative shift not allowed
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "negative shift count"));
- } else if (rhs_val >= BITS_PER_WORD || lhs_val > (MP_SMALL_INT_MAX >> rhs_val) || lhs_val < (MP_SMALL_INT_MIN >> rhs_val)) {
+ } else if (rhs_val >= (mp_int_t)BITS_PER_WORD || lhs_val > (MP_SMALL_INT_MAX >> rhs_val) || lhs_val < (MP_SMALL_INT_MIN >> rhs_val)) {
// left-shift will overflow, so use higher precision integer
lhs = mp_obj_new_int_from_ll(lhs_val);
goto generic_binary_op;
@@ -351,7 +351,7 @@ mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "negative shift count"));
} else {
// standard precision is enough for right-shift
- if (rhs_val >= BITS_PER_WORD) {
+ if (rhs_val >= (mp_int_t)BITS_PER_WORD) {
// Shifting to big amounts is underfined behavior
// in C and is CPU-dependent; propagate sign bit.
rhs_val = BITS_PER_WORD - 1;