kernel: Delimiting the scope of some variables

According with MISRA-C an object should be defined in a block scope if
it is used in a single function.

MISRA-C rule 8.9

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2018-11-01 17:42:07 -07:00 committed by Anas Nashif
commit ac14685211
4 changed files with 20 additions and 16 deletions

View file

@ -17,14 +17,6 @@ extern struct device __device_POST_KERNEL_start[];
extern struct device __device_APPLICATION_start[];
extern struct device __device_init_end[];
static struct device *config_levels[] = {
__device_PRE_KERNEL_1_start,
__device_PRE_KERNEL_2_start,
__device_POST_KERNEL_start,
__device_APPLICATION_start,
/* End marker */
__device_init_end,
};
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
extern u32_t __device_busy_start[];
@ -46,6 +38,14 @@ extern u32_t __device_busy_end[];
void _sys_device_do_config_level(s32_t level)
{
struct device *info;
static struct device *config_levels[] = {
__device_PRE_KERNEL_1_start,
__device_PRE_KERNEL_2_start,
__device_POST_KERNEL_start,
__device_APPLICATION_start,
/* End marker */
__device_init_end,
};
for (info = config_levels[level]; info < config_levels[level+1];
info++) {

View file

@ -43,10 +43,8 @@ LOG_MODULE_REGISTER(kernel);
#if defined(CONFIG_BOOT_DELAY) && CONFIG_BOOT_DELAY > 0
#define BOOT_DELAY_BANNER " (delayed boot " \
STRINGIFY(CONFIG_BOOT_DELAY) "ms)"
static const unsigned int boot_delay = CONFIG_BOOT_DELAY;
#else
#define BOOT_DELAY_BANNER ""
static const unsigned int boot_delay;
#endif
#ifdef BUILD_VERSION
@ -199,6 +197,12 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
ARG_UNUSED(unused2);
ARG_UNUSED(unused3);
#if defined(CONFIG_BOOT_DELAY) && CONFIG_BOOT_DELAY > 0
static const unsigned int boot_delay = CONFIG_BOOT_DELAY;
#else
static const unsigned int boot_delay;
#endif
_sys_device_do_config_level(_SYS_INIT_LEVEL_POST_KERNEL);
#if CONFIG_STACK_POINTER_RANDOM
z_stack_adjust_initialized = 1;

View file

@ -26,9 +26,6 @@ struct k_mbox_async {
struct k_mbox_msg tx_msg; /* transmit message descriptor */
};
/* array of asynchronous message descriptors */
static struct k_mbox_async __noinit async_msg[CONFIG_NUM_MBOX_ASYNC_MSGS];
/* stack of unused asynchronous message descriptors */
K_STACK_DEFINE(async_msg_free, CONFIG_NUM_MBOX_ASYNC_MSGS);
@ -63,6 +60,9 @@ static int init_mbox_module(struct device *dev)
{
ARG_UNUSED(dev);
/* array of asynchronous message descriptors */
static struct k_mbox_async __noinit async_msg[CONFIG_NUM_MBOX_ASYNC_MSGS];
#if (CONFIG_NUM_MBOX_ASYNC_MSGS > 0)
/*
* Create pool of asynchronous message descriptors.

View file

@ -45,9 +45,6 @@ struct k_pipe *_trace_list_k_pipe;
#if (CONFIG_NUM_PIPE_ASYNC_MSGS > 0)
/* Array of asynchronous message descriptors */
static struct k_pipe_async __noinit async_msg[CONFIG_NUM_PIPE_ASYNC_MSGS];
/* stack of unused asynchronous message descriptors */
K_STACK_DEFINE(pipe_async_msgs, CONFIG_NUM_PIPE_ASYNC_MSGS);
@ -91,6 +88,9 @@ static int init_pipes_module(struct device *dev)
{
ARG_UNUSED(dev);
/* Array of asynchronous message descriptors */
static struct k_pipe_async __noinit async_msg[CONFIG_NUM_PIPE_ASYNC_MSGS];
#if (CONFIG_NUM_PIPE_ASYNC_MSGS > 0)
/*
* Create pool of asynchronous pipe message descriptors.