Browse Source

Merge pull request #3265 from BernardXiong/comments_cleanup

[kernel] code and comments cleanup
Bernard Xiong 5 years ago
parent
commit
75a3f3dd3a
9 changed files with 67 additions and 67 deletions
  1. 3 3
      include/libc/libc_signal.h
  2. 1 1
      include/rtdef.h
  3. 1 1
      include/rthw.h
  4. 1 1
      src/clock.c
  5. 8 8
      src/device.c
  6. 47 47
      src/ipc.c
  7. 1 1
      src/kservice.c
  8. 2 2
      src/signal.c
  9. 3 3
      src/thread.c

+ 3 - 3
include/libc/libc_signal.h

@@ -24,7 +24,7 @@ extern "C" {
     NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
           sigev_notify_attributes to the sigevent structure.  */
 
-union sigval 
+union sigval
 {
     int    sival_int;    /* Integer signal value */
     void  *sival_ptr;    /* Pointer signal value */
@@ -107,7 +107,7 @@ typedef unsigned long sigset_t;
 
 typedef void (*_sig_func_ptr)(int);
 
-struct sigaction 
+struct sigaction
 {
     _sig_func_ptr sa_handler;
     sigset_t sa_mask;
@@ -163,7 +163,7 @@ typedef unsigned long sigset_t;
 
 typedef void (*_sig_func_ptr)(int);
 
-struct sigaction 
+struct sigaction
 {
     _sig_func_ptr sa_handler;
     sigset_t sa_mask;

+ 1 - 1
include/rtdef.h

@@ -522,7 +522,7 @@ typedef siginfo_t rt_siginfo_t;
 
 /**
  * CPUs definitions
- * 
+ *
  */
 struct rt_cpu
 {

+ 1 - 1
include/rthw.h

@@ -37,7 +37,7 @@ extern "C" {
 #endif
 
 #ifndef RT_CPU_CACHE_LINE_SZ
-#define RT_CPU_CACHE_LINE_SZ	32
+#define RT_CPU_CACHE_LINE_SZ    32
 #endif
 
 enum RT_HW_CACHE_OPS

+ 1 - 1
src/clock.c

@@ -25,7 +25,7 @@ static rt_tick_t rt_tick = 0;
 #endif
 
 /**
- * This function will init system tick and set it to zero.
+ * This function will initialize system tick and set it to zero.
  * @ingroup SystemInit
  *
  * @deprecated since 1.1.0, this function does not need to be invoked

+ 8 - 8
src/device.c

@@ -95,7 +95,7 @@ RTM_EXPORT(rt_device_unregister);
  * @return the error code, RT_EOK on successfully.
  *
  * @deprecated since 1.2.x, this function is not needed because the initialization
- *             of a device is performed when applicaiton opens it.
+ *             of a device is performed when application opens it.
  */
 rt_err_t rt_device_init_all(void)
 {
@@ -162,7 +162,7 @@ rt_device_t rt_device_create(int type, int attach_size)
 
     size = RT_ALIGN(sizeof(struct rt_device), RT_ALIGN_SIZE);
     attach_size = RT_ALIGN(attach_size, RT_ALIGN_SIZE);
-    /* use the totoal size */
+    /* use the total size */
     size += attach_size;
 
     device = (rt_device_t)rt_malloc(size);
@@ -208,7 +208,7 @@ rt_err_t rt_device_init(rt_device_t dev)
 
     RT_ASSERT(dev != RT_NULL);
 
-    /* get device init handler */
+    /* get device_init handler */
     if (device_init != RT_NULL)
     {
         if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
@@ -269,7 +269,7 @@ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
         return -RT_EBUSY;
     }
 
-    /* call device open interface */
+    /* call device_open interface */
     if (device_open != RT_NULL)
     {
         result = device_open(dev, oflag);
@@ -317,7 +317,7 @@ rt_err_t rt_device_close(rt_device_t dev)
     if (dev->ref_count != 0)
         return RT_EOK;
 
-    /* call device close interface */
+    /* call device_close interface */
     if (device_close != RT_NULL)
     {
         result = device_close(dev);
@@ -357,7 +357,7 @@ rt_size_t rt_device_read(rt_device_t dev,
         return 0;
     }
 
-    /* call device read interface */
+    /* call device_read interface */
     if (device_read != RT_NULL)
     {
         return device_read(dev, pos, buffer, size);
@@ -396,7 +396,7 @@ rt_size_t rt_device_write(rt_device_t dev,
         return 0;
     }
 
-    /* call device write interface */
+    /* call device_write interface */
     if (device_write != RT_NULL)
     {
         return device_write(dev, pos, buffer, size);
@@ -423,7 +423,7 @@ rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg)
     RT_ASSERT(dev != RT_NULL);
     RT_ASSERT(rt_object_get_type(&dev->parent) == RT_Object_Class_Device);
 
-    /* call device write interface */
+    /* call device_write interface */
     if (device_control != RT_NULL)
     {
         return device_control(dev, cmd, arg);

+ 47 - 47
src/ipc.c

@@ -60,7 +60,7 @@ extern void (*rt_object_put_hook)(struct rt_object *object);
  */
 rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc)
 {
-    /* init ipc object */
+    /* initialize ipc object */
     rt_list_init(&(ipc->suspend_thread));
 
     return RT_EOK;
@@ -159,13 +159,13 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
     struct rt_thread *thread;
     register rt_ubase_t temp;
 
-    /* wakeup all suspend threads */
+    /* wakeup all suspended threads */
     while (!rt_list_isempty(list))
     {
         /* disable interrupt */
         temp = rt_hw_interrupt_disable();
 
-        /* get next suspend thread */
+        /* get next suspended thread */
         thread = rt_list_entry(list->next, struct rt_thread, tlist);
         /* set error code to RT_ERROR */
         thread->error = -RT_ERROR;
@@ -173,7 +173,7 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
         /*
          * resume thread
          * In rt_thread_resume function, it will remove current thread from
-         * suspend list
+         * suspended list
          */
         rt_thread_resume(thread);
 
@@ -191,7 +191,7 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
  *
  * @param sem the semaphore object
  * @param name the name of semaphore
- * @param value the init value of semaphore
+ * @param value the initial value of semaphore
  * @param flag the flag of semaphore
  *
  * @return the operation status, RT_EOK on successful
@@ -204,13 +204,13 @@ rt_err_t rt_sem_init(rt_sem_t    sem,
     RT_ASSERT(sem != RT_NULL);
     RT_ASSERT(value < 0x10000U);
 
-    /* init object */
+    /* initialize object */
     rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name);
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(sem->parent));
 
-    /* set init value */
+    /* set initial value */
     sem->value = (rt_uint16_t)value;
 
     /* set parent */
@@ -236,7 +236,7 @@ rt_err_t rt_sem_detach(rt_sem_t sem)
     RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore);
     RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent));
 
-    /* wakeup all suspend threads */
+    /* wakeup all suspended threads */
     rt_ipc_list_resume_all(&(sem->parent.suspend_thread));
 
     /* detach semaphore object */
@@ -251,7 +251,7 @@ RTM_EXPORT(rt_sem_detach);
  * This function will create a semaphore from system resource
  *
  * @param name the name of semaphore
- * @param value the init value of semaphore
+ * @param value the initial value of semaphore
  * @param flag the flag of semaphore
  *
  * @return the created semaphore, RT_NULL on error happen
@@ -270,10 +270,10 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag)
     if (sem == RT_NULL)
         return sem;
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(sem->parent));
 
-    /* set init value */
+    /* set initial value */
     sem->value = value;
 
     /* set parent */
@@ -301,7 +301,7 @@ rt_err_t rt_sem_delete(rt_sem_t sem)
     RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore);
     RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent) == RT_FALSE);
 
-    /* wakeup all suspend threads */
+    /* wakeup all suspended threads */
     rt_ipc_list_resume_all(&(sem->parent.suspend_thread));
 
     /* delete semaphore object */
@@ -532,10 +532,10 @@ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag)
     /* parameter check */
     RT_ASSERT(mutex != RT_NULL);
 
-    /* init object */
+    /* initialize object */
     rt_object_init(&(mutex->parent.parent), RT_Object_Class_Mutex, name);
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(mutex->parent));
 
     mutex->value = 1;
@@ -566,10 +566,10 @@ rt_err_t rt_mutex_detach(rt_mutex_t mutex)
     RT_ASSERT(rt_object_get_type(&mutex->parent.parent) == RT_Object_Class_Mutex);
     RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent));
 
