[kernel] fix some strict compiling warnings

This commit is contained in:
Meco Man 2024-02-19 01:35:50 -05:00
parent 4cbc1a41f6
commit 2748a6ada4
11 changed files with 72 additions and 43 deletions

View File

@ -233,7 +233,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define rt_noreturn
#define rt_inline static inline
#define rt_always_inline rt_inline
#elif defined (_MSC_VER)
#elif defined (_MSC_VER) /* for Visual Studio Compiler */
#define rt_section(x)
#define rt_used
#define rt_align(n) __declspec(align(n))
@ -242,10 +242,12 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define rt_noreturn
#define rt_inline static __inline
#define rt_always_inline rt_inline
#elif defined (__TI_COMPILER_VERSION__)
/* The way that TI compiler set section is different from other(at least
#elif defined (__TI_COMPILER_VERSION__) /* for TI CCS Compiler */
/**
* The way that TI compiler set section is different from other(at least
* GCC and MDK) compilers. See ARM Optimizing C/C++ Compiler 5.9.3 for more
* details. */
* details.
*/
#define rt_section(x) __attribute__((section(x)))
#ifdef __TI_EABI__
#define rt_used __attribute__((retain)) __attribute__((used))
@ -263,7 +265,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define rt_noreturn
#define rt_inline static inline
#define rt_always_inline rt_inline
#elif defined (__TASKING__)
#elif defined (__TASKING__) /* for TASKING Compiler */
#define rt_section(x) __attribute__((section(x)))
#define rt_used __attribute__((used, protect))
#define PRAGMA(x) _Pragma(#x)
@ -273,7 +275,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define rt_noreturn
#define rt_inline static inline
#define rt_always_inline rt_inline
#else
#else /* Unkown Compiler */
#error not supported tool chain
#endif /* __ARMCC_VERSION */
@ -322,10 +324,10 @@ typedef int (*init_fn_t)(void);
#define INIT_EXPORT(fn, level) \
rt_used const init_fn_t __rt_init_##fn rt_section(".rti_fn." level) = fn
#endif /* RT_DEBUGING_AUTO_INIT */
#endif
#endif /* _MSC_VER */
#else
#define INIT_EXPORT(fn, level)
#endif
#endif /* RT_USING_COMPONENTS_INIT */
/* board init routines will be called in board_init() function */
#define INIT_BOARD_EXPORT(fn) INIT_EXPORT(fn, "1")
@ -380,15 +382,15 @@ typedef int (*init_fn_t)(void);
/* kernel malloc definitions */
#ifndef RT_KERNEL_MALLOC
#define RT_KERNEL_MALLOC(sz) rt_malloc(sz)
#endif
#endif /* RT_KERNEL_MALLOC */
#ifndef RT_KERNEL_FREE
#define RT_KERNEL_FREE(ptr) rt_free(ptr)
#endif
#endif /* RT_KERNEL_FREE */
#ifndef RT_KERNEL_REALLOC
#define RT_KERNEL_REALLOC(ptr, size) rt_realloc(ptr, size)
#endif
#endif /* RT_KERNEL_REALLOC */
/**
* @addtogroup Error
@ -961,7 +963,7 @@ typedef struct {
#if _LWP_NSIG <= 64
#define lwp_sigmask(signo) ((lwp_sigset_t){.sig = {[0] = ((long)(1u << ((signo)-1)))}})
#define lwp_sigset_init(mask) ((lwp_sigset_t){.sig = {[0] = (long)(mask)}})
#endif
#endif /* _LWP_NSIG <= 64 */
struct lwp_sigaction {
union {
@ -1004,7 +1006,7 @@ struct rt_user_context
void *ctx;
};
#endif
#endif /* RT_USING_SMART */
typedef void (*rt_thread_cleanup_t)(struct rt_thread *tid);
@ -1050,7 +1052,7 @@ struct rt_thread
/* object for IPC */
rt_list_t taken_object_list;
rt_object_t pending_object;
#endif
#endif /* RT_USING_MUTEX */
#ifdef RT_USING_EVENT
/* thread event */
@ -1124,8 +1126,8 @@ struct rt_thread
void *mem_regions;
#ifdef RT_USING_HW_STACK_GUARD
void *stack_buf;
#endif
#endif
#endif /* RT_USING_HW_STACK_GUARD */
#endif /* RT_USING_MEM_PROTECTION */
struct rt_spinlock spinlock;
rt_ubase_t user_data; /**< private user data beyond this thread */
@ -1503,7 +1505,7 @@ typedef struct rt_wqueue rt_wqueue_t;
#ifdef RT_USING_DM
struct rt_driver;
struct rt_bus;
#endif
#endif /* RT_USING_DM */
/**
* Device structure
@ -1518,8 +1520,8 @@ struct rt_device
struct rt_driver *drv; /**< driver for powering the device */
#ifdef RT_USING_OFW
void *ofw_node; /**< ofw node get from device tree */
#endif
#endif
#endif /* RT_USING_OFW */
#endif /* RT_USING_DM */
enum rt_device_class_type type; /**< device type */
rt_uint16_t flag; /**< device flag */
@ -1574,7 +1576,7 @@ struct rt_channel
rt_ubase_t ref;
};
typedef struct rt_channel *rt_channel_t;
#endif
#endif /* RT_USING_SMART */
/**@}*/
#endif /* RT_USING_DEVICE */

