shaojinchun 5 лет назад
Родитель
Сommit
bfd3e0bf7c

+ 3 - 3
components/dfs/filesystems/jffs2/dfs_jffs2.c

@@ -241,7 +241,7 @@ static int dfs_jffs2_open(struct dfs_fd* file)
     }
     else /* name[0] still will be '/' */
     {
-        name ++;
+        name++;
     }
 
     result = _find_fs(&mte, fs->dev_id);
@@ -520,7 +520,7 @@ static int dfs_jffs2_getdents(struct dfs_fd* file,
                 return -ENOMEM;
 
         /* make a right entry */
-        if ((file->fnode->path[0] == '/') )
+        if (file->fnode->path[0] == '/')
         {
             if (file->fnode->path[1] == 0)
             {
@@ -557,7 +557,7 @@ static int dfs_jffs2_getdents(struct dfs_fd* file,
         d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
         rt_strncpy(d->d_name, jffs2_d.d_name, d->d_namlen + 1);
 
-        index ++;
+        index++;
         if (index * sizeof(struct dirent) >= count)
         {
             break;

+ 1 - 4
components/dfs/filesystems/nfs/dfs_nfs.c

@@ -562,7 +562,6 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
     if (file->fnode->type == FT_DIRECTORY)
         return -EISDIR;
 
-
     RT_ASSERT(file->fnode->data != NULL);
     struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem *)(file->fnode->data));
     nfs = (struct nfs_filesystem *)(dfs_nfs->data);
@@ -679,8 +678,7 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
             file->fnode->size = fd->size;
         }
         xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res);
-    }
-    while (count > 0);
+    } while (count > 0);
 
     xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res);
 
@@ -1085,7 +1083,6 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
     nfs_filesystem *nfs;
     char *name;
 
-
     RT_ASSERT(file->fnode->data != NULL);
     struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem *)(file->fnode->data));
     nfs = (struct nfs_filesystem *)(dfs_nfs->data);

+ 1 - 1
components/dfs/filesystems/ramfs/dfs_ramfs.c

@@ -227,7 +227,7 @@ int dfs_ramfs_open(struct dfs_fd *file)
                 /* remove '/' separator */
                 name_ptr = file->fnode->path;
                 while (*name_ptr == '/' && *name_ptr)
-                    name_ptr ++;
+                    name_ptr++;
                 strncpy(dirent->name, name_ptr, RAMFS_NAME_MAX);
 
                 rt_list_init(&(dirent->list));

+ 1 - 1
components/dfs/filesystems/romfs/dfs_romfs.c

@@ -261,7 +261,7 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
         return -EINVAL;
 
     index = 0;
-    for (index = 0; index < count && file->pos < file->fnode->size; index ++)
+    for (index = 0; index < count && file->pos < file->fnode->size; index++)
     {
         d = dirp + index;
 

+ 18 - 20
components/dfs/src/dfs.c

@@ -145,8 +145,8 @@ void dfs_fd_unlock(void)
 
 static int fd_slot_expand(struct dfs_fdtable *fdt, int fd)
 {
-    int nr = 0;
-    int index = 0;
+    int nr;
+    int index;
     struct dfs_fd **fds = NULL;
 
     if (fd < fdt->maxfd)
@@ -182,7 +182,7 @@ static int fd_slot_expand(struct dfs_fdtable *fdt, int fd)
 
 static int fd_slot_alloc(struct dfs_fdtable *fdt, int startfd)
 {
-    int idx = 0;
+    int idx;
 
     /* find an empty fd slot */
     for (idx = startfd; idx < (int)fdt->maxfd; idx++)
@@ -207,7 +207,7 @@ static int fd_slot_alloc(struct dfs_fdtable *fdt, int startfd)
 
 static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
 {
-    int idx = 0;
+    int idx;
     struct dfs_fd *fd = NULL;
 
     idx = fd_slot_alloc(fdt, startfd);
@@ -238,7 +238,7 @@ static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
  */
 int fdt_fd_new(struct dfs_fdtable *fdt)
 {
-    int idx = 0;
+    int idx;
 
     /* lock filesystem */
     dfs_fd_lock();
@@ -250,10 +250,8 @@ int fdt_fd_new(struct dfs_fdtable *fdt)
     if (idx < 0)
     {
         LOG_E("DFS fd new is failed! Could not found an empty fd entry.");
-        goto __result;
     }
 
-__result:
     dfs_fd_unlock();
     return idx;
 }
@@ -508,7 +506,7 @@ const char *dfs_subdir(const char *directory, const char *filename)
     dir = filename + strlen(directory);
     if ((*dir != '/') && (dir != filename))
     {
-        dir --;
+        dir--;
     }
 
     return dir;
@@ -573,14 +571,14 @@ char *dfs_normalize_path(const char *directory, const char *filename)
 
         if (c == '.')
         {
-            if (!src[1]) src ++; /* '.' and ends */
+            if (!src[1]) src++; /* '.' and ends */
             else if (src[1] == '/')
             {
                 /* './' case */
                 src += 2;
 
                 while ((*src == '/') && (*src != '\0'))
-                    src ++;
+                    src++;
                 continue;
             }
             else if (src[1] == '.')
@@ -597,7 +595,7 @@ char *dfs_normalize_path(const char *directory, const char *filename)
                     src += 3;
 
                     while ((*src == '/') && (*src != '\0'))
-                        src ++;
+                        src++;
                     goto up_one;
                 }
             }
@@ -605,15 +603,15 @@ char *dfs_normalize_path(const char *directory, const char *filename)
 
         /* copy up the next '/' and erase all '/' */
         while ((c = *src++) != '\0' && c != '/')
-            *dst ++ = c;
+            *dst++ = c;
 
         if (c == '/')
         {
-            *dst ++ = '/';
+            *dst++ = '/';
             while (c == '/')
                 c = *src++;
 
-            src --;
+            src--;
         }
         else if (!c)
             break;
@@ -621,20 +619,20 @@ char *dfs_normalize_path(const char *directory, const char *filename)
         continue;
 
 up_one:
-        dst --;
+        dst--;
         if (dst < dst0)
         {
             rt_free(fullpath);
             return NULL;
         }
         while (dst0 < dst && dst[-1] != '/')
-            dst --;
+            dst--;
     }
 
     *dst = '\0';
 
     /* remove '/' in the end of path if exist */
-    dst --;
+    dst--;
     if ((dst != fullpath) && (*dst == '/'))
         *dst = '\0';
 
@@ -689,7 +687,7 @@ int list_fd(void)
 
     rt_kprintf("fd type    ref magic  path\n");
     rt_kprintf("-- ------  --- ----- ------\n");
-    for (index = 0; index < (int)fd_table->maxfd; index ++)
+    for (index = 0; index < (int)fd_table->maxfd; index++)
     {
         struct dfs_fd *fd = fd_table->fds[index];
 
@@ -737,12 +735,12 @@ int mount(int argc, char *argv[])
         rt_kprintf("filesystem  device  mountpoint\n");
         rt_kprintf("----------  ------  ----------\n");
         for (iter = &filesystem_table[0];
-             iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++)
+                iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++)
         {
             if ((iter != NULL) && (iter->path != NULL))
             {
                 rt_kprintf("%-10s  %-6s  %-s\n",
-                           iter->ops->name, iter->dev_id->parent.name, iter->path);
+                        iter->ops->name, iter->dev_id->parent.name, iter->path);
             }
         }
         return 0;

+ 4 - 8
components/dfs/src/dfs_file.c

@@ -771,8 +771,7 @@ void ls(const char *pathname)
                     rt_kprintf("BAD file: %s\n", dirent.d_name);
                 rt_free(fullpath);
             }
