From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH 4/6] debugfs: don't swap htree nodes in-place
Date: Thu, 23 Oct 2014 16:28:44 -0500 [thread overview]
Message-ID: <5449730C.90907@redhat.com> (raw)
In-Reply-To: <54497296.8000708@redhat.com>
htree_dump_int_node() was swapping htree nodes in-place,
something not done elsewhere, so it made the sparse checker
unhappy. Just use dedicated variables to hold the 2 needed
(endian-swapped) values.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
debugfs/htree.c | 35 ++++++++++++++++++-----------------
1 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/debugfs/htree.c b/debugfs/htree.c
index 4f0118d..866d1c6 100644
--- a/debugfs/htree.c
+++ b/debugfs/htree.c
@@ -138,21 +138,20 @@ static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino,
struct ext2_dx_entry *ent,
char *buf, int level)
{
- struct ext2_dx_countlimit limit;
- struct ext2_dx_entry e;
+ struct ext2_dx_countlimit dx_countlimit;
struct ext2_dx_tail *tail;
int hash, i;
+ int limit, count;
int remainder;
- limit = *((struct ext2_dx_countlimit *) ent);
- limit.count = ext2fs_le16_to_cpu(limit.count);
- limit.limit = ext2fs_le16_to_cpu(limit.limit);
+ dx_countlimit = *((struct ext2_dx_countlimit *) ent);
+ count = ext2fs_le16_to_cpu(dx_countlimit.count);
+ limit = ext2fs_le16_to_cpu(dx_countlimit.limit);
- fprintf(pager, "Number of entries (count): %d\n", limit.count);
- fprintf(pager, "Number of entries (limit): %d\n", limit.limit);
+ fprintf(pager, "Number of entries (count): %d\n", count);
+ fprintf(pager, "Number of entries (limit): %d\n", limit);
- remainder = fs->blocksize - (limit.limit *
- sizeof(struct ext2_dx_entry));
+ remainder = fs->blocksize - (limit * sizeof(struct ext2_dx_entry));
if (ent == (struct ext2_dx_entry *)(rootnode + 1))
remainder -= sizeof(struct ext2_dx_root_info) + 24;
else
@@ -160,12 +159,12 @@ static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino,
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
remainder == sizeof(struct ext2_dx_tail)) {
- tail = (struct ext2_dx_tail *)(ent + limit.limit);
+ tail = (struct ext2_dx_tail *)(ent + limit);
fprintf(pager, "Checksum: 0x%08x\n",
ext2fs_le32_to_cpu(tail->dt_checksum));
}
- for (i=0; i < limit.count; i++) {
+ for (i=0; i < count; i++) {
hash = i ? ext2fs_le32_to_cpu(ent[i].hash) : 0;
fprintf(pager, "Entry #%d: Hash 0x%08x%s, block %u\n", i,
hash, (hash & 1) ? " (**)" : "",
@@ -174,17 +173,19 @@ static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino,
fprintf(pager, "\n");
- for (i=0; i < limit.count; i++) {
- e.hash = ext2fs_le32_to_cpu(ent[i].hash);
- e.block = ext2fs_le32_to_cpu(ent[i].block);
+ for (i=0; i < count; i++) {
+ int hash, block;
+
+ hash = ext2fs_le32_to_cpu(ent[i].hash);
+ block = ext2fs_le32_to_cpu(ent[i].block);
fprintf(pager, "Entry #%d: Hash 0x%08x, block %u\n", i,
- i ? e.hash : 0, e.block);
+ i ? hash : 0, block);
if (level)
htree_dump_int_block(fs, ino, inode, rootnode,
- e.block, buf, level-1);
+ block, buf, level-1);
else
htree_dump_leaf_node(fs, ino, inode, rootnode,
- e.block, buf);
+ block, buf);
}
fprintf(pager, "---------------------\n");
-- 1.7.1
next prev parent reply other threads:[~2014-10-23 21:28 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 ` Eric Sandeen [this message]
2014-10-23 21:29 ` [PATCH 5/6] libext2: minor sparse endian checker fixup Eric Sandeen
2014-10-23 21:29 ` [PATCH 6/6] quotaio: annotate & fix up for sparse endian checker Eric Sandeen
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=5449730C.90907@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).