Skip to content

Commit 75af908

Browse files
committed
extmod: Use mp_raise_OSError helper function.
1 parent 06d0083 commit 75af908

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

extmod/machine_pulse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ STATIC mp_obj_t machine_time_pulse_us_(size_t n_args, const mp_obj_t *args) {
5858
}
5959
mp_uint_t us = machine_time_pulse_us(pin, level, timeout_us);
6060
if (us == (mp_uint_t)-1) {
61-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(MP_ETIMEDOUT)));
61+
mp_raise_OSError(MP_ETIMEDOUT);
6262
}
6363
return mp_obj_new_int(us);
6464
}

extmod/modbtree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ STATIC const mp_obj_type_t btree_type;
5858

5959
#define CHECK_ERROR(res) \
6060
if (res == RET_ERROR) { \
61-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno))); \
61+
mp_raise_OSError(errno); \
6262
}
6363

6464
void __dbpanic(DB *db) {
@@ -370,7 +370,7 @@ STATIC mp_obj_t mod_btree_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t
370370

371371
DB *db = __bt_open(pos_args[0], &btree_stream_fvtable, &openinfo, /*dflags*/0);
372372
if (db == NULL) {
373-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
373+
mp_raise_OSError(errno);
374374
}
375375
return MP_OBJ_FROM_PTR(btree_new(db));
376376
}

extmod/modussl_axtls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, bool server_side) {
5656

5757
uint32_t options = SSL_SERVER_VERIFY_LATER;
5858
if ((o->ssl_ctx = ssl_ctx_new(options, SSL_DEFAULT_CLNT_SESS)) == NULL) {
59-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(EINVAL)));
59+
mp_raise_OSError(MP_EINVAL);
6060
}
6161

6262
if (server_side) {
@@ -69,7 +69,7 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, bool server_side) {
6969
if ((res = ssl_handshake_status(o->ssl_sock)) != SSL_OK) {
7070
printf("ssl_handshake_status: %d\n", res);
7171
ssl_display_error(res);
72-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(EIO)));
72+
mp_raise_OSError(MP_EIO);
7373
}
7474
}
7575

extmod/modussl_mbedtls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
179179
if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
180180
//assert(0);
181181
printf("mbedtls_ssl_handshake error: -%x\n", -ret);
182-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(EIO)));
182+
mp_raise_OSError(MP_EIO);
183183
}
184184
}
185185
}

extmod/moduzlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ STATIC unsigned char read_src_stream(TINF_DATA *data) {
5959
byte c;
6060
mp_uint_t out_sz = stream->read(self->src_stream, &c, 1, &err);
6161
if (out_sz == MP_STREAM_ERROR) {
62-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(err)));
62+
mp_raise_OSError(err);
6363
}
6464
if (out_sz == 0) {
6565
nlr_raise(mp_obj_new_exception(&mp_type_EOFError));

0 commit comments

Comments
 (0)