kernel: userspace: Sanitize switch usage
MISRA-C requires that every switch clause has a break instruction. Changing gen_kobject_list script to generates compliance code. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
a3cea50ce7
commit
3259ac08ca
@ -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 *otype_to_str(enum k_objects otype)
|
||||||
{
|
{
|
||||||
|
const char *ret;
|
||||||
/* -fdata-sections doesn't work right except in very very recent
|
/* -fdata-sections doesn't work right except in very very recent
|
||||||
* GCC and these literal strings would appear in the binary even if
|
* GCC and these literal strings would appear in the binary even if
|
||||||
* otype_to_str was omitted by the linker
|
* otype_to_str was omitted by the linker
|
||||||
@ -45,12 +46,14 @@ const char *otype_to_str(enum k_objects otype)
|
|||||||
*/
|
*/
|
||||||
#include <otype-to-str.h>
|
#include <otype-to-str.h>
|
||||||
default:
|
default:
|
||||||
return "?";
|
ret = "?";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ARG_UNUSED(otype);
|
ARG_UNUSED(otype);
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct perm_ctx {
|
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)
|
static size_t obj_size_get(enum k_objects otype)
|
||||||
{
|
{
|
||||||
|
size_t ret;
|
||||||
|
|
||||||
switch (otype) {
|
switch (otype) {
|
||||||
#include <otype-to-size.h>
|
#include <otype-to-size.h>
|
||||||
default:
|
default:
|
||||||
return sizeof(struct device);
|
ret = sizeof(struct device);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int node_lessthan(struct rbnode *a, struct rbnode *b)
|
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);
|
k_stack_cleanup((struct k_stack *)ko->name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
/* Nothing to do */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -202,14 +202,14 @@ def write_kobj_otype_output(fp):
|
|||||||
if dep:
|
if dep:
|
||||||
fp.write("#ifdef %s\n" % 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:
|
if dep:
|
||||||
fp.write("#endif\n")
|
fp.write("#endif\n")
|
||||||
|
|
||||||
fp.write("/* Driver subsystems */\n")
|
fp.write("/* Driver subsystems */\n")
|
||||||
for subsystem in subsystems:
|
for subsystem in subsystems:
|
||||||
subsystem = subsystem.replace("_driver_api", "")
|
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.upper(),
|
||||||
subsystem
|
subsystem
|
||||||
))
|
))
|
||||||
@ -225,7 +225,7 @@ def write_kobj_size_output(fp):
|
|||||||
if dep:
|
if dep:
|
||||||
fp.write("#ifdef %s\n" % 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))
|
(kobject_to_enum(kobj), kobj))
|
||||||
if dep:
|
if dep:
|
||||||
fp.write("#endif\n")
|
fp.write("#endif\n")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user