Skip to content

Commit 44f15d5

Browse files
committed
Rename "environ" errors to "getenv" errors
1 parent 678a466 commit 44f15d5

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

ports/espressif/common-hal/_bleio/Adapter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, bool enable
103103

104104
#if CIRCUITPY_OS_GETENV
105105
char ble_name[1 + MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH];
106-
os_environ_err_t result = common_hal_os_getenv_str("CIRCUITPY_BLE_NAME", ble_name, sizeof(ble_name));
107-
if (result == ENVIRON_OK) {
106+
os_getenv_err_t result = common_hal_os_getenv_str("CIRCUITPY_BLE_NAME", ble_name, sizeof(ble_name));
107+
if (result == GETENV_OK) {
108108
ble_svc_gap_device_name_set(ble_name);
109109
} else
110110
#endif

ports/espressif/supervisor/port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ void port_idle_until_interrupt(void) {
519519
void port_post_boot_py(bool heap_valid) {
520520
if (!heap_valid && filesystem_present()) {
521521
mp_int_t reserved;
522-
if (common_hal_os_getenv_int("CIRCUITPY_RESERVED_PSRAM", &reserved) == ENVIRON_OK) {
522+
if (common_hal_os_getenv_int("CIRCUITPY_RESERVED_PSRAM", &reserved) == GETENV_OK) {
523523
common_hal_espidf_set_reserved_psram(reserved);
524524
}
525525
common_hal_espidf_reserve_psram();

shared-module/os/__init__.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727
#pragma once
2828

2929
typedef enum {
30-
ENVIRON_OK = 0,
30+
GETENV_OK = 0,
3131
ENVIRON_ERR_OPEN,
3232
ENVIRON_ERR_UNICODE,
3333
ENVIRON_ERR_LENGTH,
3434
ENVIRON_ERR_NOT_FOUND,
3535
ENVIRON_ERR_UNEXPECTED = 0xff00, // logical or'd with the byte value
36-
} os_environ_err_t;
36+
} os_getenv_err_t;
3737

3838
// Allocation free version that returns the full length of the value.
3939
// If it fits, the return value is 0-terminated. If the value doesn't fit,
4040
// *value_len may be an over-estimate but never an under-estimate.
41-
os_environ_err_t common_hal_os_getenv_str(const char *key, char *value, size_t value_len);
41+
os_getenv_err_t common_hal_os_getenv_str(const char *key, char *value, size_t value_len);
4242

4343
// Returns ENVIRON_ERR_OK and sets value to the read value. Returns
4444
// ENVIRON_ERR_... if the value was not numeric. allocation-free.
45-
os_environ_err_t common_hal_os_environ_get_key_int(const char *key, mp_int_t *value);
45+
os_getenv_err_t common_hal_os_environ_get_key_int(const char *key, mp_int_t *value);

shared-module/os/getenv.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include "supervisor/filesystem.h"
4040
#include "supervisor/memory.h"
4141

42-
#define ENVIRON_PATH "settings.toml"
42+
#define GETENV_PATH "settings.toml"
4343

4444
#if defined(UNIX)
4545
typedef FILE *file_arg;
@@ -178,7 +178,7 @@ STATIC bool key_matches(file_arg *active_file, const char *key) {
178178
return true;
179179
}
180180

181-
STATIC os_environ_err_t read_unicode_escape(file_arg *active_file, int sz, vstr_t *buf) {
181+
STATIC os_getenv_err_t read_unicode_escape(file_arg *active_file, int sz, vstr_t *buf) {
182182
char hex_buf[sz + 1];
183183
for (int i = 0; i < sz; i++) {
184184
hex_buf[i] = get_next_byte(active_file);
@@ -197,7 +197,7 @@ STATIC os_environ_err_t read_unicode_escape(file_arg *active_file, int sz, vstr_
197197
}
198198

199199
// Read a quoted string
200-
STATIC os_environ_err_t read_string_value(file_arg *active_file, vstr_t *buf) {
200+
STATIC os_getenv_err_t read_string_value(file_arg *active_file, vstr_t *buf) {
201201
while (true) {
202202
int character = get_next_byte(active_file);
203203
switch (character) {
@@ -244,7 +244,7 @@ STATIC os_environ_err_t read_string_value(file_arg *active_file, vstr_t *buf) {
244244
case 'U':
245245
case 'u': {
246246
int sz = (character == 'u') ? 4 : 8;
247-
os_environ_err_t res;
247+
os_getenv_err_t res;
248248
res = read_unicode_escape(active_file, sz, buf);
249249
if (res != ENVIRON_OK) {
250250
return res;
@@ -262,7 +262,7 @@ STATIC os_environ_err_t read_string_value(file_arg *active_file, vstr_t *buf) {
262262
}
263263

264264
// Read a numeric value (non-quoted value) as a string
265-
STATIC os_environ_err_t read_bare_value(file_arg *active_file, vstr_t *buf, int first_character) {
265+
STATIC os_getenv_err_t read_bare_value(file_arg *active_file, vstr_t *buf, int first_character) {
266266
int character = first_character;
267267
while (true) {
268268
switch (character) {
@@ -292,13 +292,13 @@ STATIC mp_int_t read_value(file_arg *active_file, vstr_t *buf, bool *quoted) {
292292
}
293293
}
294294

295-
STATIC os_environ_err_t os_environ_get_key_vstr(const char *path, const char *key, vstr_t *buf, bool *quoted) {
295+
STATIC os_getenv_err_t os_environ_get_key_vstr(const char *path, const char *key, vstr_t *buf, bool *quoted) {
296296
file_arg active_file;
297297
if (!open_file(path, &active_file)) {
298298
return ENVIRON_ERR_OPEN;
299299
}
300300

301-
os_environ_err_t result = ENVIRON_ERR_NOT_FOUND;
301+
os_getenv_err_t result = ENVIRON_ERR_NOT_FOUND;
302302
while (!is_eof(&active_file)) {
303303
if (key_matches(&active_file, key)) {
304304
result = read_value(&active_file, buf, quoted);
@@ -308,10 +308,10 @@ STATIC os_environ_err_t os_environ_get_key_vstr(const char *path, const char *ke
308308
return result;
309309
}
310310

311-
STATIC os_environ_err_t os_environ_get_key_buf_terminated(const char *key, char *value, size_t value_len, bool *quoted) {
311+
STATIC os_getenv_err_t os_environ_get_key_buf_terminated(const char *key, char *value, size_t value_len, bool *quoted) {
312312
vstr_t buf;
313313
vstr_init_fixed_buf(&buf, value_len, value);
314-
os_environ_err_t result = os_environ_get_key_vstr(ENVIRON_PATH, key, &buf, quoted);
314+
os_getenv_err_t result = os_environ_get_key_vstr(ENVIRON_PATH, key, &buf, quoted);
315315

316316
if (result == ENVIRON_OK) {
317317
vstr_add_byte_nonstd(&buf, 0);
@@ -323,16 +323,16 @@ STATIC os_environ_err_t os_environ_get_key_buf_terminated(const char *key, char
323323
return result;
324324
}
325325

326-
os_environ_err_t common_hal_os_getenv_str(const char *key, char *value, size_t value_len) {
326+
os_getenv_err_t common_hal_os_getenv_str(const char *key, char *value, size_t value_len) {
327327
bool quoted;
328-
os_environ_err_t result = os_environ_get_key_buf_terminated(key, value, value_len, &quoted);
328+
os_getenv_err_t result = os_environ_get_key_buf_terminated(key, value, value_len, &quoted);
329329
if (result == ENVIRON_OK && !quoted) {
330330
result = ENVIRON_ERR_UNEXPECTED | value[0];
331331
}
332332
return result;
333333
}
334334

335-
STATIC void throw__environ_error(os_environ_err_t error) {
335+
STATIC void throw__environ_error(os_getenv_err_t error) {
336336
if (error == ENVIRON_OK) {
337337
return;
338338
}
@@ -366,7 +366,7 @@ mp_obj_t common_hal_os_getenv_path(const char *path, const char *key, mp_obj_t d
366366
bool quoted;
367367

368368
vstr_init(&buf, 64);
369-
os_environ_err_t result = os_environ_get_key_vstr(path, key, &buf, &quoted);
369+
os_getenv_err_t result = os_environ_get_key_vstr(path, key, &buf, &quoted);
370370
if (result == ENVIRON_ERR_NOT_FOUND) {
371371
return default_;
372372
}
@@ -383,10 +383,10 @@ mp_obj_t common_hal_os_getenv(const char *key, mp_obj_t default_) {
383383
return common_hal_os_getenv_path(ENVIRON_PATH, key, default_);
384384
}
385385

386-
os_environ_err_t common_hal_os_environ_get_key_int(const char *key, mp_int_t *value) {
386+
os_getenv_err_t common_hal_os_environ_get_key_int(const char *key, mp_int_t *value) {
387387
char buf[16];
388388
bool quoted;
389-
os_environ_err_t result = os_environ_get_key_buf_terminated(key, buf, sizeof(buf), &quoted);
389+
os_getenv_err_t result = os_environ_get_key_buf_terminated(key, buf, sizeof(buf), &quoted);
390390
if (result != ENVIRON_OK) {
391391
return result;
392392
}

supervisor/shared/web_workflow/web_workflow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ void supervisor_start_web_workflow(void) {
251251
size_t ssid_len = 0;
252252
size_t password_len = 0;
253253

254-
os_environ_err_t result = common_hal_os_getenv_str("CIRCUITPY_WIFI_SSID", ssid, sizeof(ssid));
255-
if (result != ENVIRON_OK) {
254+
os_getenv_err_t result = common_hal_os_getenv_str("CIRCUITPY_WIFI_SSID", ssid, sizeof(ssid));
255+
if (result != GETENV_OK) {
256256
return;
257257
}
258258

0 commit comments

Comments
 (0)