raspberrypi: statically allocate storage for hostname

This commit is contained in:
Jeff Epler 2022-09-30 10:05:11 -05:00
parent 84c7ac4a81
commit 0912889106
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
2 changed files with 5 additions and 5 deletions

View File

@ -92,10 +92,10 @@ mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self) {
}
void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) {
self->hostname = mp_obj_new_str(hostname, strlen(hostname));
hostname = mp_obj_str_get_str(self->hostname);
netif_set_hostname(NETIF_STA, hostname);
netif_set_hostname(NETIF_AP, hostname);
assert(strlen(hostname) < MP_ARRAY_SIZE(self->hostname));
memcpy(self->hostname, hostname, strlen(hostname));
netif_set_hostname(NETIF_STA, self->hostname);
netif_set_hostname(NETIF_AP, self->hostname);
}
mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {

View File

@ -33,7 +33,7 @@
typedef struct {
mp_obj_base_t base;
mp_obj_t hostname;
char hostname[254]; // hostname max is 253 chars, + 1 for trailing NUL
wifi_scannednetworks_obj_t *current_scan;
} wifi_radio_obj_t;