Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Mar 2017 10:07:46 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r314650 - head/lib/msun/tests
Message-ID:  <201703041007.v24A7kae097986@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Mar  4 10:07:46 2017
New Revision: 314650
URL: https://svnweb.freebsd.org/changeset/base/314650

Log:
  Fix warnings in lib/msun/tests/... to help pave way for WARNS?= 6.
  
  - Staticize variables.
  - Use nitems liberally. Wherever nitems is used, use unsigned integers
  - Remove unused variables (argc, argv, etc)
  
  This fixes most issues -- some issues remain in logarithm_test though.
  
  MFC after:	1 week
  Sponsored by:	Dell EMC Isilon

Modified:
  head/lib/msun/tests/cexp_test.c
  head/lib/msun/tests/conj_test.c
  head/lib/msun/tests/csqrt_test.c
  head/lib/msun/tests/ctrig_test.c
  head/lib/msun/tests/exponential_test.c
  head/lib/msun/tests/fenv_test.c
  head/lib/msun/tests/fma_test.c
  head/lib/msun/tests/fmaxmin_test.c
  head/lib/msun/tests/invctrig_test.c
  head/lib/msun/tests/invtrig_test.c
  head/lib/msun/tests/logarithm_test.c
  head/lib/msun/tests/lrint_test.c
  head/lib/msun/tests/nan_test.c
  head/lib/msun/tests/nearbyint_test.c
  head/lib/msun/tests/next_test.c
  head/lib/msun/tests/rem_test.c
  head/lib/msun/tests/test-utils.h
  head/lib/msun/tests/trig_test.c

Modified: head/lib/msun/tests/cexp_test.c
==============================================================================
--- head/lib/msun/tests/cexp_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/cexp_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -94,7 +94,7 @@ static const float finites[] =
 
 
 /* Tests for 0 */
-void
+static void
 test_zero(void)
 {
 
@@ -109,10 +109,10 @@ test_zero(void)
  * Tests for NaN.  The signs of the results are indeterminate unless the
  * imaginary part is 0.
  */
-void
-test_nan()
+static void
+test_nan(void)
 {
-	int i;
+	unsigned i;
 
 	/* cexp(x + NaNi) = NaN + NaNi and optionally raises invalid */
 	/* cexp(NaN + yi) = NaN + NaNi and optionally raises invalid (|y|>0) */
@@ -142,10 +142,10 @@ test_nan()
 		ALL_STD_EXCEPT, 0, 0);
 }
 
-void
+static void
 test_inf(void)
 {
-	int i;
+	unsigned i;
 
 	/* cexp(x + inf i) = NaN + NaNi and raises invalid */
 	for (i = 0; i < nitems(finites); i++) {
@@ -184,10 +184,10 @@ test_inf(void)
 		ALL_STD_EXCEPT, 0, 1);
 }
 
-void
+static void
 test_reals(void)
 {
-	int i;
+	unsigned i;
 
 	for (i = 0; i < nitems(finites); i++) {
 		/* XXX could check exceptions more meticulously */
@@ -207,10 +207,10 @@ test_reals(void)
 	}
 }
 
-void
+static void
 test_imaginaries(void)
 {
-	int i;
+	unsigned i;
 
 	for (i = 0; i < nitems(finites); i++) {
 		printf("# Run %d..\n", i);
@@ -229,7 +229,7 @@ test_imaginaries(void)
 	}
 }
 
