From e98ff40604170eb231225a4285d9ef740b8b9501 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 14 Feb 2018 18:27:14 +1100 Subject: [PATCH] py/modbuiltins: Simplify casts from char to byte ptr in builtin ord. --- py/modbuiltins.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py/modbuiltins.c b/py/modbuiltins.c index 6b8886804b..5461816af0 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -343,19 +343,19 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct); STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) { size_t len; - const char *str = mp_obj_str_get_data(o_in, &len); + const byte *str = (const byte*)mp_obj_str_get_data(o_in, &len); #if MICROPY_PY_BUILTINS_STR_UNICODE if (MP_OBJ_IS_STR(o_in)) { - len = utf8_charlen((const byte*)str, len); + len = utf8_charlen(str, len); if (len == 1) { - return mp_obj_new_int(utf8_get_char((const byte*)str)); + return mp_obj_new_int(utf8_get_char(str)); } } else #endif { // a bytes object, or a str without unicode support (don't sign extend the char) if (len == 1) { - return MP_OBJ_NEW_SMALL_INT(((const byte*)str)[0]); + return MP_OBJ_NEW_SMALL_INT(str[0]); } }