From 2b4ad1ed0399dc77632bf7dca61b269517320ad9 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 20 Jan 2021 17:10:28 -0800 Subject: [PATCH] Fix warnings that come from -O3 (I think) --- extmod/vfs.c | 5 +++-- shared-bindings/microcontroller/Pin.c | 8 ++++---- shared-module/os/__init__.c | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/extmod/vfs.c b/extmod/vfs.c index c9c1fe3c31..420f8305f7 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -71,6 +71,7 @@ mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out) { STATIC mp_vfs_mount_t *lookup_path(mp_obj_t path_in, mp_obj_t *path_out) { const char *path = mp_obj_str_get_str(path_in); const char *p_out; + *path_out = mp_const_none; mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &p_out); if (vfs != MP_VFS_NONE && vfs != MP_VFS_ROOT) { *path_out = mp_obj_new_str_of_type(mp_obj_get_type(path_in), @@ -329,7 +330,7 @@ mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args) { path_in = MP_OBJ_NEW_QSTR(MP_QSTR_); } - mp_obj_t path_out; + mp_obj_t path_out = mp_const_none; mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); if (vfs == MP_VFS_ROOT) { @@ -359,7 +360,7 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) { MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj, 0, 1, mp_vfs_listdir); mp_obj_t mp_vfs_mkdir(mp_obj_t path_in) { - mp_obj_t path_out; + mp_obj_t path_out = mp_const_none; mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); if (vfs == MP_VFS_ROOT || (vfs != MP_VFS_NONE && !strcmp(mp_obj_str_get_str(path_out), "/"))) { mp_raise_OSError(MP_EEXIST); diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index 6ba02a0e7d..2a97b54b3d 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -66,12 +66,12 @@ static void get_pin_name(const mcu_pin_obj_t *self, qstr* package, qstr* module, STATIC void mcu_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { mcu_pin_obj_t *self = MP_OBJ_TO_PTR(self_in); - qstr package; + qstr package = MP_QSTR_Pin; qstr module; - qstr name; + qstr name = MP_QSTR_Pin; get_pin_name(self, &package, &module, &name); - if (package){ + if (package) { mp_printf(print, "%q.%q.%q", package, module, name); } else { mp_printf(print, "%q.%q", module , name); @@ -131,7 +131,7 @@ void assert_pin_free(const mcu_pin_obj_t* pin) { if (pin != NULL && pin != MP_OBJ_TO_PTR(mp_const_none) && !common_hal_mcu_pin_is_free(pin)) { qstr package; qstr module; - qstr name; + qstr name = MP_QSTR_Pin; get_pin_name(pin, &package, &module, &name); mp_raise_ValueError_varg(translate("%q in use"), name); diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index 39cf40fda3..159b54e315 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -42,6 +42,7 @@ // Version of mp_vfs_lookup_path that takes and returns uPy string objects. STATIC mp_vfs_mount_t *lookup_path(const char* path, mp_obj_t *path_out) { const char *p_out; + *path_out = mp_const_none; mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &p_out); if (vfs != MP_VFS_NONE && vfs != MP_VFS_ROOT) { *path_out = mp_obj_new_str_of_type(&mp_type_str, @@ -53,6 +54,7 @@ STATIC mp_vfs_mount_t *lookup_path(const char* path, mp_obj_t *path_out) { // Strip off trailing slashes to please underlying libraries STATIC mp_vfs_mount_t *lookup_dir_path(const char* path, mp_obj_t *path_out) { const char *p_out; + *path_out = mp_const_none; mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &p_out); if (vfs != MP_VFS_NONE && vfs != MP_VFS_ROOT) { size_t len = strlen(p_out);