[pulseaudio-discuss] [PATCH v2 15/25] build-sys: Move to compiling with C11 support

arun at accosted.net arun at accosted.net
Tue Dec 15 19:40:01 PST 2015


From: Arun Raghavan <git at arunraghavan.net>

This is needed for building with anonymous unions. A bunch of calls to
fail() that used to mysteriously work need fixing -- fail() is a macro
that takes a printf-style message as an argument. Not passing this
somehow worked with the previous compiler flags, but breaks with
-std=c11.
---
 configure.ac                     | 3 ++-
 src/tests/connect-stress.c       | 6 +++---
 src/tests/cpu-mix-test.c         | 2 +-
 src/tests/cpu-remap-test.c       | 4 ++--
 src/tests/cpu-sconv-test.c       | 4 ++--
 src/tests/cpu-volume-test.c      | 2 +-
 src/tests/cpulimit-test.c        | 4 ++--
 src/tests/extended-test.c        | 4 ++--
 src/tests/get-binary-name-test.c | 2 +-
 src/tests/interpol-test.c        | 2 +-
 src/tests/mult-s16-test.c        | 2 +-
 src/tests/sync-playback.c        | 4 ++--
 12 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index 26c3e29..6fc77c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,7 +80,6 @@ AC_PROG_LN_S
 # CC
 
 AC_PROG_CC
-AC_PROG_CC_C99
 AM_PROG_CC_C_O
 # Only required if you want the WebRTC canceller -- no runtime dep on
 # libstdc++ otherwise
@@ -176,6 +175,8 @@ esac
 
 #### Compiler flags ####
 
+AX_APPEND_COMPILE_FLAGS([-std=c11], [], [-pedantic -Werror])
+
 AX_APPEND_COMPILE_FLAGS(
     [-Wall -W -Wextra -pipe -Wno-long-long -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -fno-common -fdiagnostics-show-option -fdiagnostics-color=auto],
     [], [-pedantic -Werror])
diff --git a/src/tests/connect-stress.c b/src/tests/connect-stress.c
index 7c755e9..055ef13 100644
--- a/src/tests/connect-stress.c
+++ b/src/tests/connect-stress.c
@@ -80,7 +80,7 @@ static void connect(const char *name, int *try) {
     /* Connect the context */
     if (pa_context_connect(context, NULL, 0, NULL) < 0) {
         fprintf(stderr, "pa_context_connect() failed.\n");
-        fail();
+        ck_abort();
     }
 
     ret = pa_threaded_mainloop_start(mainloop);
@@ -144,7 +144,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
         default:
         case PA_STREAM_FAILED:
             fprintf(stderr, "Stream error: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s))));
-            fail();
+            ck_abort();
     }
 }
 
@@ -190,7 +190,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
         case PA_CONTEXT_FAILED:
         default:
             fprintf(stderr, "Context error: %s\n", pa_strerror(pa_context_errno(c)));
-            fail();
+            ck_abort();
     }
 }
 
diff --git a/src/tests/cpu-mix-test.c b/src/tests/cpu-mix-test.c
index f3bc0cc..f42530d 100644
--- a/src/tests/cpu-mix-test.c
+++ b/src/tests/cpu-mix-test.c
@@ -118,7 +118,7 @@ static void run_mix_test(
                     i,
                     samples[i], samples_ref[i],
                     samples0[i], samples1[i]);
-                fail();
+                ck_abort();
             }
         }
     }
diff --git a/src/tests/cpu-remap-test.c b/src/tests/cpu-remap-test.c
index cfe8647..7af5e29 100644
--- a/src/tests/cpu-remap-test.c
+++ b/src/tests/cpu-remap-test.c
@@ -70,7 +70,7 @@ static void run_remap_test_float(
                 pa_log_debug("Correctness test failed: align=%d", align);
                 pa_log_debug("%d: %.24f != %.24f\n", i,
                     out[i], out_ref[i]);
-                fail();
+                ck_abort();
             }
         }
     }
@@ -123,7 +123,7 @@ static void run_remap_test_s16(
             if (abs(out[i] - out_ref[i]) > 3) {
                 pa_log_debug("Correctness test failed: align=%d", align);
                 pa_log_debug("%d: %d != %d\n", i, out[i], out_ref[i]);
-                fail();
+                ck_abort();
             }
         }
     }
diff --git a/src/tests/cpu-sconv-test.c b/src/tests/cpu-sconv-test.c
index 2eb51de..3f189d1 100644
--- a/src/tests/cpu-sconv-test.c
+++ b/src/tests/cpu-sconv-test.c
@@ -65,7 +65,7 @@ static void run_conv_test_float_to_s16(
             if (abs(samples[i] - samples_ref[i]) > 1) {
                 pa_log_debug("Correctness test failed: align=%d", align);
                 pa_log_debug("%d: %04hx != %04hx (%.24f)\n", i, samples[i], samples_ref[i], floats[i]);
-                fail();
+                ck_abort();
             }
         }
     }
