From: Anand jain <Anand.Jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: Ilya Dryomov <idryomov@gmail.com>
Subject: [PATCH 3/9] Btrfs-progs: refactor resolve_root() function a bit
Date: Fri, 3 Aug 2012 17:48:52 +0800 [thread overview]
Message-ID: <1343987338-10612-5-git-send-email-Anand.Jain@oracle.com> (raw)
In-Reply-To: <1343987338-10612-1-git-send-email-Anand.Jain@oracle.com>
From: Ilya Dryomov <idryomov@gmail.com>
Don't pass a pointer to root_id to resolve_root(). It's always the same as
ri->root_id, passing a pointer hints that root_id can somehow change which is
not true.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
btrfs-list.c | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/btrfs-list.c b/btrfs-list.c
index 680dd03..5c21cac 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -202,7 +202,7 @@ static int add_root(struct root_lookup *root_lookup,
* in by lookup_ino_path
*/
static int resolve_root(struct root_lookup *rl, struct root_info *ri,
- u64 *root_id, u64 *parent_id, u64 *top_id, char **path)
+ u64 *parent_id, u64 *top_id, char **path)
{
char *full_path = NULL;
int len = 0;
@@ -256,7 +256,6 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri,
}
}
- *root_id = ri->root_id;
*path = full_path;
return 0;
@@ -700,23 +699,23 @@ int list_subvols(int fd, int print_parent)
n = rb_last(&root_lookup.root);
while (n) {
struct root_info *entry;
- u64 root_id;
u64 level;
u64 parent_id;
char *path;
+
entry = rb_entry(n, struct root_info, rb_node);
- resolve_root(&root_lookup, entry, &root_id, &parent_id,
- &level, &path);
+ resolve_root(&root_lookup, entry, &parent_id, &level, &path);
if (print_parent) {
printf("ID %llu parent %llu top level %llu path %s\n",
- (unsigned long long)root_id,
+ (unsigned long long)entry->root_id,
(unsigned long long)parent_id,
(unsigned long long)level, path);
} else {
printf("ID %llu top level %llu path %s\n",
- (unsigned long long)root_id,
+ (unsigned long long)entry->root_id,
(unsigned long long)level, path);
}
+
free(path);
n = rb_prev(n);
}
@@ -922,17 +921,17 @@ char *path_for_root(int fd, u64 root)
n = rb_last(&root_lookup.root);
while (n) {
struct root_info *entry;
- u64 root_id;
u64 parent_id;
u64 level;
char *path;
+
entry = rb_entry(n, struct root_info, rb_node);
- resolve_root(&root_lookup, entry, &root_id, &parent_id, &level,
- &path);
- if (root_id == root)
+ resolve_root(&root_lookup, entry, &parent_id, &level, &path);
+ if (entry->root_id == root)
ret_path = path;
else
free(path);
+
n = rb_prev(n);
}
--
1.7.1
next prev parent reply other threads:[~2012-08-03 9:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-01 12:01 [PATCH] add crtime to the snapshot list Anand jain
2012-08-01 12:01 ` [PATCH] Btrfs-progs: show crtime in " Anand jain
2012-08-01 12:14 ` [PATCH] add crtime to " Alexander Block
2012-08-01 15:56 ` anand jain
2012-08-01 12:43 ` Liu Bo
2012-08-03 9:48 ` [PATCH 0/9 V2] Include otime in " Anand jain
2012-08-03 9:48 ` [PATCH] Btrfs: introduce subvol uuids and times Anand jain
2012-08-03 9:48 ` [PATCH 1/9] Update ctree.h and ioctl.h for the new uuid+times for subvolumes Anand jain
2012-08-03 9:48 ` [PATCH 2/9] Btrfs-progs: search subvolumes with proper objectid Anand jain
2012-08-03 9:48 ` Anand jain [this message]
2012-08-03 9:48 ` [PATCH 4/9] Btrfs-progs: nuke redundant zeroing in __list_subvol_search() Anand jain
2012-08-03 9:48 ` [PATCH 5/9] Btrfs-progs: bring 'subvol get-default' back in Anand jain
2012-08-03 9:48 ` [PATCH 6/9] Btrfs-progs: show generation in command btrfs subvol list Anand jain
2012-08-03 9:48 ` [PATCH 7/9] Btrfs-progs: list snapshots by generation Anand jain
2012-08-03 9:48 ` [PATCH 8/9] Btrfs-progs: add otime to the snapshot list Anand jain
2012-08-03 9:48 ` [PATCH 9/9] Btrfs-progs: fix the btrfs subvol list path last char Anand jain
2012-08-14 6:04 ` [PATCH] get uuid of subvol and snapshot Anand jain
2012-08-14 6:04 ` [PATCH] add -u to show subvol uuid Anand jain
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=1343987338-10612-5-git-send-email-Anand.Jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=idryomov@gmail.com \
--cc=linux-btrfs@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).