Add more comment for yaffs_PruneWorker function.
authorcharles <charles>
Wed, 30 Dec 2009 22:30:12 +0000 (22:30 +0000)
committercharles <charles>
Wed, 30 Dec 2009 22:30:12 +0000 (22:30 +0000)
yaffs_guts.c

index d6e4b11..d3539a0 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 const char *yaffs_guts_c_version =
-    "$Id: yaffs_guts.c,v 1.101 2009-12-25 01:53:05 charles Exp $";
+    "$Id: yaffs_guts.c,v 1.102 2009-12-30 22:30:12 charles Exp $";
 
 #include "yportenv.h"
 
@@ -1807,6 +1807,10 @@ static void yaffs_SoftDeleteFile(yaffs_Object *obj)
  * level 0 tnode entries must be zeroed out.
  * Could also use this for file deletion, but that's probably better handled
  * by a special case.
+ *
+ * This function is recursive. For levels > 0 the function is called again on
+ * any sub-tree. For level == 0 we just check if the sub-tree has data.
+ * If there is no data in a subtree then it is pruned.
  */
 
 static yaffs_Tnode *yaffs_PruneWorker(yaffs_Device *dev, yaffs_Tnode *tn,
@@ -1819,25 +1823,25 @@ static yaffs_Tnode *yaffs_PruneWorker(yaffs_Device *dev, yaffs_Tnode *tn,
                hasData = 0;
 
                if(level > 0){
-                       for (i = 0; i < YAFFS_NTNODES_INTERNAL; i++) {
-                               if (tn->internal[i]) {
-                                       tn->internal[i] =
-                                               yaffs_PruneWorker(dev, tn->internal[i],
-                                                       level - 1,
-                                                       (i == 0) ? del0 : 1);
-                               }
-
-                               if (tn->internal[i])
-                                       hasData++;
-                        }
+                       for (i = 0; i < YAFFS_NTNODES_INTERNAL; i++) {
+                               if (tn->internal[i]) {
+                                       tn->internal[i] =
+                                               yaffs_PruneWorker(dev, tn->internal[i],
+                                                       level - 1,
+                                                       (i == 0) ? del0 : 1);
+                               }
+
+                               if (tn->internal[i])
+                                       hasData++;
+                       }
                } else {
-                       int tnodeSize;
-                       __u32 *map = (__u32 *)tn;
-                       tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
+                       int tnodeSize;
+                       __u32 *map = (__u32 *)tn;
+                       tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
 
-                       if (tnodeSize < sizeof(yaffs_Tnode))
-                               tnodeSize = sizeof(yaffs_Tnode);
-                        tnodeSize /= sizeof(__u32);
+                       if (tnodeSize < sizeof(yaffs_Tnode))
+                               tnodeSize = sizeof(yaffs_Tnode);
+                       tnodeSize /= sizeof(__u32);
 
                         for(i = 0; !hasData && i < tnodeSize; i++){
                                 if(map[i])