Skip to content

Commit 9b175cd

Browse files
committed
nvme-print-stdout: refactor subsys config
DRY the subsys config output. Refactor into a helper. Signed-off-by: Daniel Wagner <dwagner@suse.de>
1 parent 4ac020d commit 9b175cd

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

nvme-print-stdout.c

+14-16
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,18 @@ static void stdout_subsystem_ctrls(nvme_subsystem_t s)
10461046
}
10471047
}
10481048

1049+
static void stdout_subsys_config(nvme_subsystem_t s)
1050+
{
1051+
int len = strlen(nvme_subsystem_get_name(s));
1052+
1053+
printf("%s - NQN=%s\n", nvme_subsystem_get_name(s),
1054+
nvme_subsystem_get_nqn(s));
1055+
printf("%*s hostnqn=%s\n", len, " ",
1056+
nvme_host_get_hostnqn(nvme_subsystem_get_host(s)));
1057+
printf("%*s iopolicy=%s\n", len, " ",
1058+
nvme_subsystem_get_iopolicy(s));
1059+
}
1060+
10491061
static void stdout_subsystem(nvme_root_t r, bool show_ana)
10501062
{
10511063
nvme_host_t h;
@@ -1055,18 +1067,11 @@ static void stdout_subsystem(nvme_root_t r, bool show_ana)
10551067
nvme_subsystem_t s;
10561068

10571069
nvme_for_each_subsystem(h, s) {
1058-
int len = strlen(nvme_subsystem_get_name(s));
1059-
10601070
if (!first)
10611071
printf("\n");
10621072
first = false;
10631073

1064-
printf("%s - NQN=%s\n", nvme_subsystem_get_name(s),
1065-
nvme_subsystem_get_nqn(s));
1066-
printf("%*s hostnqn=%s\n", len, " ",
1067-
nvme_host_get_hostnqn(nvme_subsystem_get_host(s)));
1068-
printf("%*s iopolicy=%s\n", len, " ",
1069-
nvme_subsystem_get_iopolicy(s));
1074+
stdout_subsys_config(s);
10701075
printf("\\\n");
10711076

10721077
if (!show_ana || !stdout_subsystem_multipath(s))
@@ -5041,18 +5046,11 @@ static void stdout_simple_topology(nvme_root_t r,
50415046

50425047
nvme_for_each_host(r, h) {
50435048
nvme_for_each_subsystem(h, s) {
5044-
int len = strlen(nvme_subsystem_get_name(s));
5045-
50465049
if (!first)
50475050
printf("\n");
50485051
first = false;
50495052

5050-
printf("%s - NQN=%s\n", nvme_subsystem_get_name(s),
5051-
nvme_subsystem_get_nqn(s));
5052-
printf("%*s hostnqn=%s\n", len, " ",
5053-
nvme_host_get_hostnqn(nvme_subsystem_get_host(s)));
5054-
printf("%*s iopolicy=%s\n", len, " ",
5055-
nvme_subsystem_get_iopolicy(s));
5053+
stdout_subsys_config(s);
50565054
printf("\\\n");
50575055

50585056
if (nvme_is_multipath(s))

0 commit comments

Comments
 (0)