diff --git a/kernel/userspace.c b/kernel/userspace.c index a5a27b1e22e..908e34dfb10 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -34,6 +34,7 @@ static void clear_perms_cb(struct _k_object *ko, void *ctx_ptr); const char *otype_to_str(enum k_objects otype) { + const char *ret; /* -fdata-sections doesn't work right except in very very recent * GCC and these literal strings would appear in the binary even if * otype_to_str was omitted by the linker @@ -45,12 +46,14 @@ const char *otype_to_str(enum k_objects otype) */ #include default: - return "?"; + ret = "?"; + break; } #else ARG_UNUSED(otype); return NULL; #endif + return ret; } struct perm_ctx { @@ -94,11 +97,16 @@ static sys_dlist_t obj_list = SYS_DLIST_STATIC_INIT(&obj_list); static size_t obj_size_get(enum k_objects otype) { + size_t ret; + switch (otype) { #include default: - return sizeof(struct device); + ret = sizeof(struct device); + break; } + + return ret; } static int node_lessthan(struct rbnode *a, struct rbnode *b) @@ -342,6 +350,7 @@ static void unref_check(struct _k_object *ko) k_stack_cleanup((struct k_stack *)ko->name); break; default: + /* Nothing to do */ break; } diff --git a/scripts/gen_kobject_list.py b/scripts/gen_kobject_list.py index 9937edc8134..9ff5cebfe30 100755 --- a/scripts/gen_kobject_list.py +++ b/scripts/gen_kobject_list.py @@ -202,14 +202,14 @@ def write_kobj_otype_output(fp): if dep: fp.write("#ifdef %s\n" % dep) - fp.write('case %s: return "%s";\n' % (kobject_to_enum(kobj), kobj)) + fp.write('case %s: ret = "%s"; break;\n' % (kobject_to_enum(kobj), kobj)) if dep: fp.write("#endif\n") fp.write("/* Driver subsystems */\n") for subsystem in subsystems: subsystem = subsystem.replace("_driver_api", "") - fp.write('case K_OBJ_DRIVER_%s: return "%s driver";\n' % ( + fp.write('case K_OBJ_DRIVER_%s: ret = "%s driver"; break;\n' % ( subsystem.upper(), subsystem )) @@ -225,7 +225,7 @@ def write_kobj_size_output(fp): if dep: fp.write("#ifdef %s\n" % dep) - fp.write('case %s: return sizeof(struct %s);\n' % + fp.write('case %s: ret = sizeof(struct %s); break;\n' % (kobject_to_enum(kobj), kobj)) if dep: fp.write("#endif\n")