From ffa899f296dcf4916f5a27918b56ded544c35c7d Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 2 Nov 2015 18:54:48 +0100 Subject: btrfs-progs: fi usage: cleanup, replace header constant The size of the header is not obvious, let's make it more visible by replacing it with a varaible. Signed-off-by: David Sterba --- cmds-fi-usage.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'cmds-fi-usage.c') diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c index 2eb5739e..21d1b6cd 100644 --- a/cmds-fi-usage.c +++ b/cmds-fi-usage.c @@ -624,6 +624,7 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode, int ncols, nrows; int col; int unallocated_col; + const int vhdr_skip = 3; /* amount of vertical header space */ /* path, unallocated */ ncols = 2; @@ -635,7 +636,7 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode, } /* 2 for header, empty line, devices, ===, total, used */ - nrows = 2 + 1 + device_info_count + 1 + 2; + nrows = vhdr_skip + device_info_count + 1 + 2; matrix = table_create(ncols, nrows); if (!matrix) { @@ -679,7 +680,8 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode, else p++; - table_printf(matrix, 0, i + 3, "<%s", device_info_ptr[i].path); + table_printf(matrix, 0, vhdr_skip + i, "<%s", + device_info_ptr[i].path); for (col = 1, k = 0 ; k < sargs->total_spaces ; k++) { u64 flags = sargs->spaces[k].flags; @@ -700,10 +702,10 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode, } if (size) - table_printf(matrix, col, i+3, + table_printf(matrix, col, vhdr_skip+ i, ">%s", pretty_size_mode(size, unit_mode)); else - table_printf(matrix, col, i+3, ">-"); + table_printf(matrix, col, vhdr_skip + i, ">-"); total_allocated += size; col++; @@ -712,7 +714,7 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode, unused = get_partition_size(device_info_ptr[i].path) - total_allocated; - table_printf(matrix, unallocated_col, i + 3, + table_printf(matrix, unallocated_col, vhdr_skip + i, ">%s", pretty_size_mode(unused, unit_mode)); total_unused += unused; @@ -722,30 +724,32 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode, if (sargs->spaces[i].flags & BTRFS_SPACE_INFO_GLOBAL_RSV) continue; - table_printf(matrix, col++, device_info_count + 3, "="); + table_printf(matrix, col++, vhdr_skip + device_info_count, "="); } /* One for Unallocated */ - table_printf(matrix, col, device_info_count + 3, "="); + table_printf(matrix, col, vhdr_skip + device_info_count, "="); /* footer */ - table_printf(matrix, 0, device_info_count + 4, "total_spaces; i++) { if (sargs->spaces[i].flags & BTRFS_SPACE_INFO_GLOBAL_RSV) continue; - table_printf(matrix, col++, device_info_count + 4, ">%s", + table_printf(matrix, col++, vhdr_skip + device_info_count + 1, + ">%s", pretty_size_mode(sargs->spaces[i].total_bytes, unit_mode)); } - table_printf(matrix, unallocated_col, device_info_count + 4, + table_printf(matrix, unallocated_col, vhdr_skip + device_info_count + 1, ">%s", pretty_size_mode(total_unused, unit_mode)); - table_printf(matrix, 0, device_info_count + 5, "total_spaces; i++) { if (sargs->spaces[i].flags & BTRFS_SPACE_INFO_GLOBAL_RSV) continue; - table_printf(matrix, col++, device_info_count+5, ">%s", + table_printf(matrix, col++, vhdr_skip + device_info_count + 2, + ">%s", pretty_size_mode(sargs->spaces[i].used_bytes, unit_mode)); } -- cgit v1.2.3