[U-Boot] [PATCH v2 5/5] ext4: optimize direntlen loops

Michael Walle michael at walle.cc
Tue Aug 23 10:27:42 CEST 2016


direntlen is always >= 8. Therefore, the loop condition is always true.

Signed-off-by: Michael Walle <michael at walle.cc>
Suggested-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
---
 fs/ext4/ext4_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 4a003cf..9430a3b 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -420,7 +420,7 @@ restart:
 		goto fail;
 	dir = (struct ext2_dirent *)root_first_block_buffer;
 	totalbytes = 0;
-	while (le16_to_cpu(dir->direntlen) > 0) {
+	while (true) {
 		/*
 		 * blocksize-totalbytes because last directory length
 		 * i.e. dir->direntlen is free availble space in the
@@ -560,7 +560,7 @@ static int search_dir(struct ext2_inode *parent_inode, char *dirname)
 		dir = (struct ext2_dirent *)block_buffer;
 		ptr = (char *)dir;
 		totalbytes = 0;
-		while (le16_to_cpu(dir->direntlen) >= 0) {
+		while (true) {
 			/*
 			 * blocksize-totalbytes because last directory
 			 * length i.e.,*dir->direntlen is free availble
@@ -806,7 +806,7 @@ static int check_filename(char *filename, unsigned int blknr)
 	dir = (struct ext2_dirent *)root_first_block_buffer;
 	ptr = (char *)dir;
 	totalbytes = 0;
-	while (le16_to_cpu(dir->direntlen) >= 0) {
+	while (true) {
 		/*
 		 * blocksize-totalbytes because last
 		 * directory length i.e., *dir->direntlen
-- 
2.1.4



More information about the U-Boot mailing list