summaryrefslogtreecommitdiffstatshomepage
path: root/py/modbuiltins.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-02-07 16:10:42 +1100
committerDamien George <damien.p.george@gmail.com>2018-02-07 16:13:02 +1100
commit771dfb0826f7416848b4302ce8ce49a7a556a27f (patch)
tree769eaf89b08488d022e9937a9ff646a2540af62b /py/modbuiltins.c
parent1f53ff61fffb4cc9b42ddf7e331e225c1b48b4ff (diff)
downloadmicropython-771dfb0826f7416848b4302ce8ce49a7a556a27f.tar.gz
micropython-771dfb0826f7416848b4302ce8ce49a7a556a27f.zip
py/modbuiltins: For builtin_chr, use uint8_t instead of char for array.
The array should be of type unsigned byte because that is the type of the values being stored. And changing to uint8_t helps to prevent warnings from some static analysers.
Diffstat (limited to 'py/modbuiltins.c')
-rw-r--r--py/modbuiltins.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index c8e3235f6f..e6f82df6f4 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -137,7 +137,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);
STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
#if MICROPY_PY_BUILTINS_STR_UNICODE
mp_uint_t c = mp_obj_get_int(o_in);
- char str[4];
+ uint8_t str[4];
int len = 0;
if (c < 0x80) {
*str = c; len = 1;
@@ -159,12 +159,12 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
} else {
mp_raise_ValueError("chr() arg not in range(0x110000)");
}
- return mp_obj_new_str_via_qstr(str, len);
+ return mp_obj_new_str_via_qstr((char*)str, len);
#else
mp_int_t ord = mp_obj_get_int(o_in);
if (0 <= ord && ord <= 0xff) {
- char str[1] = {ord};
- return mp_obj_new_str_via_qstr(str, 1);
+ uint8_t str[1] = {ord};
+ return mp_obj_new_str_via_qstr((char*)str, 1);
} else {
mp_raise_ValueError("chr() arg not in range(256)");
}