View File

@ -16,6 +16,8 @@
#ifndef __RT_SERVICE_H__
#define __RT_SERVICE_H__
#include <rtdef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -454,6 +454,8 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb);
#endif /* RT_USING_HEAP */
rt_err_t rt_mb_send(rt_mailbox_t mb, rt_ubase_t value);
rt_err_t rt_mb_send_interruptible(rt_mailbox_t mb, rt_ubase_t value);
rt_err_t rt_mb_send_killable(rt_mailbox_t mb, rt_ubase_t value);
rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
rt_ubase_t value,
rt_int32_t timeout);

View File

@ -178,9 +178,10 @@ struct rt_thread main_thread;
*
* @param parameter is the arg of the thread.
*/
void main_thread_entry(void *parameter)
static void main_thread_entry(void *parameter)
{
extern int main(void);
RT_UNUSED(parameter);
#ifdef RT_USING_COMPONENTS_INIT
/* RT-Thread components initialization */
@ -198,7 +199,7 @@ void main_thread_entry(void *parameter)
}
#elif defined(__ICCARM__) || defined(__GNUC__) || defined(__TASKING__) || defined(__TI_COMPILER_VERSION__)
main();
#endif
#endif /* __ARMCC_VERSION */
}
/**

View File

@ -263,6 +263,7 @@ static void rt_defunct_execute(void)
static void idle_thread_entry(void *parameter)
{
RT_UNUSED(parameter);
#ifdef RT_USING_SMP
if (rt_hw_cpu_id() != 0)
{

View File

@ -1591,11 +1591,11 @@ RTM_EXPORT(rt_mutex_release);
*/
rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg)
{
/* parameter check */
RT_ASSERT(mutex != RT_NULL);
RT_ASSERT(rt_object_get_type(&mutex->parent.parent) == RT_Object_Class_Mutex);
RT_UNUSED(mutex);
RT_UNUSED(cmd);
RT_UNUSED(arg);
return -RT_ERROR;
return -RT_EINVAL;
}
RTM_EXPORT(rt_mutex_control);
@ -2123,6 +2123,8 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg)
{
rt_base_t level;
RT_UNUSED(arg);
/* parameter check */
RT_ASSERT(event != RT_NULL);
RT_ASSERT(rt_object_get_type(&event->parent.parent) == RT_Object_Class_Event);
@ -2866,6 +2868,8 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg)
{
rt_base_t level;
RT_UNUSED(arg);
/* parameter check */
RT_ASSERT(mb != RT_NULL);
RT_ASSERT(rt_object_get_type(&mb->parent.parent) == RT_Object_Class_MailBox);
@ -3243,6 +3247,8 @@ static rt_err_t _rt_mq_send_wait(rt_mq_t mq,
struct rt_thread *thread;
rt_err_t ret;
RT_UNUSED(prio);
/* parameter check */
RT_ASSERT(mq != RT_NULL);
RT_ASSERT(rt_object_get_type(&mq->parent.parent) == RT_Object_Class_MessageQueue);
@ -3626,6 +3632,8 @@ static rt_ssize_t _rt_mq_recv(rt_mq_t mq,
rt_err_t ret;
rt_size_t len;
RT_UNUSED(prio);
/* parameter check */
RT_ASSERT(mq != RT_NULL);
RT_ASSERT(rt_object_get_type(&mq->parent.parent) == RT_Object_Class_MessageQueue);
@ -3839,6 +3847,8 @@ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg)
rt_base_t level;
struct rt_mq_message *msg;
RT_UNUSED(arg);
/* parameter check */
RT_ASSERT(mq != RT_NULL);
RT_ASSERT(rt_object_get_type(&mq->parent.parent) == RT_Object_Class_MessageQueue);

View File

@ -95,12 +95,18 @@ rt_weak void rt_hw_cpu_shutdown(void)
rt_weak rt_err_t rt_hw_backtrace_frame_get(rt_thread_t thread, struct rt_hw_backtrace_frame *frame)
{
RT_UNUSED(thread);
RT_UNUSED(frame);
LOG_W("%s is not implemented", __func__);
return -RT_ENOSYS;
}
rt_weak rt_err_t rt_hw_backtrace_frame_unwind(rt_thread_t thread, struct rt_hw_backtrace_frame *frame)
{
RT_UNUSED(thread);
RT_UNUSED(frame);
LOG_W("%s is not implemented", __func__);
return -RT_ENOSYS;
}
@ -1482,6 +1488,7 @@ RTM_EXPORT(rt_console_set_device);
rt_weak void rt_hw_console_output(const char *str)
{
/* empty console output */
RT_UNUSED(str);
}
RTM_EXPORT(rt_hw_console_output);
@ -1918,7 +1925,7 @@ rt_inline void _slab_info(rt_size_t *total,
#define _MEM_INFO(...)
#endif
void _rt_system_heap_init(void *begin_addr, void *end_addr)
static void _rt_system_heap_init(void *begin_addr, void *end_addr)
{
rt_ubase_t begin_align = RT_ALIGN((rt_ubase_t)begin_addr, RT_ALIGN_SIZE);
rt_ubase_t end_align = RT_ALIGN_DOWN((rt_ubase_t)end_addr, RT_ALIGN_SIZE);

View File

@ -562,7 +562,7 @@ RTM_EXPORT(rt_smem_free);
#include <finsh.h>
#ifdef RT_USING_MEMTRACE
int memcheck(int argc, char *argv[])
static int memcheck(int argc, char *argv[])
{
int position;
rt_base_t level;
@ -611,7 +611,7 @@ __exit:
}
MSH_CMD_EXPORT(memcheck, check memory data);
int memtrace(int argc, char **argv)
static int memtrace(int argc, char **argv)
{
struct rt_small_mem_item *mem;
struct rt_small_mem *m;

View File

@ -861,7 +861,7 @@ void *_memheap_realloc(struct rt_memheap *heap, void *rmem, rt_size_t newsize)
#endif
#ifdef RT_USING_MEMTRACE
int memheapcheck(int argc, char *argv[])
static int memheapcheck(int argc, char *argv[])
{
struct rt_object_information *info;
struct rt_list_node *list;
@ -926,7 +926,7 @@ int memheapcheck(int argc, char *argv[])
}
MSH_CMD_EXPORT(memheapcheck, check memory for memheap);
int memheaptrace(int argc, char *argv[])
static int memheaptrace(int argc, char *argv[])
{
struct rt_object_information *info;
struct rt_list_node *list;

View File

@ -30,7 +30,7 @@
* 2021-11-15 THEWON Remove duplicate work between idle and _thread_exit
* 2021-12-27 Meco Man remove .init_priority
* 2022-01-07 Gabriel Moving __on_rt_xxxxx_hook to thread.c
* 2022-01-24 THEWON let rt_thread_sleep return thread->error when using signal
* 2022-01-24 THEWON let _thread_sleep return thread->error when using signal
* 2022-10-15 Bernard add nested mutex feature
* 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable
* 2023-12-10 xqyjlj fix thread_exit/detach/delete
@ -164,6 +164,8 @@ static rt_err_t _thread_init(struct rt_thread *thread,
rt_uint8_t priority,
rt_uint32_t tick)
{
RT_UNUSED(name);
/* init thread list */
rt_list_init(&(thread->tlist));
rt_list_init(&(thread->tlist_schedule));
@ -622,7 +624,7 @@ RTM_EXPORT(rt_thread_yield);
* @return Return the operation status. If the return value is RT_EOK, the function is successfully executed.
* If the return value is any other values, it means this operation failed.
*/
rt_err_t rt_thread_sleep(rt_tick_t tick)
static rt_err_t _thread_sleep(rt_tick_t tick)
{
rt_base_t level;
struct rt_thread *thread;
@ -686,7 +688,7 @@ rt_err_t rt_thread_sleep(rt_tick_t tick)
*/
rt_err_t rt_thread_delay(rt_tick_t tick)
{
return rt_thread_sleep(tick);
return _thread_sleep(tick);
}
RTM_EXPORT(rt_thread_delay);
@ -773,7 +775,7 @@ rt_err_t rt_thread_mdelay(rt_int32_t ms)
tick = rt_tick_from_millisecond(ms);
return rt_thread_sleep(tick);
return _thread_sleep(tick);
}
RTM_EXPORT(rt_thread_mdelay);

View File

@ -748,7 +748,7 @@ rt_tick_t rt_timer_next_timeout_tick(void)
* @brief This function will check software-timer list, if a timeout event happens, the
* corresponding timeout function will be invoked.
*/
void rt_soft_timer_check(void)
static void _soft_timer_check(void)
{
rt_tick_t current_tick;
struct rt_timer *t;
@ -829,6 +829,8 @@ static void _timer_thread_entry(void *parameter)
rt_tick_t next_timeout;
rt_base_t level;
RT_UNUSED(parameter);
rt_sem_control(&_soft_timer_sem, RT_IPC_CMD_SET_VLIMIT, (void*)1);
while (1)
@ -858,7 +860,7 @@ static void _timer_thread_entry(void *parameter)
}
/* check software timer */
rt_soft_timer_check();
_soft_timer_check();
}
}
#endif /* RT_USING_TIMER_SOFT */