Menu

#326 sox_sample_test.h needs math.h for fabs()

closed-fixed
nobody
None
5
2020-08-03
2019-08-02
No

Currently, in a build of the SoX Git source code, on Linux, using the Intel compiler, I see this warning:

In file included from /home/prog/sox/src/sox_sample_test.c(18):
/home/prog/sox/src/sox_sample_test.h(190): warning #266: function "fabs" declared implicitly
    assert(fabs(d - 1) < 1e-9 && clips == 0);
    ^

Then, when I install and run "make installcheck", I see this:

[...]
Making installcheck in src
make[1]: Entering directory `/tmp/sox-git-build/src'
/home/prog/sox/src/tests.sh --bindir=/tmp/sox-git-build/_install/bin --builddir=. --srcdir=/home/prog/sox/src
sox_sample_test: /home/prog/sox/src/sox_sample_test.h:190: main: Assertion `fabs(d - 1) < 1e-9 && clips == 0' failed.
/home/prog/sox/src/tests.sh: line 217:  7663 Aborted                 (core dumped) ${builddir}/sox_sample_test${EXEEXT}
make[1]: *** [installcheck] Error 1
make[1]: Leaving directory `/tmp/sox-git-build/src'
make: *** [installcheck-recursive] Error 1

What happens is that fabs(d - 1) returns 1 (int), because the function was not declared. The following patch addresses the issue and allows the test suite to pass:

diff --git a/src/sox_sample_test.h b/src/sox_sample_test.h
index 62b55e4..17f0069 100644
--- a/src/sox_sample_test.h
+++ b/src/sox_sample_test.h
@@ -19,6 +19,7 @@
 #undef NDEBUG /* Must undef above assert.h or other that might include it. */
 #endif
 #include <assert.h>
+#include <math.h>
 #include "sox.h"

 #define TEST_UINT(bits) \

Discussion

  • Mans Rullgard

    Mans Rullgard - 2020-08-03
    • status: open --> closed-fixed
     
  • Mans Rullgard

    Mans Rullgard - 2020-08-03

    Fixed.

     

Log in to post a comment.

MongoDB Logo MongoDB