xiaoxiang781216 commented on a change in pull request #5854:
URL: https://github.com/apache/incubator-nuttx/pull/5854#discussion_r835931746



##########
File path: fs/romfs/fs_romfsutil.c
##########
@@ -436,51 +429,44 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm,
           return ret;
         }
 
-      /* Now we are pointing to the real entry of interest. Is it a
-       * directory? Or a file?
-       */
+      ret = romfs_parsefilename(rm, offset, childname);
+      if (ret < 0)
+        {
+          return ret;
+        }
 
-      if (IS_DIRECTORY(next) || IS_FILE(next))
+      if (strcmp(childname, ".") != 0 && strcmp(childname, "..") != 0)
         {
-          ret = romfs_parsefilename(rm, offset, childname);
-          if (ret < 0)
+          if (child == NULL || nodeinfo->rn_count == num - 1)
             {
-              return ret;
-            }
+              FAR void *tmp;
 
-          if (strcmp(childname, ".") != 0 && strcmp(childname, "..") != 0)
-            {
-              if (child == NULL || nodeinfo->rn_count == num - 1)
+              tmp = kmm_realloc(nodeinfo->rn_child,
+                                (num + NODEINFO_NINCR) *
+                                sizeof(FAR struct romfs_nodeinfo_s *));
+              if (tmp == NULL)
                 {
-                  FAR void *tmp;
-
-                  tmp = kmm_realloc(nodeinfo->rn_child,
-                                    (num + NODEINFO_NINCR) *
-                                    sizeof(FAR struct romfs_nodeinfo_s *));
-                  if (tmp == NULL)
-                    {
-                      return -ENOMEM;
-                    }
-
-                  nodeinfo->rn_child = tmp;
-                  memset(nodeinfo->rn_child + num, 0, NODEINFO_NINCR *
-                         sizeof(FAR struct romfs_nodeinfo_s *));
-                  num += NODEINFO_NINCR;
+                  return -ENOMEM;
                 }
 
-              child = &nodeinfo->rn_child[nodeinfo->rn_count++];
-              if (IS_DIRECTORY(next))
-                {
-                  linkoffset = info;
-                }
+              nodeinfo->rn_child = tmp;
+              memset(nodeinfo->rn_child + num, 0, NODEINFO_NINCR *
+                     sizeof(FAR struct romfs_nodeinfo_s *));

Review comment:
       @pkarashchenko but FAR is required here, otherwise the sizeof may return 
value smaller than expected.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to