[pulseaudio-discuss] [PATCH 7/8] modules: Cleanup get_sinks() in module-equalizer-sink
Peter Meerwald
pmeerw at pmeerw.net
Mon Sep 14 09:07:48 PDT 2015
From: Peter Meerwald <p.meerwald at bct-electronic.com>
CID 1323588
return value of pa_idxset_iterate() should be checked,
rewrite loop to do so
could have used PA_IDXSET_FOREACH() as well
---
src/modules/module-equalizer-sink.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/modules/module-equalizer-sink.c b/src/modules/module-equalizer-sink.c
index 9c25f3f..b3c8cf2 100644
--- a/src/modules/module-equalizer-sink.c
+++ b/src/modules/module-equalizer-sink.c
@@ -1669,20 +1669,20 @@ void manager_get_revision(DBusConnection *conn, DBusMessage *msg, void *_u) {
static void get_sinks(pa_core *u, char ***names, unsigned *n_sinks) {
void *iter = NULL;
- struct userdata *sink_u = NULL;
- uint32_t dummy;
+ struct userdata *sink_u;
pa_idxset *sink_list;
+ unsigned i = 0;
+
pa_assert(u);
pa_assert(names);
pa_assert(n_sinks);
pa_assert_se(sink_list = pa_shared_get(u, SINKLIST));
*n_sinks = (unsigned) pa_idxset_size(sink_list);
- *names = *n_sinks > 0 ? pa_xnew0(char *,*n_sinks) : NULL;
- for(uint32_t i = 0; i < *n_sinks; ++i) {
- sink_u = (struct userdata *) pa_idxset_iterate(sink_list, &iter, &dummy);
- (*names)[i] = pa_xstrdup(sink_u->dbus_path);
- }
+ *names = *n_sinks > 0 ? pa_xnew0(char *, *n_sinks) : NULL;
+
+ while ((sink_u = pa_idxset_iterate(sink_list, &iter, NULL)))
+ (*names)[i++] = pa_xstrdup(sink_u->dbus_path);
}
void manager_get_sinks(DBusConnection *conn, DBusMessage *msg, void *_u) {
--
1.7.9.5
More information about the pulseaudio-discuss
mailing list