-    /* wakeup all suspend threads */
+    /* wakeup all suspended threads */
     rt_ipc_list_resume_all(&(mutex->parent.suspend_thread));
 
-    /* detach mutex object */
+    /* detach semaphore object */
     rt_object_detach(&(mutex->parent.parent));
 
     return RT_EOK;
@@ -598,7 +598,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag)
     if (mutex == RT_NULL)
         return mutex;
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(mutex->parent));
 
     mutex->value              = 1;
@@ -631,7 +631,7 @@ rt_err_t rt_mutex_delete(rt_mutex_t mutex)
     RT_ASSERT(rt_object_get_type(&mutex->parent.parent) == RT_Object_Class_Mutex);
     RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent) == RT_FALSE);
 
-    /* wakeup all suspend threads */
+    /* wakeup all suspended threads */
     rt_ipc_list_resume_all(&(mutex->parent.suspend_thread));
 
     /* delete mutex object */
@@ -917,16 +917,16 @@ rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag)
     /* parameter check */
     RT_ASSERT(event != RT_NULL);
 
-    /* init object */
+    /* initialize object */
     rt_object_init(&(event->parent.parent), RT_Object_Class_Event, name);
 
     /* set parent flag */
     event->parent.parent.flag = flag;
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(event->parent));
 
-    /* init event */
+    /* initialize event */
     event->set = 0;
 
     return RT_EOK;
@@ -980,10 +980,10 @@ rt_event_t rt_event_create(const char *name, rt_uint8_t flag)
     /* set parent */
     event->parent.parent.flag = flag;
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(event->parent));
 
-    /* init event */
+    /* initialize event */
     event->set = 0;
 
     return event;
@@ -1050,7 +1050,7 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set)
     event->set |= set;
 
     RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(event->parent.parent)));
-    
+
     if (!rt_list_isempty(&event->parent.suspend_thread))
     {
         /* search thread list to resume thread */
@@ -1073,7 +1073,7 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set)
             {
                 if (thread->event_set & event->set)
                 {
-                    /* save recieved event set */
+                    /* save the received event set */
                     thread->event_set = thread->event_set & event->set;
 
                     /* received an OR event */
@@ -1143,7 +1143,7 @@ rt_err_t rt_event_recv(rt_event_t   event,
     if (set == 0)
         return -RT_ERROR;
 
-    /* init status */
+    /* initialize status */
     status = -RT_ERROR;
     /* get current thread */
     thread = rt_thread_self();
@@ -1253,7 +1253,7 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg)
     /* parameter check */
     RT_ASSERT(event != RT_NULL);
     RT_ASSERT(rt_object_get_type(&event->parent.parent) == RT_Object_Class_Event);
-    
+
     if (cmd == RT_IPC_CMD_RESET)
     {
         /* disable interrupt */
@@ -1262,7 +1262,7 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg)
         /* resume all waiting thread */
         rt_ipc_list_resume_all(&event->parent.suspend_thread);
 
-        /* init event set */
+        /* initialize event set */
         event->set = 0;
 
         /* enable interrupt */
@@ -1299,23 +1299,23 @@ rt_err_t rt_mb_init(rt_mailbox_t mb,
 {
     RT_ASSERT(mb != RT_NULL);
 
-    /* init object */
+    /* initialize object */
     rt_object_init(&(mb->parent.parent), RT_Object_Class_MailBox, name);
 
     /* set parent flag */
     mb->parent.parent.flag = flag;
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(mb->parent));
 
-    /* init mailbox */
+    /* initialize mailbox */
     mb->msg_pool   = (rt_ubase_t *)msgpool;
     mb->size       = size;
     mb->entry      = 0;
     mb->in_offset  = 0;
     mb->out_offset = 0;
 
-    /* init an additional list of sender suspend thread */
+    /* initialize an additional list of sender suspend thread */
     rt_list_init(&(mb->suspend_sender_thread));
 
     return RT_EOK;
@@ -1372,10 +1372,10 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
     /* set parent */
     mb->parent.parent.flag = flag;
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(mb->parent));
 
-    /* init mailbox */
+    /* initialize mailbox */
     mb->size     = size;
     mb->msg_pool = (rt_ubase_t *)RT_KERNEL_MALLOC(mb->size * sizeof(rt_ubase_t));
     if (mb->msg_pool == RT_NULL)
@@ -1389,7 +1389,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
     mb->in_offset  = 0;
     mb->out_offset = 0;
 
-    /* init an additional list of sender suspend thread */
+    /* initialize an additional list of sender suspend thread */
     rt_list_init(&(mb->suspend_sender_thread));
 
     return mb;
@@ -1791,27 +1791,27 @@ rt_err_t rt_mq_init(rt_mq_t     mq,
     /* parameter check */
     RT_ASSERT(mq != RT_NULL);
 
-    /* init object */
+    /* initialize object */
     rt_object_init(&(mq->parent.parent), RT_Object_Class_MessageQueue, name);
 
     /* set parent flag */
     mq->parent.parent.flag = flag;
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(mq->parent));
 
-    /* set messasge pool */
+    /* set message pool */
     mq->msg_pool = msgpool;
 
     /* get correct message size */
     mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE);
     mq->max_msgs = pool_size / (mq->msg_size + sizeof(struct rt_mq_message));
 
-    /* init message list */
+    /* initialize message list */
     mq->msg_queue_head = RT_NULL;
     mq->msg_queue_tail = RT_NULL;
 
-    /* init message empty list */
+    /* initialize message empty list */
     mq->msg_queue_free = RT_NULL;
     for (temp = 0; temp < mq->max_msgs; temp ++)
     {
@@ -1824,7 +1824,7 @@ rt_err_t rt_mq_init(rt_mq_t     mq,
     /* the initial entry is zero */
     mq->entry = 0;
 
-    /* init an additional list of sender suspend thread */
+    /* initialize an additional list of sender suspend thread */
     rt_list_init(&(mq->suspend_sender_thread));
 
     return RT_EOK;
@@ -1887,10 +1887,10 @@ rt_mq_t rt_mq_create(const char *name,
     /* set parent */
     mq->parent.parent.flag = flag;
 
-    /* init ipc object */
+    /* initialize ipc object */
     rt_ipc_object_init(&(mq->parent));
 
-    /* init message queue */
+    /* initialize message queue */
 
     /* get correct message size */
     mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE);
@@ -1905,11 +1905,11 @@ rt_mq_t rt_mq_create(const char *name,
         return RT_NULL;
     }
 
-    /* init message list */
+    /* initialize message list */
     mq->msg_queue_head = RT_NULL;
     mq->msg_queue_tail = RT_NULL;
 
-    /* init message empty list */
+    /* initialize message empty list */
     mq->msg_queue_free = RT_NULL;
     for (temp = 0; temp < mq->max_msgs; temp ++)
     {
@@ -1922,7 +1922,7 @@ rt_mq_t rt_mq_create(const char *name,
     /* the initial entry is zero */
     mq->entry = 0;
 
-    /* init an additional list of sender suspend thread */
+    /* initialize an additional list of sender suspend thread */
     rt_list_init(&(mq->suspend_sender_thread));
 
     return mq;

+ 1 - 1
src/kservice.c

@@ -316,7 +316,7 @@ RTM_EXPORT(rt_memmove);
  * This function will compare two areas of memory
  *
  * @param cs one area of memory
- * @param ct znother area of memory
+ * @param ct another area of memory
  * @param count the size of the area
  *
  * @return the result

+ 2 - 2
src/signal.c

@@ -22,8 +22,8 @@
 #define RT_SIG_INFO_MAX 32
 #endif
 
-#define DBG_TAG    "SIGN"
-#define DBG_LVL           DBG_WARNING
+#define DBG_TAG     "SIGN"
+#define DBG_LVL     DBG_WARNING
 #include <rtdbg.h>
 
 #define sig_mask(sig_no)    (1u << sig_no)

+ 3 - 3
src/thread.c

@@ -179,7 +179,7 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread,
     thread->cleanup   = 0;
     thread->user_data = 0;
 
-    /* init thread timer */
+    /* initialize thread timer */
     rt_timer_init(&(thread->thread_timer),
                   thread->name,
                   rt_thread_timeout,
@@ -242,7 +242,7 @@ rt_err_t rt_thread_init(struct rt_thread *thread,
     RT_ASSERT(thread != RT_NULL);
     RT_ASSERT(stack_start != RT_NULL);
 
-    /* init thread object */
+    /* initialize thread object */
     rt_object_init((rt_object_t)thread, RT_Object_Class_Thread, name);
 
     return _rt_thread_init(thread,
@@ -293,7 +293,7 @@ rt_err_t rt_thread_startup(rt_thread_t thread)
     RT_ASSERT((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_INIT);
     RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
 
-    /* set current priority to init priority */
+    /* set current priority to initialize priority */
     thread->current_priority = thread->init_priority;
 
     /* calculate priority attribute */