@@ -115,7 +115,7 @@ static void run_conv_test_s16_to_float(
             if (fabsf(floats[i] - floats_ref[i]) > 0.0001f) {
                 pa_log_debug("Correctness test failed: align=%d", align);
                 pa_log_debug("%d: %.24f != %.24f (%d)\n", i, floats[i], floats_ref[i], samples[i]);
-                fail();
+                ck_abort();
             }
         }
     }
diff --git a/src/tests/cpu-volume-test.c b/src/tests/cpu-volume-test.c
index 01ac2fc..15f0658 100644
--- a/src/tests/cpu-volume-test.c
+++ b/src/tests/cpu-volume-test.c
@@ -78,7 +78,7 @@ static void run_volume_test(
                 pa_log_debug("Correctness test failed: align=%d, channels=%d", align, channels);
                 pa_log_debug("%d: %04hx != %04hx (%04hx * %08x)\n", i, samples[i], samples_ref[i],
                         samples_orig[i], volumes[i % channels]);
-                fail();
+                ck_abort();
             }
         }
     }
diff --git a/src/tests/cpulimit-test.c b/src/tests/cpulimit-test.c
index 3a8124f..e01a5b8 100644
--- a/src/tests/cpulimit-test.c
+++ b/src/tests/cpulimit-test.c
@@ -48,7 +48,7 @@ static void func(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata
     if ((now - start) >= 30) {
         m->quit(m, 1);
         fprintf(stderr, "Test failed\n");
-        fail();
+        ck_abort();
     } else
         raise(SIGUSR1);
 }
@@ -78,7 +78,7 @@ START_TEST (cpulimit_test) {
 
         if ((now - start) >= 30) {
             fprintf(stderr, "Test failed\n");
-            fail();
+            ck_abort();
             break;
         }
     }
diff --git a/src/tests/extended-test.c b/src/tests/extended-test.c
index ee766b8..0d08fac 100644
--- a/src/tests/extended-test.c
+++ b/src/tests/extended-test.c
@@ -100,7 +100,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
         default:
         case PA_STREAM_FAILED:
             fprintf(stderr, "Stream error: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s))));
-            fail();
+            ck_abort();
     }
 }
 
@@ -151,7 +151,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
         case PA_CONTEXT_FAILED:
         default:
             fprintf(stderr, "Context error: %s\n", pa_strerror(pa_context_errno(c)));
-            fail();
+            ck_abort();
     }
 }
 
diff --git a/src/tests/get-binary-name-test.c b/src/tests/get-binary-name-test.c
index 4c855bb..cd53bde 100644
--- a/src/tests/get-binary-name-test.c
+++ b/src/tests/get-binary-name-test.c
@@ -39,7 +39,7 @@ START_TEST (getbinaryname_test) {
         if (!pa_get_binary_name(exename, allocated)) {
             pa_log_error("failed to read binary name");
             pa_xfree(exename);
-            fail();
+            ck_abort();
         }
 
         if (strlen(exename) < allocated - 1) {
diff --git a/src/tests/interpol-test.c b/src/tests/interpol-test.c
index 7a7bffc..b4cf18c 100644
--- a/src/tests/interpol-test.c
+++ b/src/tests/interpol-test.c
@@ -144,7 +144,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
         case PA_CONTEXT_FAILED:
         default:
             pa_log_error("Context error: %s", pa_strerror(pa_context_errno(c)));
-            fail();
+            ck_abort();
     }
 }
 
diff --git a/src/tests/mult-s16-test.c b/src/tests/mult-s16-test.c
index d2a351c..4f6f9c7 100644
--- a/src/tests/mult-s16-test.c
+++ b/src/tests/mult-s16-test.c
@@ -65,7 +65,7 @@ START_TEST (mult_s16_test) {
 
         if (a != b) {
             pa_log_debug("%d: %d != %d", i, a, b);
-            fail();
+            ck_abort();
         }
     }
 
diff --git a/src/tests/sync-playback.c b/src/tests/sync-playback.c
index f06b459..9ef038c 100644
--- a/src/tests/sync-playback.c
+++ b/src/tests/sync-playback.c
@@ -106,7 +106,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
         default:
         case PA_STREAM_FAILED:
             fprintf(stderr, "Stream error: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s))));
-            fail();
+            ck_abort();
     }
 }
 
@@ -148,7 +148,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
         case PA_CONTEXT_FAILED:
         default:
             fprintf(stderr, "Context error: %s\n", pa_strerror(pa_context_errno(c)));
-            fail();
+            ck_abort();
     }
 }
 
-- 
2.5.0



More information about the pulseaudio-discuss mailing list