Skip to content

Commit 26fcce7

Browse files
committed
btrfs-progs: convert chunk info to struct array
Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 167dba6 commit 26fcce7

File tree

3 files changed

+96
-107
lines changed

3 files changed

+96
-107
lines changed

cmds/device.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -837,27 +837,25 @@ static int _cmd_device_usage(int fd, const char *path, unsigned unit_mode)
837837
{
838838
int i;
839839
int ret = 0;
840-
struct chunk_info *chunkinfo = NULL;
840+
struct array chunkinfos = { 0 };
841841
struct device_info *devinfo = NULL;
842-
int chunkcount = 0;
843842
int devcount = 0;
844843

845-
ret = load_chunk_and_device_info(fd, &chunkinfo, &chunkcount, &devinfo,
846-
&devcount);
844+
ret = load_chunk_and_device_info(fd, &chunkinfos, &devinfo, &devcount);
847845
if (ret)
848846
goto out;
849847

850848
for (i = 0; i < devcount; i++) {
851849
pr_verbose(LOG_DEFAULT, "%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
852850
print_device_sizes(&devinfo[i], unit_mode);
853-
print_device_chunks(&devinfo[i], chunkinfo, chunkcount,
854-
unit_mode);
851+
print_device_chunks(&devinfo[i], &chunkinfos, unit_mode);
855852
pr_verbose(LOG_DEFAULT, "\n");
856853
}
857854

858855
out:
859856
free(devinfo);
860-
free(chunkinfo);
857+
array_free_elements(&chunkinfos);
858+
array_free(&chunkinfos);
861859

862860
return ret;
863861
}

0 commit comments

Comments
 (0)