@@ -96,7 +96,7 @@ vfs_node_t vfs_node_alloc(vfs_node_t parent, const char *name)
9696 node -> refcount = 0 ;
9797 node -> blksz = PAGE_4K_SIZE ;
9898 node -> mode = 0777 ;
99- node -> linkto = NULL ;
99+ node -> linkto = 0 ;
100100
101101 if (parent ) clist_prepend (parent -> child , node );
102102 return node ;
@@ -140,9 +140,9 @@ vfs_node_t vfs_open(const char *str)
140140 vfs_node_t current = rootdir ;
141141
142142 for (char * buf = pathtok (& save_ptr ); buf ; buf = pathtok (& save_ptr )) {
143- if (streq (buf , "." )) { continue ; }
143+ if (streq (buf , "." )) continue ;
144144 if (streq (buf , ".." )) {
145- if (current -> parent ) { current = current -> parent ; }
145+ if (current -> parent ) current = current -> parent ;
146146 continue ;
147147 }
148148
@@ -254,17 +254,20 @@ int vfs_link(const char *name, const char *target_name)
254254 char * save_ptr = path ;
255255 char * filename = path + strlen (path );
256256
257- while (* -- filename != '/' && filename != path ) {}
257+ while (1 ) {
258+ -- filename ;
259+ if (* filename != '/' && filename != path ) break ;
260+ }
258261 if (filename != path ) {
259262 * filename ++ = '\0' ;
260263 } else {
261264 goto create ;
262265 }
263-
264266 if (!strlen (path )) {
265267 free (path );
266268 return -1 ;
267269 }
270+
268271 for (const char * buf = pathtok (& save_ptr ); buf ; buf = pathtok (& save_ptr )) {
269272 if (streq (buf , "." )) continue ;
270273 if (streq (buf , ".." )) {
@@ -307,17 +310,20 @@ int vfs_symlink(const char *name, const char *target_name)
307310 char * save_ptr = path ;
308311 char * filename = path + strlen (path );
309312
310- while (* -- filename != '/' && filename != path ) {}
313+ while (1 ) {
314+ -- filename ;
315+ if (* filename != '/' && filename != path ) break ;
316+ }
311317 if (filename != path ) {
312318 * filename ++ = '\0' ;
313319 } else {
314320 goto create ;
315321 }
316-
317322 if (!strlen (path )) {
318323 free (path );
319324 return -1 ;
320325 }
326+
321327 for (const char * buf = pathtok (& save_ptr ); buf ; buf = pathtok (& save_ptr )) {
322328 if (streq (buf , "." )) continue ;
323329 if (streq (buf , ".." )) {
@@ -326,6 +332,7 @@ int vfs_symlink(const char *name, const char *target_name)
326332 continue ;
327333 }
328334 vfs_node_t new_current = vfs_child_find (current , buf );
335+
329336 if (!new_current ) {
330337 new_current = vfs_node_alloc (current , buf );
331338 new_current -> type = file_dir ;
@@ -355,7 +362,7 @@ int vfs_regist(vfs_callback_t callback)
355362{
356363 if (!callback ) return -1 ;
357364 for (size_t i = 0 ; i < sizeof (struct vfs_callback ) / sizeof (void * ); i ++ ) {
358- if (((void * * )callback )[i ] == NULL ) return -1 ;
365+ if (! ((void * * )callback )[i ]) return -1 ;
359366 }
360367
361368 int id = fs_nextid ++ ;
@@ -366,8 +373,7 @@ int vfs_regist(vfs_callback_t callback)
366373/* Mount a file system to a directory */
367374int vfs_mount (const char * src , vfs_node_t node )
368375{
369- if (!node ) return -1 ;
370- if (node -> type != file_dir ) return -1 ;
376+ if (!node || node -> type != file_dir ) return -1 ;
371377 for (int i = 1 ; i < fs_nextid ; i ++ ) {
372378 if (!fs_callbacks [i ]-> mount (src , node )) {
373379 node -> fsid = i ;
0 commit comments