[pulseaudio-commits] 5 commits - src/modules src/pulsecore src/tests

Peter Meerwald pmeerw at kemper.freedesktop.org
Mon Nov 17 04:27:55 PST 2014


 src/modules/alsa/alsa-mixer.c          |    3 +--
 src/modules/bluetooth/backend-native.c |    4 ++--
 src/pulsecore/aupdate.c                |    2 +-
 src/pulsecore/macro.h                  |    8 +++++++-
 src/pulsecore/sink-input.c             |    6 +++---
 src/pulsecore/sink.c                   |    2 +-
 src/pulsecore/source-output.c          |    2 +-
 src/pulsecore/source.c                 |    2 +-
 src/tests/format-test.c                |    2 +-
 src/tests/lo-test-util.c               |   10 ++++------
 10 files changed, 22 insertions(+), 19 deletions(-)

New commits:
commit 275ffb3657dbf6917e53819ba48c213e888c5845
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Sun Nov 9 17:38:27 2014 +0100

    alsa-mixer: Use pa_assert_not_reached()
    
    get rid of the following warning when compiling with NDEBUG:
    
    modules/alsa/alsa-mixer.c: In function 'element_is_subset':
    modules/alsa/alsa-mixer.c:3125:18: warning: 'a_limit' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 long a_limit;
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 8b23d90..b5d6276 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -3155,8 +3155,7 @@ static bool element_is_subset(pa_alsa_element *a, pa_alsa_element *b, snd_mixer_
             else if (a->volume_use == PA_ALSA_VOLUME_MERGE)
                 a_limit = a->volume_limit;
             else
-                /* This should never be reached */
-                pa_assert(false);
+                pa_assert_not_reached();
 
             if (a_limit > b->volume_limit)
                 return false;

commit 09a3d904a1f5f1dd05877cc491bb1123edf9e209
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Sun Nov 9 17:33:00 2014 +0100

    tests: Use pa_assert_se() to get rid of an used variable warning
    
    when compiled with NDEBUG
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/lo-test-util.c b/src/tests/lo-test-util.c
index 01eb295..84e8af3 100644
--- a/src/tests/lo-test-util.c
+++ b/src/tests/lo-test-util.c
@@ -72,7 +72,7 @@ static int cal_state = CALIBRATION_ONE;
 
 static void calibrate_write_cb(pa_stream *s, size_t nbytes, void *userdata) {
     pa_lo_test_context *ctx = (pa_lo_test_context *) userdata;
-    int i, r, nsamp = nbytes / ctx->fs;
+    int i, nsamp = nbytes / ctx->fs;
     float tmp[nsamp][2];
     static int count = 0;
 
@@ -80,8 +80,7 @@ static void calibrate_write_cb(pa_stream *s, size_t nbytes, void *userdata) {
     for (i = 0; i < nsamp; i++)
         tmp[i][0] = tmp[i][1] = cal_state == CALIBRATION_ONE ? sinf(count++ * TONE_HZ * 2 * M_PI / ctx->sample_spec.rate) : 0.0f;
 
-    r = pa_stream_write(s, &tmp, nbytes, nop_free_cb, 0, PA_SEEK_RELATIVE);
-    pa_assert(r == 0);
+    pa_assert_se(pa_stream_write(s, &tmp, nbytes, nop_free_cb, 0, PA_SEEK_RELATIVE) == 0);
 
     if (cal_state == CALIBRATION_DONE)
         pa_stream_set_write_callback(s, ctx->write_cb, ctx);
@@ -94,12 +93,11 @@ static void calibrate_read_cb(pa_stream *s, size_t nbytes, void *userdata) {
 
     pa_cvolume vol;
     pa_operation *o;
-    int r, nsamp;
+    int nsamp;
     float *in;
     size_t l;
 
-    r = pa_stream_peek(s, (const void **)&in, &l);
-    pa_assert(r == 0);
+    pa_assert_se(pa_stream_peek(s, (const void **)&in, &l) == 0);
 
     nsamp = l / ctx->fs;
 

commit 68cc36140ba2b48dd3d8fe80b7e25d149536af54
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Sun Nov 9 17:34:11 2014 +0100

    core: Annotate variables only used within assert()s to be PA_UNUSED
    
    supresses a warning when compiling with NDEBUG:
    
    pulsecore/aupdate.c: In function 'pa_aupdate_read_end':
    pulsecore/aupdate.c:82:14: warning: variable 'n' set but not used [-Wunused-but-set-variable]
         unsigned n;
    
    pulsecore/sink-input.c: In function 'pa_sink_input_unlink':
    pulsecore/sink-input.c:648:27: warning: variable 'p' set but not used [-Wunused-but-set-variable]
         pa_source_output *o, *p = NULL;
    
    pulsecore/sink-input.c: In function 'find_filter_sink_input':
    pulsecore/sink-input.c:1523:14: warning: unused variable 'i' [-Wunused-variable]
         unsigned i = 0;
    
    pulsecore/sink-input.c: In function 'pa_sink_input_start_move':
    pulsecore/sink-input.c:1569:27: warning: variable 'p' set but not used [-Wunused-but-set-variable]
         pa_source_output *o, *p = NULL;
    
      CC       pulsecore/libpulsecore_5.0_la-sink.lo
    pulsecore/sink.c: In function 'pa_sink_unlink':
    pulsecore/sink.c:673:24: warning: variable 'j' set but not used [-Wunused-but-set-variable]
         pa_sink_input *i, *j = NULL;
    
       pulsecore/source-output.c: In function 'find_filter_source_output':
    pulsecore/source-output.c:1179:9: warning: unused variable 'i' [-Wunused-variable]
         int i = 0;
    
      CC       pulsecore/libpulsecore_5.0_la-source.lo
    pulsecore/source.c: In function 'pa_source_unlink':
    pulsecore/source.c:616:27: warning: variable 'j' set but not used [-Wunused-but-set-variable]
         pa_source_output *o, *j = NULL;
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/modules/bluetooth/backend-native.c b/src/modules/bluetooth/backend-native.c
index 86af422..e8f9c03 100644
--- a/src/modules/bluetooth/backend-native.c
+++ b/src/modules/bluetooth/backend-native.c
@@ -320,7 +320,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
     pa_bluetooth_profile_t p;
     DBusMessage *r;
     int fd;
-    const char *sender, *path, *handler;
+    const char *sender, *path, PA_UNUSED *handler;
     DBusMessageIter arg_i;
     char *pathfd;
     struct transport_rfcomm *trfc;
@@ -331,7 +331,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
     }
 
     handler = dbus_message_get_path(m);
-    pa_assert (pa_streq(handler, HSP_AG_PROFILE));
+    pa_assert(pa_streq(handler, HSP_AG_PROFILE));
 
     pa_assert(dbus_message_iter_get_arg_type(&arg_i) == DBUS_TYPE_OBJECT_PATH);
     dbus_message_iter_get_basic(&arg_i, &path);
diff --git a/src/pulsecore/aupdate.c b/src/pulsecore/aupdate.c
index 2a7241a..2b2fa87 100644
--- a/src/pulsecore/aupdate.c
+++ b/src/pulsecore/aupdate.c
@@ -79,7 +79,7 @@ unsigned pa_aupdate_read_begin(pa_aupdate *a) {
 }
 
 void pa_aupdate_read_end(pa_aupdate *a) {
-    unsigned n;
+    unsigned PA_UNUSED n;
 
     pa_assert(a);
 
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index fa379ea..8e773ec 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -644,7 +644,7 @@ static void sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state)
 /* Called from main context */
 void pa_sink_input_unlink(pa_sink_input *i) {
     bool linked;
-    pa_source_output *o, *p = NULL;
+    pa_source_output *o, PA_UNUSED *p = NULL;
 
     pa_assert(i);
     pa_assert_ctl_context();
@@ -1519,7 +1519,7 @@ bool pa_sink_input_may_move(pa_sink_input *i) {
 }
 
 static bool find_filter_sink_input(pa_sink_input *target, pa_sink *s) {
-    int i = 0;
+    unsigned PA_UNUSED i = 0;
     while (s && s->input_to_master) {
         if (s->input_to_master == target)
             return true;
@@ -1565,7 +1565,7 @@ bool pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest) {
 
 /* Called from main context */
 int pa_sink_input_start_move(pa_sink_input *i) {
-    pa_source_output *o, *p = NULL;
+    pa_source_output *o, PA_UNUSED *p = NULL;
     struct volume_factor_entry *v;
     void *state = NULL;
     int r;
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 46b6eec..8e2b5c8 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -669,7 +669,7 @@ void pa_sink_put(pa_sink* s) {
 /* Called from main context */
 void pa_sink_unlink(pa_sink* s) {
     bool linked;
-    pa_sink_input *i, *j = NULL;
+    pa_sink_input *i, PA_UNUSED *j = NULL;
 
     pa_assert(s);
     pa_assert_ctl_context();
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 90e86fe..65b2d80 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -1175,7 +1175,7 @@ bool pa_source_output_may_move(pa_source_output *o) {
 }
 
 static bool find_filter_source_output(pa_source_output *target, pa_source *s) {
-    int i = 0;
+    unsigned PA_UNUSED i = 0;
     while (s && s->output_from_master) {
         if (s->output_from_master == target)
             return true;
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 77fa510..ab3a0d2 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -612,7 +612,7 @@ void pa_source_put(pa_source *s) {
 /* Called from main context */
 void pa_source_unlink(pa_source *s) {
     bool linked;
-    pa_source_output *o, *j = NULL;
+    pa_source_output *o, PA_UNUSED *j = NULL;
 
     pa_assert(s);
     pa_assert_ctl_context();
diff --git a/src/tests/format-test.c b/src/tests/format-test.c
index 5e7d587..e9e9622 100644
--- a/src/tests/format-test.c
+++ b/src/tests/format-test.c
@@ -36,7 +36,7 @@
 
 START_TEST (format_test) {
     pa_format_info *f1 = NULL, *f2 = NULL;
-    int rates1[] = { 32000, 44100, 48000 }, i, temp_int1 = -1, temp_int2 = -1, *temp_int_array;
+    int rates1[] = { 32000, 44100, 48000 }, i, temp_int1 = -1, PA_UNUSED temp_int2 = -1, *temp_int_array;
     const char *strings[] = { "thing1", "thing2", "thing3" };
     char *temp_str, **temp_str_array;
 

commit 87d188b46c1cf0b9e5892969661990948de6a732
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Sun Nov 9 17:28:36 2014 +0100

    macro: Add macro PA_UNUSED
    
    the macro PA_UNUSED may be used to suppress a warning when a variable
    is not used, or assigned and never used; this typically happens
    when the only use of the variable is within an assert() that can
    be optimized away (i.e. with NDEBUG set)
    
    has an effect with GCC only
    
    v2: (thanks to Alexander Patrakov)
    * fix patch subject/description
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index e36b6ce..21c3e6c 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -77,6 +77,12 @@ static inline size_t PA_PAGE_ALIGN(size_t l) {
     return (l + PA_PAGE_SIZE - 1) & ~(PA_PAGE_SIZE - 1);
 }
 
+#if defined(__GNUC__)
+    #define PA_UNUSED __attribute__ ((unused))
+#else
+    #define PA_UNUSED
+#endif
+
 #define PA_ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
 
 #if defined(__GNUC__)

commit 094de7f02404c8eaed75dfccc4d2febd7d64484a
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Sun Nov 9 16:45:32 2014 +0100

    macro: Abort() when pa_assert_not_reached() even for NDEBUG
    
    fixes many warnings when compiling with NDEBUG, such as
      CC       pulse/libpulse_la-channelmap.lo
    pulse/channelmap.c: In function 'pa_channel_map_init_auto':
    pulse/channelmap.c:397:1: warning: control reaches end of non-void function [-Wreturn-type]
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 4d5e80f..e36b6ce 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -231,7 +231,7 @@ static inline size_t PA_PAGE_ALIGN(size_t l) {
 #endif
 
 #ifdef NDEBUG
-#define pa_assert_not_reached() pa_nop()
+#define pa_assert_not_reached() abort()
 #else
 #define pa_assert_not_reached()                                         \
     do {                                                                \



More information about the pulseaudio-commits mailing list