Skip to contentSkip to conversation

erofs-utils: lib: capture errors from {mkfs,rebuild}_handle_inode()

PATCH Superseded Hongzhen Luo 2 participants 2 messages Nov 11, 2024 – Nov 12, 2024 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: lib: capture errors from {mkfs,rebuild}_handle_inode()

Currently, the error code returned by erofs_{mkfs,rebuild}_handle_inode() in erofs_mkfs_dump_tree() may be ignored. This patch introduces err1 and err2 to capture errors from the {mkfs,rebuild}_handle_inode() functions.

---
 lib/inode.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
lib/inode.c +7 -7
index 7abde7f4a3b5..e2ca07f1c18c 100644
@@ -1733,7 +1733,7 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
 	}
 
 	do {
-		int err;
+		int err1, err2;
 		struct erofs_inode *dir = dumpdir;
 		/* used for adding sub-directories in reverse order due to FIFO */
 		struct erofs_inode *head, **last = &head;
@@ -1753,11 +1753,11 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
 				erofs_mark_parent_inode(inode, dir);
 
 				if (!rebuild)
-					err = erofs_mkfs_handle_inode(inode);
+					err1 = erofs_mkfs_handle_inode(inode);
 				else
-					err = erofs_rebuild_handle_inode(inode,
+					err1 = erofs_rebuild_handle_inode(inode,
 								incremental);
-				if (err)
+				if (err1)
 					break;
 				if (S_ISDIR(inode->i_mode)) {
 					*last = inode;
@@ -1770,10 +1770,10 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
 		}
 		*last = dumpdir;	/* fixup the last (or the only) one */
 		dumpdir = head;
-		err = erofs_mkfs_go(sbi, EROFS_MKFS_JOB_DIR_BH,
+		err2 = erofs_mkfs_go(sbi, EROFS_MKFS_JOB_DIR_BH,
 				    &dir, sizeof(dir));
-		if (err)
-			return err;
+		if (err1 || err2)
+			return err1 ? err1 : err2;
 	} while (dumpdir);
 
 	return err;
Signature · 1 line
2.43.5
#1 lore raw

lib/inode.c static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,

Quoted 14 lines · Hongzhen Luo

Currently, the error code returned by erofs_{mkfs,rebuild}_handle_inode() in erofs_mkfs_dump_tree() may be ignored. This patch introduces err1 and err2 to capture errors from the {mkfs,rebuild}_handle_inode() functions.

---
  lib/inode.c | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)
lib/inode.c +0 -0
index 7abde7f4a3b5..e2ca07f1c18c 100644
@@ -1733,7 +1733,7 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,

add int err, err2 here.

lib/inode.c static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild, · line 1736

Quoted 5 lines
lib/inode.c +1 -1
  	}
 
  	do {
-		int err;
+		int err1, err2;

here the original int err is redundant.

Quoted 6 lines
lib/inode.c +0 -0
  		struct erofs_inode *dir = dumpdir;
  		/* used for adding sub-directories in reverse order due to FIFO */
  		struct erofs_inode *head, **last = &head;
@@ -1753,11 +1753,11 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
  				erofs_mark_parent_inode(inode, dir);
 

lib/inode.c static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild, · line 1761

Quoted 10 lines
lib/inode.c +3 -3
  				if (!rebuild)
-					err = erofs_mkfs_handle_inode(inode);
+					err1 = erofs_mkfs_handle_inode(inode);
  				else
-					err = erofs_rebuild_handle_inode(inode,
+					err1 = erofs_rebuild_handle_inode(inode,
  								incremental);
-				if (err)
+				if (err1)
  					break;

no need to change this.

lib/inode.c static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild, · line 1774

Quoted 9 lines
lib/inode.c +1 -1
  				if (S_ISDIR(inode->i_mode)) {
  					*last = inode;
@@ -1770,10 +1770,10 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
  		}
  		*last = dumpdir;	/* fixup the last (or the only) one */
  		dumpdir = head;
-		err = erofs_mkfs_go(sbi, EROFS_MKFS_JOB_DIR_BH,
+		err2 = erofs_mkfs_go(sbi, EROFS_MKFS_JOB_DIR_BH,
  				    &dir, sizeof(dir));
		err2 = ...

lib/inode.c static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild, · line 1776

Quoted 4 lines
lib/inode.c +2 -2
-		if (err)
-			return err;
+		if (err1 || err2)
+			return err1 ? err1 : err2;
		if (err || err2)
			return err ? err : err2;
Quoted 3 lines
lib/inode.c +0 -0
  	} while (dumpdir);
 
  	return err;