Skip to content

Commit 271696c

Browse files
committed
btrfs-progs: convert device info to struct array
The device infos are passed as two parameters, use struct array for that. Signed-off-by: David Sterba <[email protected]>
1 parent 26fcce7 commit 271696c

File tree

3 files changed

+89
-103
lines changed

3 files changed

+89
-103
lines changed

cmds/device.c

+10-9
Original file line numberDiff line numberDiff line change
@@ -835,25 +835,26 @@ static const char * const cmd_device_usage_usage[] = {
835835

836836
static int _cmd_device_usage(int fd, const char *path, unsigned unit_mode)
837837
{
838-
int i;
839838
int ret = 0;
840839
struct array chunkinfos = { 0 };
841-
struct device_info *devinfo = NULL;
842-
int devcount = 0;
840+
struct array devinfos = { 0 };
843841

844-
ret = load_chunk_and_device_info(fd, &chunkinfos, &devinfo, &devcount);
842+
ret = load_chunk_and_device_info(fd, &chunkinfos, &devinfos);
845843
if (ret)
846844
goto out;
847845

848-
for (i = 0; i < devcount; i++) {
849-
pr_verbose(LOG_DEFAULT, "%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
850-
print_device_sizes(&devinfo[i], unit_mode);
851-
print_device_chunks(&devinfo[i], &chunkinfos, unit_mode);
846+
for (int i = 0; i < devinfos.length; i++) {
847+
const struct device_info *devinfo = devinfos.data[i];
848+
849+
pr_verbose(LOG_DEFAULT, "%s, ID: %llu\n", devinfo->path, devinfo->devid);
850+
print_device_sizes(devinfo, unit_mode);
851+
print_device_chunks(devinfo, &chunkinfos, unit_mode);
852852
pr_verbose(LOG_DEFAULT, "\n");
853853
}
854854

855855
out:
856-
free(devinfo);
856+
array_free_elements(&devinfos);
857+
array_free(&devinfos);
857858
array_free_elements(&chunkinfos);
858859
array_free(&chunkinfos);
859860

0 commit comments

Comments
 (0)