-void
+static void
 test_small(void)
 {
 	static const double tests[] = {
@@ -242,7 +242,7 @@ test_small(void)
 	};
 	double a, b;
 	double x, y;
-	int i;
+	unsigned i;
 
 	for (i = 0; i < nitems(tests); i += 4) {
 		printf("# Run %d..\n", i);
@@ -260,7 +260,7 @@ test_small(void)
 }
 
 /* Test inputs with a real part r that would overflow exp(r). */
-void
+static void
 test_large(void)
 {
 
@@ -288,7 +288,7 @@ test_large(void)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..7\n");

Modified: head/lib/msun/tests/conj_test.c
==============================================================================
--- head/lib/msun/tests/conj_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/conj_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -71,7 +71,7 @@ static const double tests[] = {
 };
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 	static const int ntests = sizeof(tests) / sizeof(tests[0]) / 2;
 	complex float in;
@@ -90,7 +90,7 @@ main(int argc, char *argv[])
 		assert(fpequal(libcreall(in), __real__ in));
 		assert(fpequal(libcimagf(in), __imag__ in));
 		assert(fpequal(libcimag(in), __imag__ in));
-		assert(fpequal(libcimagl(in), __imag__ in));		
+		assert(fpequal(libcimagl(in), __imag__ in));
 
 		feclearexcept(FE_ALL_EXCEPT);
 		if (!cfpequal(libconjf(in), expected)) {

Modified: head/lib/msun/tests/csqrt_test.c
==============================================================================
--- head/lib/msun/tests/csqrt_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/csqrt_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
  * The latter two convert to float or double, respectively, and test csqrtf()
  * and csqrt() with the same arguments.
  */
-long double complex (*t_csqrt)(long double complex);
+static long double complex (*t_csqrt)(long double complex);
 
 static long double complex
 _csqrtf(long double complex d)
@@ -82,7 +82,7 @@ assert_equal(long double complex d1, lon
  * exceptions.)
  */
 static void
-test_finite()
+test_finite(void)
 {
 	static const double tests[] = {
 	     /* csqrt(a + bI) = x + yI */
@@ -125,7 +125,7 @@ test_finite()
 
 	double a, b;
 	double x, y;
-	int i, j;
+	unsigned i, j;
 
 	for (i = 0; i < nitems(tests); i += 4) {
 		for (j = 0; j < nitems(mults); j++) {
@@ -143,7 +143,7 @@ test_finite()
  * Test the handling of +/- 0.
  */
 static void
-test_zeros()
+test_zeros(void)
 {
 
 	assert_equal(t_csqrt(CMPLXL(0.0, 0.0)), CMPLXL(0.0, 0.0));
@@ -156,7 +156,7 @@ test_zeros()
  * Test the handling of infinities when the other argument is not NaN.
  */
 static void
-test_infinities()
+test_infinities(void)
 {
 	static const double vals[] = {
 		0.0,
@@ -167,7 +167,7 @@ test_infinities()
 		-INFINITY,
 	};
 
-	int i;
+	unsigned i;
 
 	for (i = 0; i < nitems(vals); i++) {
 		if (isfinite(vals[i])) {
@@ -187,7 +187,7 @@ test_infinities()
  * Test the handling of NaNs.
  */
 static void
-test_nans()
+test_nans(void)
 {
 
 	assert(creall(t_csqrt(CMPLXL(INFINITY, NAN))) == INFINITY);
@@ -232,7 +232,7 @@ test_overflow(int maxexp)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..15\n");

Modified: head/lib/msun/tests/ctrig_test.c
==============================================================================
--- head/lib/msun/tests/ctrig_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/ctrig_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -31,6 +31,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/param.h>
 #include <complex.h>
 #include <fenv.h>
 #include <float.h>
@@ -238,7 +239,7 @@ ATF_TC_BODY(test_inf_inputs, tc)
 	    0, M_PI / 4, 3 * M_PI / 4, 5 * M_PI / 4,
 	};
 	long double complex z, c, s;
-	int i;
+	unsigned i;
 
 	/*
 	 * IN		CSINH		CCOSH		CTANH
@@ -260,7 +261,7 @@ ATF_TC_BODY(test_inf_inputs, tc)
 	testall_odd(ctan, z, CMPLXL(0, 1), ALL_STD_EXCEPT, 0, CS_REAL);
 
 	/* XXX We allow spurious inexact exceptions here (hard to avoid). */
-	for (i = 0; i < sizeof(finites) / sizeof(finites[0]); i++) {
+	for (i = 0; i < nitems(finites); i++) {
 		z = CMPLXL(INFINITY, finites[i]);
 		c = INFINITY * cosl(finites[i]);
 		s = finites[i] == 0 ? finites[i] : INFINITY * sinl(finites[i]);
@@ -308,9 +309,9 @@ ATF_TC_BODY(test_axes, tc)
 	    5 * M_PI / 4, 3 * M_PI / 2, 7 * M_PI / 4,
 	};
 	long double complex z;
-	int i;
+	unsigned i;
 
-	for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) {
+	for (i = 0; i < nitems(nums); i++) {
 		/* Real axis */
 		z = CMPLXL(nums[i], 0.0);
 		test_odd_tol(csinh, z, CMPLXL(sinh(nums[i]), 0), DBL_ULP());
@@ -412,9 +413,9 @@ ATF_TC_BODY(test_small_inputs, tc)
 		  -0.26580222883407969212086273981988897L }
 	};
 	long double complex z;
-	int i;
+	unsigned i;
 
-	for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+	for (i = 0; i < nitems(tests); i++) {
 		z = CMPLXL(tests[i].a, tests[i].b);
 		testall_odd_tol(csinh, z,
 		    CMPLXL(tests[i].sinh_a, tests[i].sinh_b), 1.1);

Modified: head/lib/msun/tests/exponential_test.c
==============================================================================
--- head/lib/msun/tests/exponential_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/exponential_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -89,7 +89,7 @@ __FBSDID("$FreeBSD$");
 	test(expm1f, x, result, exceptmask, excepts);			\
 } while (0)
 
-void
+static void
 run_generic_tests(void)
 {
 
@@ -122,10 +122,10 @@ run_generic_tests(void)
 	testall1(-50000.0, -1.0, ALL_STD_EXCEPT, FE_INEXACT);
 }
 
-void
+static void
 run_exp2_tests(void)
 {
-	int i;
+	unsigned i;
 
 	/*
 	 * We should insist that exp2() return exactly the correct
@@ -148,7 +148,7 @@ run_exp2_tests(void)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..3\n");

Modified: head/lib/msun/tests/fenv_test.c
==============================================================================
--- head/lib/msun/tests/fenv_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/fenv_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -64,56 +64,15 @@ static const int std_excepts[] = {
 /* init_exceptsets() initializes this to the power set of std_excepts[] */
 static int std_except_sets[1 << NEXCEPTS];
 
-static void init_exceptsets(void);
-
-static void test_dfl_env(void);
-static void test_fegsetenv(void);
-static void test_fegsetexceptflag(void);
-static void test_masking(void);
-static void test_fegsetround(void);
-static void test_feholdupdate(void);
-static void test_feraiseexcept(void);
-static void test_fetestclearexcept(void);
-
-static int getround(void);
-static void raiseexcept(int excepts);
-static void trap_handler(int sig);
-
 #pragma STDC FENV_ACCESS ON
 
-int
-main(int argc, char *argv[])
-{
-
-	printf("1..8\n");
-	init_exceptsets();
-	test_dfl_env();
-	printf("ok 1 - fenv\n");
-	test_fetestclearexcept();
-	printf("ok 2 - fenv\n");
-	test_fegsetexceptflag();
-	printf("ok 3 - fenv\n");
-	test_feraiseexcept();
-	printf("ok 4 - fenv\n");
-	test_fegsetround();
-	printf("ok 5 - fenv\n");
-	test_fegsetenv();
-	printf("ok 6 - fenv\n");
-	test_masking();
-	printf("ok 7 - fenv\n");
-	test_feholdupdate();
-	printf("ok 8 - fenv\n");
-
-	return (0);
-}
-
 /*
  * Initialize std_except_sets[] to the power set of std_excepts[]
  */
-void
+static void
 init_exceptsets(void)
 {
-	int i, j, sr;
+	unsigned i, j, sr;
 
 	for (i = 0; i < 1 << NEXCEPTS; i++) {
 		for (sr = i, j = 0; sr != 0; sr >>= 1, j++)
@@ -122,6 +81,90 @@ init_exceptsets(void)
 }
 
 /*
+ * Raise a floating-point exception without relying on the standard
+ * library routines, which we are trying to test.
+ *
+ * XXX We can't raise an {over,under}flow without also raising an
+ * inexact exception.
+ */
+static void
+raiseexcept(int excepts)
+{
+	volatile double d;
+
+	/*
+	 * With a compiler that supports the FENV_ACCESS pragma
+	 * properly, simple expressions like '0.0 / 0.0' should
+	 * be sufficient to generate traps.  Unfortunately, we
+	 * need to bring a volatile variable into the equation
+	 * to prevent incorrect optimizations.
+	 */
+	if (excepts & FE_INVALID) {
+		d = 0.0;
+		d = 0.0 / d;
+	}
+	if (excepts & FE_DIVBYZERO) {
+		d = 0.0;
+		d = 1.0 / d;
+	}
+	if (excepts & FE_OVERFLOW) {
+		d = DBL_MAX;
+		d *= 2.0;
+	}
+	if (excepts & FE_UNDERFLOW) {
+		d = DBL_MIN;
+		d /= DBL_MAX;
+	}
+	if (excepts & FE_INEXACT) {
+		d = DBL_MIN;
+		d += 1.0;
+	}
+
+	/*
+	 * On the x86 (and some other architectures?) the FPU and
+	 * integer units are decoupled.  We need to execute an FWAIT
+	 * or a floating-point instruction to get synchronous exceptions.
+	 */
+	d = 1.0;
+	d += 1.0;
+}
+
+/*
+ * Determine the current rounding mode without relying on the fenv
+ * routines.  This function may raise an inexact exception.
+ */
+static int
+getround(void)
+{
+	volatile double d;
+
+	/*
+	 * This test works just as well with 0.0 - 0.0, except on ia64
+	 * where 0.0 - 0.0 gives the wrong sign when rounding downwards.
+	 */
+	d = 1.0;
+	d -= 1.0;
+	if (copysign(1.0, d) < 0.0)
+		return (FE_DOWNWARD);
+
+	d = 1.0;
+	if (d + (DBL_EPSILON * 3.0 / 4.0) == 1.0)
+		return (FE_TOWARDZERO);
+	if (d + (DBL_EPSILON * 1.0 / 4.0) > 1.0)
+		return (FE_UPWARD);
+
+	return (FE_TONEAREST);
+}
+
+static void
+trap_handler(int sig)
+{
+
+	assert(sig == SIGFPE);
+	_exit(0);
+}
+
+/*
  * This tests checks the default FP environment, so it must be first.
  * The memcmp() test below may be too much to ask for, since there
  * could be multiple machine-specific default environments.
@@ -347,7 +390,8 @@ static void
 test_masking(void)
 {
 	struct sigaction act;
-	int except, i, pass, raise, status;
+	int except, pass, raise, status;
+	unsigned i;
 
 	assert((fegetexcept() & ALL_STD_EXCEPT) == 0);
 	assert((feenableexcept(FE_INVALID|FE_OVERFLOW) & ALL_STD_EXCEPT) == 0);
@@ -427,7 +471,8 @@ test_feholdupdate(void)
 	fenv_t env;
 
 	struct sigaction act;
-	int except, i, pass, status, raise;
+	int except, pass, status, raise;
+	unsigned i;
 
 	sigemptyset(&act.sa_mask);
 	act.sa_flags = 0;
@@ -452,7 +497,7 @@ test_feholdupdate(void)
 				 * We don't want to cause a fatal exception in
 				 * the child until the second pass, so we can
 				 * check other properties of feupdateenv().
-				 */				
+				 */
 				if (pass == 1)
 					assert((feenableexcept(except) &
 						   ALL_STD_EXCEPT) == 0);
@@ -491,86 +536,28 @@ test_feholdupdate(void)
 	assert(fetestexcept(FE_ALL_EXCEPT) == 0);
 }
 
-/*
- * Raise a floating-point exception without relying on the standard
- * library routines, which we are trying to test.
- *
- * XXX We can't raise an {over,under}flow without also raising an
- * inexact exception.
- */
-static void
-raiseexcept(int excepts)
-{
-	volatile double d;
-
-	/*
-	 * With a compiler that supports the FENV_ACCESS pragma
-	 * properly, simple expressions like '0.0 / 0.0' should
-	 * be sufficient to generate traps.  Unfortunately, we
-	 * need to bring a volatile variable into the equation
-	 * to prevent incorrect optimizations.
-	 */
-	if (excepts & FE_INVALID) {
-		d = 0.0;
-		d = 0.0 / d;
-	}
-	if (excepts & FE_DIVBYZERO) {
-		d = 0.0;
-		d = 1.0 / d;
-	}
-	if (excepts & FE_OVERFLOW) {
-		d = DBL_MAX;
-		d *= 2.0;
-	}
-	if (excepts & FE_UNDERFLOW) {
-		d = DBL_MIN;
-		d /= DBL_MAX;
-	}
-	if (excepts & FE_INEXACT) {
-		d = DBL_MIN;
-		d += 1.0;
-	}
-
-	/*
-	 * On the x86 (and some other architectures?) the FPU and
-	 * integer units are decoupled.  We need to execute an FWAIT
-	 * or a floating-point instruction to get synchronous exceptions.
-	 */
-	d = 1.0;
-	d += 1.0;
-}
-
-/*
- * Determine the current rounding mode without relying on the fenv
- * routines.  This function may raise an inexact exception.
- */
-static int
-getround(void)
+int
+main(void)
 {
-	volatile double d;
 
-	/*
-	 * This test works just as well with 0.0 - 0.0, except on ia64
-	 * where 0.0 - 0.0 gives the wrong sign when rounding downwards.
-	 */
-	d = 1.0;
-	d -= 1.0;
-	if (copysign(1.0, d) < 0.0)
-		return (FE_DOWNWARD);
-
-	d = 1.0;
-	if (d + (DBL_EPSILON * 3.0 / 4.0) == 1.0)
-		return (FE_TOWARDZERO);
-	if (d + (DBL_EPSILON * 1.0 / 4.0) > 1.0)
-		return (FE_UPWARD);
-
-	return (FE_TONEAREST);
-}
-
-static void
-trap_handler(int sig)
-{
+	printf("1..8\n");
+	init_exceptsets();
+	test_dfl_env();
+	printf("ok 1 - fenv\n");
+	test_fetestclearexcept();
+	printf("ok 2 - fenv\n");
+	test_fegsetexceptflag();
+	printf("ok 3 - fenv\n");
+	test_feraiseexcept();
+	printf("ok 4 - fenv\n");
+	test_fegsetround();
+	printf("ok 5 - fenv\n");
+	test_fegsetenv();
+	printf("ok 6 - fenv\n");
+	test_masking();
+	printf("ok 7 - fenv\n");
+	test_feholdupdate();
+	printf("ok 8 - fenv\n");
 
-	assert(sig == SIGFPE);
-	_exit(0);
+	return (0);
 }

Modified: head/lib/msun/tests/fma_test.c
==============================================================================
--- head/lib/msun/tests/fma_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/fma_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$");
  * This is needed because clang constant-folds fma in ways that are incorrect
  * in rounding modes other than FE_TONEAREST.
  */
-volatile double one = 1.0;
+static volatile double one = 1.0;
 
 static void
 test_zeroes(void)
@@ -472,10 +472,10 @@ test_double_rounding(void)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 	int rmodes[] = { FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO };
-	int i, j;
+	unsigned i, j;
 
 #if defined(__i386__)
 	printf("1..0 # SKIP all testcases fail on i386\n");

Modified: head/lib/msun/tests/fmaxmin_test.c
==============================================================================
--- head/lib/msun/tests/fmaxmin_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/fmaxmin_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$");
 	}								      \
 } while (0)
 
-int
+static int
 testall_r(long double big, long double small)
 {
 	int ok;
@@ -86,14 +86,14 @@ testall_r(long double big, long double s
 	return (ok);
 }
 
-const char *comment = NULL;
+static const char *comment = NULL;
 
 /*
  * Test all the functions: fmaxf, fmax, fmaxl, fminf, fmin, and fminl,
  * in all rounding modes and with the arguments in different orders.
  * The input 'big' must be >= 'small'.
  */
-void
+static void
 testall(int testnum, long double big, long double small)
 {
 	static const int rmodes[] = {
@@ -122,7 +122,7 @@ testall(int testnum, long double big, lo
 #endif
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..12\n");

Modified: head/lib/msun/tests/invctrig_test.c
==============================================================================
--- head/lib/msun/tests/invctrig_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/invctrig_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -31,6 +31,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/param.h>
 #include <assert.h>
 #include <complex.h>
 #include <fenv.h>
@@ -123,7 +124,7 @@ c3pi = 9.4247779607693797153879301498385
 
 
 /* Tests for 0 */
-void
+static void
 test_zero(void)
 {
 	long double complex zero = CMPLXL(0.0, 0.0);
@@ -143,8 +144,8 @@ test_zero(void)
 /*
  * Tests for NaN inputs.
  */
-void
-test_nan()
+static void
+test_nan(void)
 {
 	long double complex nan_nan = CMPLXL(NAN, NAN);
 	long double complex z;
@@ -154,7 +155,7 @@ test_nan()
 	 * NaN,NaN	NaN,NaN	    NaN,NaN	NaN,NaN	    NaN,NaN
 	 * finite,NaN	NaN,NaN*    NaN,NaN*	NaN,NaN*    NaN,NaN*
 	 * NaN,finite   NaN,NaN*    NaN,NaN*	NaN,NaN*    NaN,NaN*
-	 * NaN,Inf	Inf,NaN     NaN,-Inf	?Inf,NaN    ?0,pi/2	
+	 * NaN,Inf	Inf,NaN     NaN,-Inf	?Inf,NaN    ?0,pi/2
 	 * +-Inf,NaN	Inf,NaN     NaN,?Inf	+-Inf,NaN   +-0,NaN
 	 * +-0,NaN	NaN,NaN*    pi/2,NaN	NaN,NaN*    +-0,NaN
 	 * NaN,0	NaN,NaN*    NaN,NaN*	NaN,0	    NaN,NaN*
@@ -222,7 +223,7 @@ test_nan()
 	testall(catan, z, CMPLXL(NAN, 0.0), ALL_STD_EXCEPT, 0, 0);
 }
 
-void
+static void
 test_inf(void)
 {
 	long double complex z;
@@ -269,16 +270,16 @@ test_inf(void)
 }
 
 /* Tests along the real and imaginary axes. */
-void
+static void
 test_axes(void)
 {
 	static const long double nums[] = {
 		-2, -1, -0.5, 0.5, 1, 2
 	};
 	long double complex z;
-	int i;
+	unsigned i;
 
-	for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) {
+	for (i = 0; i < nitems(nums); i++) {
 		/* Real axis */
 		z = CMPLXL(nums[i], 0.0);
 		if (fabsl(nums[i]) <= 1) {
@@ -306,7 +307,7 @@ test_axes(void)
 	}
 }
 
-void
+static void
 test_small(void)
 {
 	/*
@@ -332,7 +333,7 @@ test_small(void)
 }
 
 /* Test inputs that might cause overflow in a sloppy implementation. */
-void
+static void
 test_large(void)
 {
 
@@ -340,7 +341,7 @@ test_large(void)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..6\n");

Modified: head/lib/msun/tests/invtrig_test.c
==============================================================================
--- head/lib/msun/tests/invtrig_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/invtrig_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -110,11 +110,10 @@ __FBSDID("$FreeBSD$");
 #define testall2(prefix, y, x, result, excepts)				\
 	testall2_tol(prefix, (y), (x), (result), 0, (excepts))
 
-long double
+static long double
 pi =   3.14159265358979323846264338327950280e+00L,
 pio3 = 1.04719755119659774615421446109316766e+00L,
 c3pi = 9.42477796076937971538793014983850839e+00L,
-c5pi = 1.57079632679489661923132169163975140e+01L,
 c7pi = 2.19911485751285526692385036829565196e+01L,
 c5pio3 = 5.23598775598298873077107230546583851e+00L,
 sqrt2m1 = 4.14213562373095048801688724209698081e-01L;
@@ -444,7 +443,7 @@ test_inverse(void)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 #if defined(__i386__)

Modified: head/lib/msun/tests/logarithm_test.c
==============================================================================
--- head/lib/msun/tests/logarithm_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/logarithm_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -31,6 +31,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/param.h>
 #include <assert.h>
 #include <fenv.h>
 #include <float.h>
@@ -98,7 +99,7 @@ __FBSDID("$FreeBSD$");
 	test(log1pl, x, result, exceptmask, excepts);			\
 } while (0)
 
-void
+static void
 run_generic_tests(void)
 {
 
@@ -127,10 +128,10 @@ run_generic_tests(void)
 	testall1(-1.0, -INFINITY, ALL_STD_EXCEPT & ~FE_INEXACT, FE_DIVBYZERO);
 }
 
-void
+static void
 run_log2_tests(void)
 {
-	int i;
+	unsigned i;
 
 	/*
 	 * We should insist that log2() return exactly the correct
@@ -154,7 +155,7 @@ run_log2_tests(void)
 	}
 }
 
-void
+static void
 run_roundingmode_tests(void)
 {
 
@@ -188,7 +189,7 @@ run_roundingmode_tests(void)
 	fesetround(FE_TONEAREST);
 }
 
-void
+static void
 run_accuracy_tests(void)
 {
 	static const struct {
@@ -219,9 +220,9 @@ run_accuracy_tests(void)
 		   7.229787154734166181706169344438271459e1L,
 		   3.139856666636059855894123306947856631e1L },
 	};
-        int i;
+        unsigned i;
 
-	for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+	for (i = 0; i < nitems(tests); i++) {
 		test_tol(log2, tests[i].x, tests[i].log2x, DBL_ULP());
 		test_tol(log2f, tests[i].x, tests[i].log2x, FLT_ULP());
 		test_tol(log2l, tests[i].x, tests[i].log2x, LDBL_ULP());
@@ -242,7 +243,7 @@ run_accuracy_tests(void)
 	}
 }
 
-void
+static void
 run_log1p_accuracy_tests(void)
 {
 
@@ -262,7 +263,7 @@ run_log1p_accuracy_tests(void)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..5\n");

Modified: head/lib/msun/tests/lrint_test.c
==============================================================================
--- head/lib/msun/tests/lrint_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/lrint_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
 
 #pragma STDC FENV_ACCESS ON
 
-void
+static void
 run_tests(void)
 {
 
@@ -132,7 +132,7 @@ run_tests(void)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..1\n");

Modified: head/lib/msun/tests/nan_test.c
==============================================================================
--- head/lib/msun/tests/nan_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/nan_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -32,6 +32,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/param.h>
 #include <assert.h>
 #include <fenv.h>
 #include <float.h>
@@ -41,7 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #include <string.h>
 
-void
+static void
 testnan(const char *nan_format)
 {
 	char nan_str[128];
@@ -49,10 +50,10 @@ testnan(const char *nan_format)
 	long double ald[4];
 	double ad[4];
 	float af[4];
-	int i;
+	unsigned i;
 
 	snprintf(nan_str, sizeof(nan_str), "nan(%s)", nan_format);
-	for (i = 0; i < 4; i++) {
+	for (i = 0; i < nitems(ad); i++) {
 		/*
 		 * x86 has an 80-bit long double stored in 96 bits,
 		 * so we need to initialize the memory for the memcmp()
@@ -61,7 +62,6 @@ testnan(const char *nan_format)
 		bzero(&af[i], sizeof(float));
 		bzero(&ad[i], sizeof(double));
 		bzero(&ald[i], sizeof(long double));
-		   
 	}
 
 	af[0] = nanf(nan_format);
@@ -105,7 +105,7 @@ testnan(const char *nan_format)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..1\n");

Modified: head/lib/msun/tests/nearbyint_test.c
==============================================================================
--- head/lib/msun/tests/nearbyint_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/nearbyint_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -35,6 +35,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/param.h>
 #include <assert.h>
 #include <fenv.h>
 #include <math.h>
@@ -49,9 +50,9 @@ static const int rmodes[] = {
 };
 
 /* Make sure we're testing the library, not some broken compiler built-ins. */
-double (*libnearbyint)(double) = nearbyint;
-float (*libnearbyintf)(float) = nearbyintf;
-long double (*libnearbyintl)(long double) = nearbyintl;
+static double (*libnearbyint)(double) = nearbyint;
+static float (*libnearbyintf)(float) = nearbyintf;
+static long double (*libnearbyintl)(long double) = nearbyintl;
 #define nearbyintf libnearbyintf
 #define nearbyint libnearbyint
 #define nearbyintl libnearbyintl
@@ -69,8 +70,6 @@ static const struct {
     { NAN,	{ NAN, NAN, NAN }},
 };
 
-static const int ntests = sizeof(tests) / sizeof(tests[0]);
-
 /* Get the appropriate result for the current rounding mode. */
 static float
 get_output(int testindex, int rmodeindex, int negative)
@@ -93,7 +92,7 @@ static void
 test_nearby(int testindex)
 {
 	float in, out;
-	int i;
+	unsigned i;
 
 	for (i = 0; i < sizeof(rmodes) / sizeof(rmodes[0]); i++) {
 		fesetround(rmodes[i]);
@@ -124,7 +123,7 @@ test_modf(int testindex)
 	float ipartf, ipart_expected;
 	double ipart;
 	long double ipartl;
-	int i;
+	unsigned i;
 
 	for (i = 0; i < sizeof(rmodes) / sizeof(rmodes[0]); i++) {
 		fesetround(rmodes[i]);
@@ -161,13 +160,13 @@ test_modf(int testindex)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
-	int i;
+	unsigned i;
 
-	printf("1..%d\n", ntests * 2);
+	printf("1..%zu\n", (size_t)(nitems(tests) * 2));
 	testnum = 1;
-	for (i = 0; i < ntests; i++) {
+	for (i = 0; i < nitems(tests); i++) {
 		test_nearby(i);
 		test_modf(i);
 	}

Modified: head/lib/msun/tests/next_test.c
==============================================================================
--- head/lib/msun/tests/next_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/next_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -73,7 +73,7 @@ static double idd(double);
 static float idf(float);
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 	static const int ex_under = FE_UNDERFLOW | FE_INEXACT;	/* shorthand */
 	static const int ex_over = FE_OVERFLOW | FE_INEXACT;

Modified: head/lib/msun/tests/rem_test.c
==============================================================================
--- head/lib/msun/tests/rem_test.c	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/rem_test.c	Sat Mar  4 10:07:46 2017	(r314650)
@@ -52,7 +52,7 @@ static void testf(float, float, float, i
 } while (0)
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 
 	printf("1..3\n");

Modified: head/lib/msun/tests/test-utils.h
==============================================================================
--- head/lib/msun/tests/test-utils.h	Sat Mar  4 09:16:51 2017	(r314649)
+++ head/lib/msun/tests/test-utils.h	Sat Mar  4 10:07:46 2017	(r314650)
@@ -88,6 +88,13 @@ CMPLXL(long double x, long double y)
 }
 #endif
 
+static int	fpequal(long double, long double) __used;
+static int	cfpequal(long double complex, long double complex) __used;
+static int	cfpequal_cs(long double complex, long double complex,
+		    int) __used;
+static int	cfpequal_tol(long double complex, long double complex,
+		    long double, unsigned int) __used;
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703041007.v24A7kae097986>