Преглед изворни кода

Merge pull request #18 from xqyjlj/fix-stat-wrong-return-dev

🐞 fix(ports/rtthread/dfs_ext.c): fix wrong return
Bernard Xiong пре 2 година
родитељ
комит
dcfe9c7001
1 измењених фајлова са 8 додато и 5 уклоњено
  1. 8 5
      ports/rtthread/dfs_ext.c

+ 8 - 5
ports/rtthread/dfs_ext.c

@@ -480,13 +480,16 @@ static int dfs_ext_stat(struct dfs_filesystem *fs, const char *path, struct stat
         }
     }
 
-    struct ext4_mount_stats s;
-    r = ext4_mount_point_stats(stat_path, &s);
     if (r == 0)
     {
-        st->st_blksize = s.block_size;
-        // man say st_blocks is number of 512B blocks allocated
-        st->st_blocks = RT_ALIGN(st->st_size, st->st_blksize) / 512;
+        struct ext4_mount_stats s;
+        r = ext4_mount_point_stats(stat_path, &s);
+        if (r == 0)
+        {
+            st->st_blksize = s.block_size;
+            // man say st_blocks is number of 512B blocks allocated
+            st->st_blocks = RT_ALIGN(st->st_size, st->st_blksize) / 512;
+        }
     }
 
     return -r;