-        }
-        while (length > 0);
+        } while (length > 0);
 
         dfs_file_close(&fd);
     }
@@ -816,8 +815,7 @@ void cat(const char *filename)
             buffer[length] = '\0';
             rt_kprintf("%s", buffer);
         }
-    }
-    while (length > 0);
+    } while (length > 0);
 
     dfs_file_close(&fd);
 }
@@ -873,8 +871,7 @@ static void copyfile(const char *src, const char *dst)
                 break;
             }
         }
-    }
-    while (read_bytes > 0);
+    } while (read_bytes > 0);
 
     dfs_file_close(&src_fd);
     dfs_file_close(&fd);
@@ -939,8 +936,7 @@ static void copydir(const char *src, const char *dst)
             rt_free(src_entry_full);
             rt_free(dst_entry_full);
         }
-    }
-    while (length > 0);
+    } while (length > 0);
 
     dfs_file_close(&cpfd);
 }

+ 11 - 11
components/drivers/src/pipe.c

@@ -42,17 +42,17 @@ static int pipe_fops_open(struct dfs_fd *fd)
     switch (fd->fnode->flags & O_ACCMODE)
     {
     case O_RDONLY:
-        pipe->readers ++;
+        pipe->readers++;
         break;
     case O_WRONLY:
-        pipe->writers ++;
+        pipe->writers++;
         break;
     case O_RDWR:
-        pipe->readers ++;
-        pipe->writers ++;
+        pipe->readers++;
+        pipe->writers++;
         break;
     }
-    device->ref_count ++;
+    device->ref_count++;
 
 __exit:
     rt_mutex_release(&(pipe->lock));
@@ -74,14 +74,14 @@ static int pipe_fops_close(struct dfs_fd *fd)
     switch (fd->fnode->flags & O_ACCMODE)
     {
     case O_RDONLY:
-        pipe->readers --;
+        pipe->readers--;
         break;
     case O_WRONLY:
-        pipe->writers --;
+        pipe->writers--;
         break;
     case O_RDWR:
-        pipe->readers --;
-        pipe->writers --;
+        pipe->readers--;
+        pipe->writers--;
         break;
     }
 
@@ -101,7 +101,7 @@ static int pipe_fops_close(struct dfs_fd *fd)
             rt_ringbuffer_destroy(pipe->fifo);
         pipe->fifo = RT_NULL;
     }
-    device->ref_count --;
+    device->ref_count--;
 
     rt_mutex_release(&(pipe->lock));
 
@@ -564,7 +564,7 @@ int pipe(int fildes[2])
 int mkfifo(const char *path, mode_t mode)
 {
     rt_pipe_t *pipe;
-    
+
     pipe = rt_pipe_create(path, PIPE_BUFSZ);
     if (pipe == RT_NULL)
     {