From 13f4c6d0513c19987ccdc94d0163e76db892bdaf Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 18 Jun 2011 15:58:43 +0200 Subject: [PATCH] get_media_devices: Get rid if asprintf It is a GNU extension and thus not declared in the std headers when compiling without _GNU_SOURCE Signed-off-by: Hans de Goede --- utils/libmedia_dev/get_media_devices.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/utils/libmedia_dev/get_media_devices.c b/utils/libmedia_dev/get_media_devices.c index d120023..948617a 100644 --- a/utils/libmedia_dev/get_media_devices.c +++ b/utils/libmedia_dev/get_media_devices.c @@ -230,7 +230,7 @@ static int add_v4l_class(struct media_device_entry *md) static int add_snd_class(struct media_device_entry *md) { unsigned c = 65535, d = 65535; - char *new; + char node[64]; if (strstr(md->node, "timer")) { md->type = MEDIA_SND_TIMER; @@ -259,18 +259,13 @@ static int add_snd_class(struct media_device_entry *md) return 0; /* Reformat device to be useful for alsa userspace library */ - if (d == 65535) { - if (asprintf(&new, "hw:%u", c) > 0) { - free(md->node); - md->node = new; - } - return 0; - } + if (d == 65535) + snprintf(node, sizeof(node), "hw:%u", c); + else + snprintf(node, sizeof(node), "hw:%u,%u", c, d); - if (asprintf(&new, "hw:%u,%u", c, d) > 0) { - free(md->node); - md->node = new; - } + free(md->node); + md->node = strdup(node); return 0; }; -- 2.7.4