Skip to content

Commit 3177ef5

Browse files
committed
esp8266: In callback helpers, pop nlr_buf on successful call.
nlr_pop must be called if no exception was raised. Also, return value of these callback helpers is made void because ther is (currently) no use for it.
1 parent b67d098 commit 3177ef5

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

esp8266/utils.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@
2929
#include "py/obj.h"
3030
#include "py/nlr.h"
3131

32-
mp_obj_t call_function_1_protected(mp_obj_t fun, mp_obj_t arg) {
32+
void call_function_1_protected(mp_obj_t fun, mp_obj_t arg) {
3333
nlr_buf_t nlr;
3434
if (nlr_push(&nlr) == 0) {
35-
return mp_call_function_1(fun, arg);
35+
mp_call_function_1(fun, arg);
36+
nlr_pop();
3637
} else {
3738
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
38-
return (mp_obj_t)nlr.ret_val;
3939
}
4040
}
4141

42-
mp_obj_t call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) {
42+
void call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) {
4343
nlr_buf_t nlr;
4444
if (nlr_push(&nlr) == 0) {
45-
return mp_call_function_2(fun, arg1, arg2);
45+
mp_call_function_2(fun, arg1, arg2);
46+
nlr_pop();
4647
} else {
4748
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
48-
return (mp_obj_t)nlr.ret_val;
4949
}
5050
}

esp8266/utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
mp_obj_t call_function_1_protected(mp_obj_t fun, mp_obj_t arg);
29-
mp_obj_t call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2);
28+
void call_function_1_protected(mp_obj_t fun, mp_obj_t arg);
29+
void call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2);

0 commit comments

Comments
 (0)