Whamcloud - gitweb
quotaio: annotate & fix up for sparse endian checker
authorEric Sandeen <sandeen@redhat.com>
Tue, 4 Nov 2014 16:26:24 +0000 (11:26 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 4 Nov 2014 16:26:24 +0000 (11:26 -0500)
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/quota/quotaio_tree.c
lib/quota/quotaio_v2.c

index 4d7a9ab..e7f3e95 100644 (file)
@@ -254,7 +254,7 @@ static int do_insert_tree(struct quota_handle *h, struct dquot *dquot,
 {
        dqbuf_t buf;
        int newson = 0, newact = 0;
-       __u32 *ref;
+       __le32 *ref;
        unsigned int newblk;
        int ret = 0;
 
@@ -274,7 +274,7 @@ static int do_insert_tree(struct quota_handle *h, struct dquot *dquot,
                read_blk(h, *treeblk, buf);
        }
 
-       ref = (__u32 *) buf;
+       ref = (__le32 *) buf;
        newblk = ext2fs_le32_to_cpu(ref[get_index(dquot->dq_id, depth)]);
        if (!newblk)
                newson = 1;
@@ -397,7 +397,7 @@ static void remove_tree(struct quota_handle *h, struct dquot *dquot,
 {
        dqbuf_t buf = getdqbuf();
        unsigned int newblk;
-       __u32 *ref = (__u32 *) buf;
+       __le32 *ref = (__le32 *) buf;
 
        if (!buf)
                return;
@@ -473,7 +473,7 @@ static ext2_loff_t find_tree_dqentry(struct quota_handle *h,
 {
        dqbuf_t buf = getdqbuf();
        ext2_loff_t ret = 0;
-       __u32 *ref = (__u32 *) buf;
+       __le32 *ref = (__le32 *) buf;
 
        if (!buf)
                return -ENOMEM;
@@ -597,7 +597,7 @@ static int report_tree(struct dquot *dquot, unsigned int blk, int depth,
 {
        int entries = 0, i;
        dqbuf_t buf = getdqbuf();
-       __u32 *ref = (__u32 *) buf;
+       __le32 *ref = (__le32 *) buf;
 
        if (!buf)
                return 0;
index e7bf29c..504b3ea 100644 (file)
@@ -151,6 +151,7 @@ static int v2_check_file(struct quota_handle *h, int type, int fmt)
 {
        struct v2_disk_dqheader dqh;
        int file_magics[] = INITQMAGICS;
+       int be_magic;
 
        if (fmt != QFMT_VFS_V1)
                return 0;
@@ -158,9 +159,9 @@ static int v2_check_file(struct quota_handle *h, int type, int fmt)
        if (!v2_read_header(h, &dqh))
                return 0;
 
-       if (ext2fs_le32_to_cpu(dqh.dqh_magic) != file_magics[type]) {
-               if (ext2fs_be32_to_cpu(dqh.dqh_magic) == file_magics[type])
-                       log_err("Your quota file is stored in wrong endianity");
+       be_magic = ext2fs_be32_to_cpu((__force __be32)dqh.dqh_magic);
+       if (be_magic == file_magics[type]) {
+               log_err("Your quota file is stored in wrong endianity");
                return 0;
        }
        if (V2_VERSION != ext2fs_le32_to_cpu(dqh.dqh_version))