Skip to content

Commit eef5fdf

Browse files
committed
soundhw: extract soundhw help to a separate function
Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9c50b8a commit eef5fdf

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

hw/audio/soundhw.c

+19-14
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ void deprecated_register_soundhw(const char *name, const char *descr,
6464
soundhw_count++;
6565
}
6666

67+
void show_valid_soundhw(void)
68+
{
69+
struct soundhw *c;
70+
71+
if (soundhw_count) {
72+
printf("Valid sound card names (comma separated):\n");
73+
for (c = soundhw; c->name; ++c) {
74+
printf ("%-11s %s\n", c->name, c->descr);
75+
}
76+
} else {
77+
printf("Machine has no user-selectable audio hardware "
78+
"(it may or may not have always-present audio hardware).\n");
79+
}
80+
}
81+
6782
static struct soundhw *selected = NULL;
6883

6984
void select_soundhw(const char *optarg)
@@ -75,19 +90,8 @@ void select_soundhw(const char *optarg)
7590
}
7691

7792
if (is_help_option(optarg)) {
78-
show_valid_cards:
79-
80-
if (soundhw_count) {
81-
printf("Valid sound card names (comma separated):\n");
82-
for (c = soundhw; c->name; ++c) {
83-
printf ("%-11s %s\n", c->name, c->descr);
84-
}
85-
printf("\n-soundhw all will enable all of the above\n");
86-
} else {
87-
printf("Machine has no user-selectable audio hardware "
88-
"(it may or may not have always-present audio hardware).\n");
89-
}
90-
exit(!is_help_option(optarg));
93+
show_valid_soundhw();
94+
exit(0);
9195
}
9296
else {
9397
for (c = soundhw; c->name; ++c) {
@@ -99,7 +103,8 @@ void select_soundhw(const char *optarg)
99103

100104
if (!c->name) {
101105
error_report("Unknown sound card name `%s'", optarg);
102-
goto show_valid_cards;
106+
show_valid_soundhw();
107+
exit(1);
103108
}
104109
}
105110
}

include/hw/audio/soundhw.h

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void deprecated_register_soundhw(const char *name, const char *descr,
77
int isa, const char *typename);
88

99
void soundhw_init(void);
10+
void show_valid_soundhw(void);
1011
void select_soundhw(const char *optarg);
1112

1213
#endif

0 commit comments

Comments
 (0)