From: Jaroslav Kysela Date: Fri, 26 Feb 2021 18:53:17 +0000 (+0100) Subject: control: snd_ctl_ascii_elem_id_get() - do not show unset numid X-Git-Tag: v1.2.5~100 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=7a1402cddcde2ec15ed97b451715e558b2f53c80;p=alsa-lib.git control: snd_ctl_ascii_elem_id_get() - do not show unset numid Signed-off-by: Jaroslav Kysela --- diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c index 74f76cca..3ed1c647 100644 --- a/src/control/ctlparse.c +++ b/src/control/ctlparse.c @@ -116,14 +116,19 @@ static long long get_integer64(const char **ptr, long long min, long long max) */ char *snd_ctl_ascii_elem_id_get(snd_ctl_elem_id_t *id) { - unsigned int index, device, subdevice; + unsigned int numid, index, device, subdevice; char buf[256], buf1[32]; + const char *iface; - snprintf(buf, sizeof(buf), "numid=%u,iface=%s,name='%s'", - snd_ctl_elem_id_get_numid(id), - snd_ctl_elem_iface_name( - snd_ctl_elem_id_get_interface(id)), - snd_ctl_elem_id_get_name(id)); + numid = snd_ctl_elem_id_get_numid(id); + iface = snd_ctl_elem_iface_name(snd_ctl_elem_id_get_interface(id)); + if (numid > 0) { + snprintf(buf, sizeof(buf), "numid=%u,iface=%s,name='%s'", + numid, iface, snd_ctl_elem_id_get_name(id)); + } else { + snprintf(buf, sizeof(buf), "iface=%s,name='%s'", + iface, snd_ctl_elem_id_get_name(id)); + } buf[sizeof(buf)-1] = '\0'; index = snd_ctl_elem_id_get_index(id); device = snd_ctl_elem_id_get_device(id);