Commit 657aef66 authored by Damien George's avatar Damien George

py/stream: Simplify arg extraction logic for stream_ioctl.

Saves 16 bytes of code.

Also, use mp_obj_get_int_truncated to allow integers as big as a machine
word to be passed as the value.
parent 6e87aeb8
......@@ -416,11 +416,10 @@ STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
mp_buffer_info_t bufinfo;
uintptr_t val = 0;
if (n_args > 2) {
if (MP_OBJ_IS_INT(args[2])) {
val = mp_obj_get_int(args[2]);
} else {
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
if (mp_get_buffer(args[2], &bufinfo, MP_BUFFER_WRITE)) {
val = (uintptr_t)bufinfo.buf;
} else {
val = mp_obj_get_int_truncated(args[2]);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment