Browse Source

Merge pull request #2319 from RT-Thread/fix_warning

[Kernel] Code cleanup for compiling warning.
Bernard Xiong 6 years ago
parent
commit
db1f0f32b5
4 changed files with 8 additions and 8 deletions
  1. 5 5
      components/dfs/src/dfs.c
  2. 1 1
      components/drivers/serial/serial.c
  3. 1 1
      src/kservice.c
  4. 1 1
      src/mem.c

+ 5 - 5
components/dfs/src/dfs.c

@@ -123,7 +123,7 @@ static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
     int idx;
     int idx;
 
 
     /* find an empty fd entry */
     /* find an empty fd entry */
-    for (idx = startfd; idx < fdt->maxfd; idx++)
+    for (idx = startfd; idx < (int)fdt->maxfd; idx++)
     {
     {
         if (fdt->fds[idx] == RT_NULL)
         if (fdt->fds[idx] == RT_NULL)
             break;
             break;
@@ -155,7 +155,7 @@ static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
     }
     }
 
 
     /* allocate  'struct dfs_fd' */
     /* allocate  'struct dfs_fd' */
-    if (idx < fdt->maxfd &&fdt->fds[idx] == RT_NULL)
+    if (idx < (int)fdt->maxfd && fdt->fds[idx] == RT_NULL)
     {
     {
         fdt->fds[idx] = rt_calloc(1, sizeof(struct dfs_fd));
         fdt->fds[idx] = rt_calloc(1, sizeof(struct dfs_fd));
         if (fdt->fds[idx] == RT_NULL)
         if (fdt->fds[idx] == RT_NULL)
@@ -223,7 +223,7 @@ struct dfs_fd *fd_get(int fd)
 
 
     fdt = dfs_fdtable_get();
     fdt = dfs_fdtable_get();
     fd = fd - DFS_FD_OFFSET;
     fd = fd - DFS_FD_OFFSET;
-    if (fd < 0 || fd >= fdt->maxfd)
+    if (fd < 0 || fd >= (int)fdt->maxfd)
         return NULL;
         return NULL;
 
 
     dfs_lock();
     dfs_lock();
@@ -263,7 +263,7 @@ void fd_put(struct dfs_fd *fd)
         struct dfs_fdtable *fdt;
         struct dfs_fdtable *fdt;
 
 
         fdt = dfs_fdtable_get();
         fdt = dfs_fdtable_get();
-        for (index = 0; index < fdt->maxfd; index ++)
+        for (index = 0; index < (int)fdt->maxfd; index ++)
         {
         {
             if (fdt->fds[index] == fd)
             if (fdt->fds[index] == fd)
             {
             {
@@ -531,7 +531,7 @@ int list_fd(void)
     
     
     rt_kprintf("fd type    ref magic  path\n");
     rt_kprintf("fd type    ref magic  path\n");
     rt_kprintf("-- ------  --- ----- ------\n");
     rt_kprintf("-- ------  --- ----- ------\n");
-    for (index = 0; index < fd_table->maxfd; index ++)
+    for (index = 0; index < (int)fd_table->maxfd; index ++)
     {
     {
         struct dfs_fd *fd = fd_table->fds[index];
         struct dfs_fd *fd = fd_table->fds[index];
 
 

+ 1 - 1
components/drivers/serial/serial.c

@@ -478,7 +478,7 @@ rt_inline int _serial_dma_rx(struct rt_serial_device *serial, rt_uint8_t *data,
 
 
         RT_ASSERT(rx_fifo != RT_NULL);
         RT_ASSERT(rx_fifo != RT_NULL);
 
 
-        if (length < fifo_recved_len)
+        if (length < (int)fifo_recved_len)
             recv_len = length;
             recv_len = length;
         else
         else
             recv_len = fifo_recved_len;
             recv_len = fifo_recved_len;

+ 1 - 1
src/kservice.c

@@ -476,7 +476,7 @@ rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen)
 {
 {
     const char *sc;
     const char *sc;
 
 
-    for (sc = s; *sc != '\0' && sc - s < maxlen; ++sc) /* nothing */
+    for (sc = s; *sc != '\0' && sc - s < (int)maxlen; ++sc) /* nothing */
         ;
         ;
 
 
     return sc - s;
     return sc - s;

+ 1 - 1
src/mem.c

@@ -644,7 +644,7 @@ int memcheck(void)
     {
     {
         position = (rt_ubase_t)mem - (rt_ubase_t)heap_ptr;
         position = (rt_ubase_t)mem - (rt_ubase_t)heap_ptr;
         if (position < 0) goto __exit;
         if (position < 0) goto __exit;
-        if (position > mem_size_aligned) goto __exit;
+        if (position > (int)mem_size_aligned) goto __exit;
         if (mem->magic != HEAP_MAGIC) goto __exit;
         if (mem->magic != HEAP_MAGIC) goto __exit;
         if (mem->used != 0 && mem->used != 1) goto __exit;
         if (mem->used != 0 && mem->used != 1) goto __exit;
     }
     }