]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: restructure code to reduce indentation level in check_dir_block()
authorTheodore Ts'o <tytso@mit.edu>
Fri, 17 Mar 2023 03:17:24 +0000 (23:17 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 17 Mar 2023 03:42:40 +0000 (23:42 -0400)
No functional changes; just move things around so we can avoid
indenting the code quite so much.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass2.c

index 2700e3409d1d4e1d1dbdb268183f9ab0d75137e6..47f9206fbcfd868b47b6c481e304dce79c16fcf0 100644 (file)
@@ -1353,56 +1353,56 @@ skip_checksum:
                                }
                        }
                        if (problem) {
-                               if (fix_problem(ctx, PR_2_DIR_CORRUPTED,
-                                               &cd->pctx)) {
 #ifdef WORDS_BIGENDIAN
-                                       /*
-                                        * On big-endian systems, if the dirent
-                                        * swap routine finds a rec_len that it
-                                        * doesn't like, it continues
-                                        * processing the block as if rec_len
-                                        * == EXT2_DIR_ENTRY_HEADER_LEN.  This means that the name
-                                        * field gets byte swapped, which means
-                                        * that salvage will not detect the
-                                        * correct name length (unless the name
-                                        * has a length that's an exact
-                                        * multiple of four bytes), and it'll
-                                        * discard the entry (unnecessarily)
-                                        * and the rest of the dirent block.
-                                        * Therefore, swap the rest of the
-                                        * block back to disk order, run
-                                        * salvage, and re-swap anything after
-                                        * the salvaged dirent.
-                                        */
-                                       int need_reswab = 0;
-                                       if (rec_len < EXT2_DIR_ENTRY_HEADER_LEN || rec_len % 4) {
-                                               need_reswab = 1;
-                                               ext2fs_dirent_swab_in2(fs,
-                                                       ((char *)dirent) + EXT2_DIR_ENTRY_HEADER_LEN,
-                                                       max_block_size - offset - EXT2_DIR_ENTRY_HEADER_LEN,
-                                                       0);
-                                       }
+                               int need_reswab = 0;
 #endif
-                                       salvage_directory(fs, dirent, prev,
-                                                         &offset,
-                                                         max_block_size,
-                                                         hash_in_dirent);
+
+                               if (!fix_problem(ctx, PR_2_DIR_CORRUPTED,
+                                               &cd->pctx))
+                                       goto abort_free_dict;
 #ifdef WORDS_BIGENDIAN
-                                       if (need_reswab) {
-                                               unsigned int len;
-
-                                               (void) ext2fs_get_rec_len(fs,
-                                                       dirent, &len);
-                                               len += offset;
-                                               if (max_block_size > len)
-                                                       ext2fs_dirent_swab_in2(fs,
-                               ((char *)dirent) + len, max_block_size - len, 0);
-                                       }
+                               /*
+                                * On big-endian systems, if the dirent
+                                * swap routine finds a rec_len that it
+                                * doesn't like, it continues processing
+                                * the block as if rec_len ==
+                                * EXT2_DIR_ENTRY_HEADER_LEN.  This means
+                                * that the name field gets byte swapped,
+                                * which means that salvage will not detect
+                                * the correct name length (unless the name
+                                * has a length that's an exact multiple of
+                                * four bytes), and it'll discard the entry
+                                * (unnecessarily) and the rest of the
+                                * dirent block.  Therefore, swap the rest
+                                * of the block back to disk order, run
+                                * salvage, and re-swap anything after the
+                                * salvaged dirent.
+                                */
+                               if (rec_len < EXT2_DIR_ENTRY_HEADER_LEN ||
+                                   rec_len % 4) {
+                                       need_reswab = 1;
+                                       ext2fs_dirent_swab_in2(fs,
+                       ((char *)dirent) + EXT2_DIR_ENTRY_HEADER_LEN,
+                       max_block_size - offset - EXT2_DIR_ENTRY_HEADER_LEN, 0);
+                               }
 #endif
-                                       dir_modified++;
-                                       continue;
-                               } else
-                                       goto abort_free_dict;
+                               salvage_directory(fs, dirent, prev, &offset,
+                                                 max_block_size,
+                                                 hash_in_dirent);
+#ifdef WORDS_BIGENDIAN
+                               if (need_reswab) {
+                                       unsigned int len;
+
+                                       (void) ext2fs_get_rec_len(fs, dirent,
+                                                                 &len);
+                                       len += offset;
+                                       if (max_block_size > len)
+                                               ext2fs_dirent_swab_in2(fs,
+                       ((char *)dirent) + len, max_block_size - len, 0);
+                               }
+#endif
+                               dir_modified++;
+                               continue;
                        }
                } else {
                        if (dot_state == 0) {