Skip to content

Commit 773c379

Browse files
committed
Throughout: Use mp_obj_new_str_0()
Use new method mp_obj_new_str_0() where appropriate. Signed-off-by: Jon Foster <jon@jon-foster.co.uk>
1 parent 12d65c5 commit 773c379

28 files changed

+40
-40
lines changed

extmod/modlwip.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ mp_obj_t lwip_format_inet_addr(const ip_addr_t *ip, mp_uint_t port) {
361361
char ipstr[IPADDR_STRLEN_MAX];
362362
ipaddr_ntoa_r(ip, ipstr, sizeof(ipstr));
363363
mp_obj_t tuple[2] = {
364-
tuple[0] = mp_obj_new_str(ipstr, strlen(ipstr)),
364+
tuple[0] = mp_obj_new_str_0(ipstr),
365365
tuple[1] = mp_obj_new_int(port),
366366
};
367367
return mp_obj_new_tuple(2, tuple);

extmod/modnetwork.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_network_country_obj, 0, 1, network_count
127127

128128
mp_obj_t mod_network_hostname(size_t n_args, const mp_obj_t *args) {
129129
if (n_args == 0) {
130-
return mp_obj_new_str(mod_network_hostname_data, strlen(mod_network_hostname_data));
130+
return mp_obj_new_str_0(mod_network_hostname_data);
131131
} else {
132132
size_t len;
133133
const char *str = mp_obj_str_get_data(args[0], &len);

extmod/modopenamp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static void openamp_ns_callback(struct rpmsg_device *rdev, const char *name, uin
263263
// the Name Service (NS) announcement containing the name of the channel.
264264
virtio_dev_obj_t *virtio_device = metal_container_of(rdev, virtio_dev_obj_t, rvdev);
265265
if (virtio_device->ns_callback != mp_const_none) {
266-
mp_call_function_2(virtio_device->ns_callback, mp_obj_new_int(dest), mp_obj_new_str(name, strlen(name)));
266+
mp_call_function_2(virtio_device->ns_callback, mp_obj_new_int(dest), mp_obj_new_str_0(name));
267267
}
268268
}
269269

extmod/modopenamp_remoteproc_store.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void *mp_openamp_remoteproc_store_alloc(void) {
7070
static int openamp_remoteproc_store_open(void *store, const char *path, const void **image_data) {
7171
metal_log(METAL_LOG_DEBUG, "store_open(): %s\n", path);
7272
mp_obj_t args[2] = {
73-
mp_obj_new_str(path, strlen(path)),
73+
mp_obj_new_str_0(path),
7474
MP_OBJ_NEW_QSTR(MP_QSTR_rb),
7575
};
7676

extmod/modtls_mbedtls.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static mp_obj_t ssl_context_get_ciphers(mp_obj_t self_in) {
307307
mp_obj_t list = mp_obj_new_list(0, NULL);
308308
for (const int *cipher_list = mbedtls_ssl_list_ciphersuites(); *cipher_list; ++cipher_list) {
309309
const char *cipher_name = mbedtls_ssl_get_ciphersuite_name(*cipher_list);
310-
mp_obj_list_append(list, MP_OBJ_FROM_PTR(mp_obj_new_str(cipher_name, strlen(cipher_name))));
310+
mp_obj_list_append(list, MP_OBJ_FROM_PTR(mp_obj_new_str_0(cipher_name)));
311311
}
312312
return list;
313313
}
@@ -572,8 +572,8 @@ static mp_obj_t mod_ssl_cipher(mp_obj_t o_in) {
572572
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in);
573573
const char *cipher_suite = mbedtls_ssl_get_ciphersuite(&o->ssl);
574574
const char *tls_version = mbedtls_ssl_get_version(&o->ssl);
575-
mp_obj_t tuple[2] = {mp_obj_new_str(cipher_suite, strlen(cipher_suite)),
576-
mp_obj_new_str(tls_version, strlen(tls_version))};
575+
mp_obj_t tuple[2] = {mp_obj_new_str_0(cipher_suite),
576+
mp_obj_new_str_0(tls_version)};
577577

578578
return mp_obj_new_tuple(2, tuple);
579579
}

extmod/modwebrepl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static void handle_op(mp_obj_webrepl_t *self) {
146146
// Handle operations requiring opened file
147147

148148
mp_obj_t open_args[2] = {
149-
mp_obj_new_str(self->hdr.fname, strlen(self->hdr.fname)),
149+
mp_obj_new_str_0(self->hdr.fname),
150150
MP_OBJ_NEW_QSTR(MP_QSTR_rb)
151151
};
152152

extmod/network_esp_hosted.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static mp_obj_t network_esp_hosted_config(size_t n_args, const mp_obj_t *args, m
230230
case MP_QSTR_essid: {
231231
esp_hosted_netinfo_t netinfo;
232232
esp_hosted_wifi_netinfo(&netinfo);
233-
return mp_obj_new_str(netinfo.ssid, strlen(netinfo.ssid));
233+
return mp_obj_new_str_0(netinfo.ssid);
234234
}
235235
case MP_QSTR_security: {
236236
esp_hosted_netinfo_t netinfo;

extmod/network_lwip.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mp_obj_t mod_network_ipconfig(size_t n_args, const mp_obj_t *args, mp_map_t *kwa
113113
case MP_QSTR_dns: {
114114
char addr_str[IPADDR_STRLEN_MAX];
115115
ipaddr_ntoa_r(dns_getserver(0), addr_str, sizeof(addr_str));
116-
return mp_obj_new_str(addr_str, strlen(addr_str));
116+
return mp_obj_new_str_0(addr_str);
117117
}
118118
case MP_QSTR_prefer: {
119119
return MP_OBJ_NEW_SMALL_INT(mp_mod_network_prefer_dns_use_ip_version);
@@ -219,7 +219,7 @@ mp_obj_t mod_network_nic_ipconfig(struct netif *netif, size_t n_args, const mp_o
219219
char addr_str[IPADDR_STRLEN_MAX];
220220
ipaddr_ntoa_r(netif_ip_addr6(netif, i), addr_str, sizeof(addr_str));
221221
mp_obj_t tuple[4] = {
222-
mp_obj_new_str(addr_str, strlen(addr_str)),
222+
mp_obj_new_str_0(addr_str),
223223
MP_OBJ_NEW_SMALL_INT(netif_ip6_addr_state(netif, i)),
224224
MP_OBJ_NEW_SMALL_INT(netif_ip6_addr_pref_life(netif, i)), // preferred
225225
MP_OBJ_NEW_SMALL_INT(netif_ip6_addr_valid_life(netif, i))

extmod/network_ninaw10.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static mp_obj_t network_ninaw10_config(size_t n_args, const mp_obj_t *args, mp_m
386386
case MP_QSTR_ssid: {
387387
nina_netinfo_t netinfo;
388388
nina_netinfo(&netinfo);
389-
return mp_obj_new_str(netinfo.ssid, strlen(netinfo.ssid));
389+
return mp_obj_new_str_0(netinfo.ssid);
390390
}
391391
case MP_QSTR_security: {
392392
nina_netinfo_t netinfo;

extmod/vfs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ mp_import_stat_t mp_vfs_import_stat(const char *path) {
139139
}
140140

141141
// delegate to vfs.stat() method
142-
mp_obj_t path_o = mp_obj_new_str(path_out, strlen(path_out));
142+
mp_obj_t path_o = mp_obj_new_str_0(path_out);
143143
mp_obj_t stat;
144144
nlr_buf_t nlr;
145145
if (nlr_push(&nlr) == 0) {

extmod/vfs_fat.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static mp_obj_t mp_vfs_fat_ilistdir_it_iternext(mp_obj_t self_in) {
144144
// make 4-tuple with info about this entry
145145
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(4, NULL));
146146
if (self->is_str) {
147-
t->items[0] = mp_obj_new_str(fn, strlen(fn));
147+
t->items[0] = mp_obj_new_str_0(fn);
148148
} else {
149149
t->items[0] = mp_obj_new_bytes((const byte *)fn, strlen(fn));
150150
}
@@ -291,7 +291,7 @@ static mp_obj_t fat_vfs_getcwd(mp_obj_t vfs_in) {
291291
if (res != FR_OK) {
292292
mp_raise_OSError(fresult_to_errno_table[res]);
293293
}
294-
return mp_obj_new_str(buf, strlen(buf));
294+
return mp_obj_new_str_0(buf);
295295
}
296296
static MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getcwd_obj, fat_vfs_getcwd);
297297

extmod/vfs_lfsx.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static mp_obj_t MP_VFS_LFSx(ilistdir_it_iternext)(mp_obj_t self_in) {
192192
// make 4-tuple with info about this entry
193193
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(4, NULL));
194194
if (self->is_str) {
195-
t->items[0] = mp_obj_new_str(info.name, strlen(info.name));
195+
t->items[0] = mp_obj_new_str_0(info.name);
196196
} else {
197197
t->items[0] = mp_obj_new_bytes((const byte *)info.name, strlen(info.name));
198198
}

extmod/vfs_posix.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static mp_obj_t vfs_posix_getcwd(mp_obj_t self_in) {
197197
}
198198
#endif
199199
}
200-
return mp_obj_new_str(ret, strlen(ret));
200+
return mp_obj_new_str_0(ret);
201201
}
202202
static MP_DEFINE_CONST_FUN_OBJ_1(vfs_posix_getcwd_obj, vfs_posix_getcwd);
203203

@@ -237,7 +237,7 @@ static mp_obj_t vfs_posix_ilistdir_it_iternext(mp_obj_t self_in) {
237237
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL));
238238

239239
if (self->is_str) {
240-
t->items[0] = mp_obj_new_str(fn, strlen(fn));
240+
t->items[0] = mp_obj_new_str_0(fn);
241241
} else {
242242
t->items[0] = mp_obj_new_bytes((const byte *)fn, strlen(fn));
243243
}

ports/cc3200/mods/modwlan.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(wlan_mode_obj, 1, 2, wlan_mode);
10741074
static mp_obj_t wlan_ssid(size_t n_args, const mp_obj_t *args) {
10751075
wlan_obj_t *self = args[0];
10761076
if (n_args == 1) {
1077-
return mp_obj_new_str((const char *)self->ssid, strlen((const char *)self->ssid));
1077+
return mp_obj_new_str_0((const char *)self->ssid);
10781078
} else {
10791079
size_t len;
10801080
const char *ssid = mp_obj_str_get_data(args[1], &len);
@@ -1094,7 +1094,7 @@ static mp_obj_t wlan_auth(size_t n_args, const mp_obj_t *args) {
10941094
} else {
10951095
mp_obj_t security[2];
10961096
security[0] = mp_obj_new_int(self->auth);
1097-
security[1] = mp_obj_new_str((const char *)self->key, strlen((const char *)self->key));
1097+
security[1] = mp_obj_new_str_0((const char *)self->key);
10981098
return mp_obj_new_tuple(2, security);
10991099
}
11001100
} else {
@@ -1198,7 +1198,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(wlan_irq_obj, 1, wlan_irq);
11981198
// mp_obj_t connections = mp_obj_new_list(0, NULL);
11991199
//
12001200
// if (wlan_is_connected()) {
1201-
// device[0] = mp_obj_new_str((const char *)wlan_obj.ssid_o, strlen((const char *)wlan_obj.ssid_o));
1201+
// device[0] = mp_obj_new_str_0((const char *)wlan_obj.ssid_o);
12021202
// device[1] = mp_obj_new_bytes((const byte *)wlan_obj.bssid, SL_BSSID_LENGTH);
12031203
// // add the device to the list
12041204
// mp_obj_list_append(connections, mp_obj_new_tuple(MP_ARRAY_SIZE(device), device));

ports/esp32/esp32_partition.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static mp_obj_t esp32_partition_info(mp_obj_t self_in) {
156156
MP_OBJ_NEW_SMALL_INT(self->part->subtype),
157157
mp_obj_new_int_from_uint(self->part->address),
158158
mp_obj_new_int_from_uint(self->part->size),
159-
mp_obj_new_str(&self->part->label[0], strlen(&self->part->label[0])),
159+
mp_obj_new_str_0(&self->part->label[0]),
160160
mp_obj_new_bool(self->part->encrypted),
161161
};
162162
return mp_obj_new_tuple(6, tuple);

ports/esp32/modsocket.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ static mp_obj_t esp_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
941941
mp_obj_new_int(resi->ai_family),
942942
mp_obj_new_int(resi->ai_socktype),
943943
mp_obj_new_int(resi->ai_protocol),
944-
mp_obj_new_str(resi->ai_canonname, strlen(resi->ai_canonname)),
944+
mp_obj_new_str_0(resi->ai_canonname),
945945
mp_const_none
946946
};
947947

@@ -952,7 +952,7 @@ static mp_obj_t esp_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
952952
char buf[16];
953953
ip4addr_ntoa_r(&ip4_addr, buf, sizeof(buf));
954954
mp_obj_t inaddr_objs[2] = {
955-
mp_obj_new_str(buf, strlen(buf)),
955+
mp_obj_new_str_0(buf),
956956
mp_obj_new_int(ntohs(addr->sin_port))
957957
};
958958
addrinfo_objs[4] = mp_obj_new_tuple(2, inaddr_objs);

ports/esp32/network_common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ mp_obj_t esp_ifname(esp_netif_t *netif) {
158158
char ifname[NETIF_NAMESIZE + 1] = {0};
159159
mp_obj_t ret = mp_const_none;
160160
if (esp_netif_get_netif_impl_name(netif, ifname) == ESP_OK && ifname[0] != 0) {
161-
ret = mp_obj_new_str((char *)ifname, strlen(ifname));
161+
ret = mp_obj_new_str_0((char *)ifname);
162162
}
163163
return ret;
164164
}

ports/esp32/network_ppp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static mp_obj_t ppp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
308308
char ifname[NETIF_NAMESIZE + 1] = {0};
309309
netif_index_to_name(netif_get_index(pppif), ifname);
310310
if (ifname[0] != 0) {
311-
val = mp_obj_new_str((char *)ifname, strlen(ifname));
311+
val = mp_obj_new_str_0((char *)ifname);
312312
}
313313
}
314314
break;

ports/esp32/network_wlan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ static mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_
640640
case MP_QSTR_essid:
641641
switch (self->if_id) {
642642
case ESP_IF_WIFI_STA:
643-
val = mp_obj_new_str((char *)cfg.sta.ssid, strlen((char *)cfg.sta.ssid));
643+
val = mp_obj_new_str_0((char *)cfg.sta.ssid);
644644
break;
645645
case ESP_IF_WIFI_AP:
646646
val = mp_obj_new_str((char *)cfg.ap.ssid, cfg.ap.ssid_len);

ports/esp8266/network_wlan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
456456
case MP_QSTR_ssid:
457457
case MP_QSTR_essid:
458458
if (self->if_id == STATION_IF) {
459-
val = mp_obj_new_str((char *)cfg.sta.ssid, strlen((char *)cfg.sta.ssid));
459+
val = mp_obj_new_str_0((char *)cfg.sta.ssid);
460460
} else {
461461
val = mp_obj_new_str((char *)cfg.ap.ssid, cfg.ap.ssid_len);
462462
}

ports/unix/coverage.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static mp_obj_t extra_coverage(void) {
387387
mp_printf(&mp_plat_print, "# str\n");
388388

389389
// intern string
390-
mp_printf(&mp_plat_print, "%d\n", mp_obj_is_qstr(mp_obj_str_intern(mp_obj_new_str("intern me", 9))));
390+
mp_printf(&mp_plat_print, "%d\n", mp_obj_is_qstr(mp_obj_str_intern(mp_obj_new_str_0("intern me"))));
391391
}
392392

393393
// bytearray
@@ -463,12 +463,12 @@ static mp_obj_t extra_coverage(void) {
463463
// call mp_call_function_1_protected
464464
mp_call_function_1_protected(MP_OBJ_FROM_PTR(&mp_builtin_abs_obj), MP_OBJ_NEW_SMALL_INT(1));
465465
// call mp_call_function_1_protected with invalid args
466-
mp_call_function_1_protected(MP_OBJ_FROM_PTR(&mp_builtin_abs_obj), mp_obj_new_str("abc", 3));
466+
mp_call_function_1_protected(MP_OBJ_FROM_PTR(&mp_builtin_abs_obj), mp_obj_new_str_0("abc"));
467467

468468
// call mp_call_function_2_protected
469469
mp_call_function_2_protected(MP_OBJ_FROM_PTR(&mp_builtin_divmod_obj), MP_OBJ_NEW_SMALL_INT(1), MP_OBJ_NEW_SMALL_INT(1));
470470
// call mp_call_function_2_protected with invalid args
471-
mp_call_function_2_protected(MP_OBJ_FROM_PTR(&mp_builtin_divmod_obj), mp_obj_new_str("abc", 3), mp_obj_new_str("abc", 3));
471+
mp_call_function_2_protected(MP_OBJ_FROM_PTR(&mp_builtin_divmod_obj), mp_obj_new_str_0("abc"), mp_obj_new_str_0("abc"));
472472

473473
// mp_obj_int_get_uint_checked with non-negative small-int
474474
mp_printf(&mp_plat_print, "%d\n", (int)mp_obj_int_get_uint_checked(MP_OBJ_NEW_SMALL_INT(1)));
@@ -722,7 +722,7 @@ static mp_obj_t extra_coverage(void) {
722722
// mp_obj_is_integer accepts ints and booleans
723723
mp_printf(&mp_plat_print, "%d %d\n", mp_obj_is_integer(MP_OBJ_NEW_SMALL_INT(1)), mp_obj_is_integer(mp_obj_new_int_from_ll(1)));
724724
mp_printf(&mp_plat_print, "%d %d\n", mp_obj_is_integer(mp_const_true), mp_obj_is_integer(mp_const_false));
725-
mp_printf(&mp_plat_print, "%d %d\n", mp_obj_is_integer(mp_obj_new_str("1", 1)), mp_obj_is_integer(mp_const_none));
725+
mp_printf(&mp_plat_print, "%d %d\n", mp_obj_is_integer(mp_obj_new_str_0("1")), mp_obj_is_integer(mp_const_none));
726726

727727
// mp_obj_is_int accepts small int and object ints
728728
mp_printf(&mp_plat_print, "%d %d\n", mp_obj_is_int(MP_OBJ_NEW_SMALL_INT(1)), mp_obj_is_int(mp_obj_new_int_from_ll(1)));

ports/unix/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
639639
return invalid_args();
640640
}
641641
mp_obj_t import_args[4];
642-
import_args[0] = mp_obj_new_str(argv[a + 1], strlen(argv[a + 1]));
642+
import_args[0] = mp_obj_new_str_0(argv[a + 1]);
643643
import_args[1] = import_args[2] = mp_const_none;
644644
// Ask __import__ to handle imported module specially - set its __name__
645645
// to __main__, and also return this leaf module, not top-level package

ports/unix/modffi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static mp_obj_t return_ffi_value(ffi_union_t *val, char type) {
174174
if (!s) {
175175
return mp_const_none;
176176
}
177-
return mp_obj_new_str(s, strlen(s));
177+
return mp_obj_new_str_0(s);
178178
}
179179
case 'v':
180180
return mp_const_none;

ports/unix/modjni.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static mp_obj_t new_jobject(jobject jo) {
337337
return mp_const_none;
338338
} else if (JJ(IsInstanceOf, jo, String_class)) {
339339
const char *s = JJ(GetStringUTFChars, jo, NULL);
340-
mp_obj_t ret = mp_obj_new_str(s, strlen(s));
340+
mp_obj_t ret = mp_obj_new_str_0(s);
341341
JJ(ReleaseStringUTFChars, jo, s);
342342
return ret;
343343
} else if (JJ(IsInstanceOf, jo, Class_class)) {

ports/unix/modos.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static mp_obj_t mp_os_getenv(size_t n_args, const mp_obj_t *args) {
4040
}
4141
return mp_const_none;
4242
}
43-
return mp_obj_new_str(s, strlen(s));
43+
return mp_obj_new_str_0(s);
4444
}
4545
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_getenv_obj, 1, 2, mp_os_getenv);
4646

ports/zephyr/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void vfs_init(void) {
103103
int ret = 0;
104104

105105
#ifdef CONFIG_DISK_DRIVER_SDMMC
106-
mp_obj_t args[] = { mp_obj_new_str(CONFIG_SDMMC_VOLUME_NAME, strlen(CONFIG_SDMMC_VOLUME_NAME)) };
106+
mp_obj_t args[] = { mp_obj_new_str_0(CONFIG_SDMMC_VOLUME_NAME) };
107107
bdev = MP_OBJ_TYPE_GET_SLOT(&zephyr_disk_access_type, make_new)(&zephyr_disk_access_type, ARRAY_SIZE(args), 0, args);
108108
mount_point_str = "/sd";
109109
#elif defined(CONFIG_FLASH_MAP) && FLASH_AREA_LABEL_EXISTS(storage)
@@ -113,7 +113,7 @@ static void vfs_init(void) {
113113
#endif
114114

115115
if ((bdev != NULL)) {
116-
mount_point = mp_obj_new_str(mount_point_str, strlen(mount_point_str));
116+
mount_point = mp_obj_new_str_0(mount_point_str);
117117
ret = mp_vfs_mount_and_chdir_protected(bdev, mount_point);
118118
// TODO: if this failed, make a new file system and try to mount again
119119
}

ports/zephyr/modsocket.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static mp_obj_t format_inet_addr(struct sockaddr *addr, mp_obj_t port) {
9292
net_addr_ntop(addr->sa_family, &sockaddr_in6->sin6_addr, buf, sizeof(buf));
9393
mp_obj_tuple_t *tuple = mp_obj_new_tuple(addr->sa_family == AF_INET ? 2 : 4, NULL);
9494

95-
tuple->items[0] = mp_obj_new_str(buf, strlen(buf));
95+
tuple->items[0] = mp_obj_new_str_0(buf);
9696
// We employ the fact that port offset is the same for IPv4 & IPv6
9797
// not filled in
9898
// tuple->items[1] = mp_obj_new_int(ntohs(((struct sockaddr_in*)addr)->sin_port));

py/binary.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
338338
return (mp_obj_t)(mp_uint_t)val;
339339
} else if (val_type == 'S') {
340340
const char *s_val = (const char *)(uintptr_t)(mp_uint_t)val;
341-
return mp_obj_new_str(s_val, strlen(s_val));
341+
return mp_obj_new_str_0(s_val);
342342
#if MICROPY_PY_BUILTINS_FLOAT
343343
} else if (val_type == 'e') {
344344
return mp_obj_new_float_from_f(mp_decode_half_float(val));

0 commit comments

Comments
 (0)