virtual_oss: Combine -d, -l and -L option getopt code

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D55671
This commit is contained in:
Christos Margiolis
2026-03-10 11:55:21 +01:00
parent cf74b63d61
commit a2b601343b
+3 -21
View File
@@ -2228,6 +2228,8 @@ parse_options(int narg, char **pparg, int is_main)
strncpy(profile.wav_name, optarg, sizeof(profile.wav_name));
break;
case 'd':
case 'L':
case 'l':
if (strlen(optarg) > VMAX_STRING - 1)
return ("Device name too long");
strncpy(profile.oss_name, optarg, sizeof(profile.oss_name));
@@ -2242,27 +2244,7 @@ parse_options(int narg, char **pparg, int is_main)
return ("-s option value is too big");
ptr = dup_profile(&profile, opt_amp, opt_pol,
opt_mute[0], opt_mute[1], 0, 1);
if (ptr != NULL)
return (ptr);
break;
case 'L':
case 'l':
if (strlen(optarg) > VMAX_STRING - 1)
return ("Device name too long");
strncpy(profile.oss_name, optarg, sizeof(profile.oss_name));
if (profile.bits == 0 || voss_dsp_sample_rate == 0 ||
profile.channels == 0 || voss_dsp_samples == 0)
return ("Missing -b, -r, -r or -s parameters");
val = (voss_dsp_samples *
profile.bits * profile.channels) / 8;
if (val <= 0 || val >= (1024 * 1024))
return ("-s option value is too big");
ptr = dup_profile(&profile, opt_amp, opt_pol,
opt_mute[0], opt_mute[1], c == 'L', 0);
opt_mute[0], opt_mute[1], c == 'L', c == 'd');
if (ptr != NULL)
return (ptr);
break;