OSDN Git Service

e2fsprogs: Remove impossible name_len tests.
authorEric Sandeen <sandeen@redhat.com>
Fri, 16 Sep 2011 20:49:17 +0000 (15:49 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 16 Sep 2011 22:43:04 +0000 (18:43 -0400)
The name_len field in ext2_dir_entry is actually comprised of
the name length in the lower 8 bytes, and the filetype in the
high 8 bytes.  So in places, we mask name_len with 0xFF to
get the actual length.

But once we have masked name_len with 0xFF, there is no point
in testing whether it is greater than EXT2_NAME_LEN, which
is 255 - or 0xFF.  So all of these tests are extraneous.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/dump.c
debugfs/htree.c
debugfs/ls.c
e2fsck/message.c
e2fsck/pass2.c

index 4cf0752..ec36eca 100644 (file)
@@ -300,8 +300,7 @@ static int rdump_dirent(struct ext2_dir_entry *dirent,
        const char *dumproot = private;
        struct ext2_inode inode;
 
-       thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN
-                  ? (dirent->name_len & 0xFF) : EXT2_NAME_LEN);
+       thislen = dirent->name_len & 0xFF;
        strncpy(name, dirent->name, thislen);
        name[thislen] = 0;
 
index b829e25..de36bd4 100644 (file)
@@ -81,8 +81,7 @@ static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino,
                                blk);
                        break;
                }
-               thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN) ?
-                       (dirent->name_len & 0xFF) : EXT2_NAME_LEN;
+               thislen = dirent->name_len & 0xFF;
                strncpy(name, dirent->name, thislen);
                name[thislen] = '\0';
                errcode = ext2fs_dirhash(hash_alg, name,
index 8e019d2..e01fd20 100644 (file)
@@ -60,8 +60,7 @@ static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
        int                     thislen;
        struct list_dir_struct *ls = (struct list_dir_struct *) private;
 
-       thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN) ?
-               (dirent->name_len & 0xFF) : EXT2_NAME_LEN;
+       thislen = dirent->name_len & 0xFF;
        strncpy(name, dirent->name, thislen);
        name[thislen] = '\0';
        ino = dirent->inode;
index 49b861d..565c3cd 100644 (file)
@@ -372,8 +372,6 @@ static _INLINE_ void expand_dirent_expression(ext2_filsys fs, char ch,
                break;
        case 'n':
                len = dirent->name_len & 0xFF;
-               if (len > EXT2_NAME_LEN)
-                       len = EXT2_NAME_LEN;
                if ((ext2fs_get_rec_len(fs, dirent, &rec_len) == 0) &&
                    (len > rec_len))
                        len = rec_len;
index e57afb9..9c44aa2 100644 (file)
@@ -858,12 +858,6 @@ out_htree:
                        } else
                                goto abort_free_dict;
                }
-               if ((dirent->name_len & 0xFF) > EXT2_NAME_LEN) {
-                       if (fix_problem(ctx, PR_2_FILENAME_LONG, &cd->pctx)) {
-                               dirent->name_len = EXT2_NAME_LEN;
-                               dir_modified++;
-                       }
-               }
 
                if (dot_state == 0) {
                        if (check_dot(ctx, dirent, ino, &cd->pctx))