From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH 6/6] quotaio: annotate & fix up for sparse endian checker
Date: Thu, 23 Oct 2014 16:29:49 -0500 [thread overview]
Message-ID: <5449734D.4030705@redhat.com> (raw)
In-Reply-To: <54497296.8000708@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
lib/quota/quotaio_tree.c | 10 +++++-----
lib/quota/quotaio_v2.c | 7 ++++---
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/quota/quotaio_tree.c b/lib/quota/quotaio_tree.c
index 4d7a9ab..e7f3e95 100644
--- a/lib/quota/quotaio_tree.c
+++ b/lib/quota/quotaio_tree.c
@@ -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;
diff --git a/lib/quota/quotaio_v2.c b/lib/quota/quotaio_v2.c
index e7bf29c..504b3ea 100644
--- a/lib/quota/quotaio_v2.c
+++ b/lib/quota/quotaio_v2.c
@@ -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))
-- 1.7.1
next prev parent reply other threads:[~2014-10-23 21:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-23 21:26 [PATCH 0/6] RFC: (partially) endian-annotate e2fsprogs Eric Sandeen
2014-10-23 21:27 ` [PATCH 1/6] e2fsprogs: define bitwise types and annotate conversion routines Eric Sandeen
2014-10-23 21:27 ` [PATCH 2/6] e2fsprogs: fix endian handling of ext3_extent_header Eric Sandeen
2014-10-23 22:03 ` Darrick J. Wong
2014-10-23 21:28 ` [PATCH 3/6] e2fsprogs: Endian-annotate most on-disk structures Eric Sandeen
2014-10-23 21:28 ` [PATCH 4/6] debugfs: don't swap htree nodes in-place Eric Sandeen
2014-10-23 21:29 ` [PATCH 5/6] libext2: minor sparse endian checker fixup Eric Sandeen
2014-10-23 21:29 ` Eric Sandeen [this message]
2014-10-23 23:56 ` [PATCH 0/6] RFC: (partially) endian-annotate e2fsprogs Andreas Dilger
2014-11-04 16:34 ` Theodore Ts'o
2014-11-04 23:27 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5449734D.4030705@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.