btrfs-progs: calc-size: use on-stack buffer for a helper structure
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
ebe04a2351
commit
b023281d3b
|
@ -436,9 +436,8 @@ static void usage(void)
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct btrfs_key key;
|
struct btrfs_key key;
|
||||||
struct fs_root *roots;
|
struct fs_root roots;
|
||||||
struct btrfs_root *root;
|
struct btrfs_root *root;
|
||||||
size_t fs_roots_size = sizeof(struct fs_root);
|
|
||||||
int opt;
|
int opt;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -482,12 +481,6 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
roots = malloc(fs_roots_size);
|
|
||||||
if (!roots) {
|
|
||||||
fprintf(stderr, "No memory\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Calculating size of root tree\n");
|
printf("Calculating size of root tree\n");
|
||||||
key.objectid = BTRFS_ROOT_TREE_OBJECTID;
|
key.objectid = BTRFS_ROOT_TREE_OBJECTID;
|
||||||
ret = calc_root_size(root, &key, 0);
|
ret = calc_root_size(root, &key, 0);
|
||||||
|
@ -506,15 +499,14 @@ int main(int argc, char **argv)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
roots[0].key.objectid = BTRFS_FS_TREE_OBJECTID;
|
roots.key.objectid = BTRFS_FS_TREE_OBJECTID;
|
||||||
roots[0].key.offset = (u64)-1;
|
roots.key.offset = (u64)-1;
|
||||||
printf("Calculatin' size of fs tree\n");
|
printf("Calculatin' size of fs tree\n");
|
||||||
ret = calc_root_size(root, &roots[0].key, 1);
|
ret = calc_root_size(root, &roots.key, 1);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
out:
|
out:
|
||||||
close_ctree(root);
|
close_ctree(root);
|
||||||
free(roots);
|
|
||||||
btrfs_close_all_devices();
|
btrfs_close_all_devices();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue