This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Avoid -Wno-write-strings for k_standard.c [committed]


We want to avoid -Wno- options in makefiles as far as possible, by
cleaning up the underlying issues if possible or failing that by using
diagnostic pragmas.  This patch eliminates the use of
-Wno-write-strings for sysdeps/ieee754/k_standard.c by using casts in
the source file to cast away const; those casts are encapsulated in a
macro that also deals with the choice of strings for float / double /
long double functions (for which the logic was previously replicated
many times).

Tested for x86_64; the only change to disassembly of installed
stripped shared libraries was a line number in an assertion.
Committed.

2015-02-26  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/ieee754/k_standard.c (CSTR): New macro.
	(__kernel_standard): Use CSTR macro when setting exc.name.
	* sysdeps/ieee754/Makefile [$(subdir) = math]
	(CFLAGS-k_standard.c): Remove variable.

diff --git a/sysdeps/ieee754/Makefile b/sysdeps/ieee754/Makefile
index 1168406..5c7fc3f 100644
--- a/sysdeps/ieee754/Makefile
+++ b/sysdeps/ieee754/Makefile
@@ -1,5 +1,4 @@
 ifeq ($(subdir),math)
 sysdep_headers += ieee754.h
-CFLAGS-k_standard.c = -Wno-write-strings
 endif
 
diff --git a/sysdeps/ieee754/k_standard.c b/sysdeps/ieee754/k_standard.c
index 7b82cd1..00bedc9 100644
--- a/sysdeps/ieee754/k_standard.c
+++ b/sysdeps/ieee754/k_standard.c
@@ -105,6 +105,10 @@ __kernel_standard(double x, double y, int type)
 	SET_HIGH_WORD(inf,0x7ff00000);	/* set inf to infinite */
 #endif
 
+#define CSTR(func) ((char *) (type < 100				\
+			      ? func					\
+			      : (type < 200 ? func "f" : func "l")))
+
 #ifdef _USE_WRITE
 	(void) fflush(stdout);
 #endif
@@ -116,8 +120,7 @@ __kernel_standard(double x, double y, int type)
 	    case 201:
 		/* acos(|x|>1) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "acos" : (type < 200
-						  ? "acosf" : "acosl");;
+		exc.name = CSTR ("acos");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -136,8 +139,7 @@ __kernel_standard(double x, double y, int type)
 	    case 202:
 		/* asin(|x|>1) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "asin" : (type < 200
-						  ? "asinf" : "asinl");
+		exc.name = CSTR ("asin");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -158,8 +160,7 @@ __kernel_standard(double x, double y, int type)
 		exc.arg1 = y;
 		exc.arg2 = x;
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "atan2" : (type < 200
-						   ? "atan2f" : "atan2l");
+		exc.name = CSTR ("atan2");
 		assert (_LIB_VERSION == _SVID_);
 		exc.retval = HUGE;
 		if(_LIB_VERSION == _POSIX_)
@@ -176,8 +177,7 @@ __kernel_standard(double x, double y, int type)
 	    case 204:
 		/* hypot(finite,finite) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "hypot" : (type < 200
-						   ? "hypotf" : "hypotl");
+		exc.name = CSTR ("hypot");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -193,8 +193,7 @@ __kernel_standard(double x, double y, int type)
 	    case 205:
 		/* cosh(finite) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "cosh" : (type < 200
-						  ? "coshf" : "coshl");
+		exc.name = CSTR ("cosh");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -210,8 +209,7 @@ __kernel_standard(double x, double y, int type)
 	    case 206:
 		/* exp(finite) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "exp" : (type < 200
-						 ? "expf" : "expl");
+		exc.name = CSTR ("exp");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -227,8 +225,7 @@ __kernel_standard(double x, double y, int type)
 	    case 207:
 		/* exp(finite) underflow */
 		exc.type = UNDERFLOW;
-		exc.name = type < 100 ? "exp" : (type < 200
-						 ? "expf" : "expl");
+		exc.name = CSTR ("exp");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
@@ -241,7 +238,7 @@ __kernel_standard(double x, double y, int type)
 	    case 208:
 		/* y0(0) = -inf */
 		exc.type = DOMAIN;	/* should be SING for IEEE */
-		exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l");
+		exc.name = CSTR ("y0");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -260,7 +257,7 @@ __kernel_standard(double x, double y, int type)
 	    case 209:
 		/* y0(x<0) = NaN */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l");
+		exc.name = CSTR ("y0");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -279,7 +276,7 @@ __kernel_standard(double x, double y, int type)
 	    case 210:
 		/* y1(0) = -inf */
 		exc.type = DOMAIN;	/* should be SING for IEEE */
-		exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l");
+		exc.name = CSTR ("y1");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -298,7 +295,7 @@ __kernel_standard(double x, double y, int type)
 	    case 211:
 		/* y1(x<0) = NaN */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l");
+		exc.name = CSTR ("y1");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -317,7 +314,7 @@ __kernel_standard(double x, double y, int type)
 	    case 212:
 		/* yn(n,0) = -inf */
 		exc.type = DOMAIN;	/* should be SING for IEEE */
-		exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl");
+		exc.name = CSTR ("yn");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -338,7 +335,7 @@ __kernel_standard(double x, double y, int type)
 	    case 213:
 		/* yn(x<0) = NaN */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl");
+		exc.name = CSTR ("yn");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -357,8 +354,7 @@ __kernel_standard(double x, double y, int type)
 	    case 214:
 		/* lgamma(finite) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "lgamma" : (type < 200
-						    ? "lgammaf" : "lgammal");
+		exc.name = CSTR ("lgamma");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -374,8 +370,7 @@ __kernel_standard(double x, double y, int type)
 	    case 215:
 		/* lgamma(-integer) or lgamma(0) */
 		exc.type = SING;
-		exc.name = type < 100 ? "lgamma" : (type < 200
-						    ? "lgammaf" : "lgammal");
+		exc.name = CSTR ("lgamma");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -394,7 +389,7 @@ __kernel_standard(double x, double y, int type)
 	    case 216:
 		/* log(0) */
 		exc.type = SING;
-		exc.name = type < 100 ? "log" : (type < 200 ? "logf" : "logl");
+		exc.name = CSTR ("log");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -413,7 +408,7 @@ __kernel_standard(double x, double y, int type)
 	    case 217:
 		/* log(x<0) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "log" : (type < 200 ? "logf" : "logl");
+		exc.name = CSTR ("log");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -432,8 +427,7 @@ __kernel_standard(double x, double y, int type)
 	    case 218:
 		/* log10(0) */
 		exc.type = SING;
-		exc.name = type < 100 ? "log10" : (type < 200
-						   ? "log10f" : "log10l");
+		exc.name = CSTR ("log10");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -452,8 +446,7 @@ __kernel_standard(double x, double y, int type)
 	    case 219:
 		/* log10(x<0) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "log10" : (type < 200
-						   ? "log10f" : "log10l");
+		exc.name = CSTR ("log10");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -473,7 +466,7 @@ __kernel_standard(double x, double y, int type)
 		/* pow(0.0,0.0) */
 		/* error only if _LIB_VERSION == _SVID_ */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
+		exc.name = CSTR ("pow");
 		exc.retval = zero;
 		if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
 		else if (!matherr(&exc)) {
@@ -486,7 +479,7 @@ __kernel_standard(double x, double y, int type)
 	    case 221:
 		/* pow(x,y) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
+		exc.name = CSTR ("pow");
 		if (_LIB_VERSION == _SVID_) {
 		  exc.retval = HUGE;
 		  y *= 0.5;
@@ -507,7 +500,7 @@ __kernel_standard(double x, double y, int type)
 	    case 222:
 		/* pow(x,y) underflow */
 		exc.type = UNDERFLOW;
-		exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
+		exc.name = CSTR ("pow");
 		exc.retval =  zero;
 		y *= 0.5;
 		if (x < zero && __rint (y) != y)
@@ -523,7 +516,7 @@ __kernel_standard(double x, double y, int type)
 	    case 223:
 		/* -0**neg */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
+		exc.name = CSTR ("pow");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = zero;
 		else
@@ -542,7 +535,7 @@ __kernel_standard(double x, double y, int type)
 	    case 243:
 		/* +0**neg */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
+		exc.name = CSTR ("pow");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = zero;
 		else
@@ -561,7 +554,7 @@ __kernel_standard(double x, double y, int type)
 	    case 224:
 		/* neg**non-integral */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
+		exc.name = CSTR ("pow");
 		if (_LIB_VERSION == _SVID_)
 		    exc.retval = zero;
 		else
@@ -580,8 +573,7 @@ __kernel_standard(double x, double y, int type)
 	    case 225:
 		/* sinh(finite) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "sinh" : (type < 200
-						  ? "sinhf" : "sinhl");
+		exc.name = CSTR ("sinh");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = ( (x>zero) ? HUGE : -HUGE);
 		else
@@ -597,8 +589,7 @@ __kernel_standard(double x, double y, int type)
 	    case 226:
 		/* sqrt(x<0) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "sqrt" : (type < 200
-						  ? "sqrtf" : "sqrtl");
+		exc.name = CSTR ("sqrt");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = zero;
 		else
@@ -617,8 +608,7 @@ __kernel_standard(double x, double y, int type)
 	    case 227:
 		/* fmod(x,0) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "fmod" : (type < 200
-						  ? "fmodf" : "fmodl");
+		exc.name = CSTR ("fmod");
 		if (_LIB_VERSION == _SVID_)
 		    exc.retval = x;
 		else
@@ -637,9 +627,7 @@ __kernel_standard(double x, double y, int type)
 	    case 228:
 		/* remainder(x,0) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "remainder" : (type < 200
-						       ? "remainderf"
-						       : "remainderl");
+		exc.name = CSTR ("remainder");
 		exc.retval = zero/zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
@@ -655,8 +643,7 @@ __kernel_standard(double x, double y, int type)
 	    case 229:
 		/* acosh(x<1) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "acosh" : (type < 200
-						   ? "acoshf" : "acoshl");
+		exc.name = CSTR ("acosh");
 		exc.retval = zero/zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
@@ -672,8 +659,7 @@ __kernel_standard(double x, double y, int type)
 	    case 230:
 		/* atanh(|x|>1) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "atanh" : (type < 200
-						   ? "atanhf" : "atanhl");
+		exc.name = CSTR ("atanh");
 		exc.retval = zero/zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
@@ -689,8 +675,7 @@ __kernel_standard(double x, double y, int type)
 	    case 231:
 		/* atanh(|x|=1) */
 		exc.type = SING;
-		exc.name = type < 100 ? "atanh" : (type < 200
-						   ? "atanhf" : "atanhl");
+		exc.name = CSTR ("atanh");
 		exc.retval = x/zero;	/* sign(x)*inf */
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
@@ -706,8 +691,7 @@ __kernel_standard(double x, double y, int type)
 	    case 232:
 		/* scalb overflow; SVID also returns +-HUGE_VAL */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "scalb" : (type < 200
-						   ? "scalbf" : "scalbl");
+		exc.name = CSTR ("scalb");
 		exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
@@ -720,8 +704,7 @@ __kernel_standard(double x, double y, int type)
 	    case 233:
 		/* scalb underflow */
 		exc.type = UNDERFLOW;
-		exc.name = type < 100 ? "scalb" : (type < 200
-						   ? "scalbf" : "scalbl");
+		exc.name = CSTR ("scalb");
 		exc.retval = __copysign(zero,x);
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
@@ -734,7 +717,7 @@ __kernel_standard(double x, double y, int type)
 	    case 234:
 		/* j0(|x|>X_TLOSS) */
 		exc.type = TLOSS;
-		exc.name = type < 100 ? "j0" : (type < 200 ? "j0f" : "j0l");
+		exc.name = CSTR ("j0");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 			__set_errno (ERANGE);
@@ -751,7 +734,7 @@ __kernel_standard(double x, double y, int type)
 	    case 235:
 		/* y0(x>X_TLOSS) */
 		exc.type = TLOSS;
-		exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l");
+		exc.name = CSTR ("y0");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 			__set_errno (ERANGE);
@@ -768,7 +751,7 @@ __kernel_standard(double x, double y, int type)
 	    case 236:
 		/* j1(|x|>X_TLOSS) */
 		exc.type = TLOSS;
-		exc.name = type < 100 ? "j1" : (type < 200 ? "j1f" : "j1l");
+		exc.name = CSTR ("j1");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 			__set_errno (ERANGE);
@@ -785,7 +768,7 @@ __kernel_standard(double x, double y, int type)
 	    case 237:
 		/* y1(x>X_TLOSS) */
 		exc.type = TLOSS;
-		exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l");
+		exc.name = CSTR ("y1");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 			__set_errno (ERANGE);
@@ -802,7 +785,7 @@ __kernel_standard(double x, double y, int type)
 	    case 238:
 		/* jn(|x|>X_TLOSS) */
 		exc.type = TLOSS;
-		exc.name = type < 100 ? "jn" : (type < 200 ? "jnf" : "jnl");
+		exc.name = CSTR ("jn");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 			__set_errno (ERANGE);
@@ -819,7 +802,7 @@ __kernel_standard(double x, double y, int type)
 	    case 239:
 		/* yn(x>X_TLOSS) */
 		exc.type = TLOSS;
-		exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl");
+		exc.name = CSTR ("yn");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 			__set_errno (ERANGE);
@@ -836,8 +819,7 @@ __kernel_standard(double x, double y, int type)
 	    case 240:
 		/* tgamma(finite) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "tgamma" : (type < 200
-						   ? "tgammaf" : "tgammal");
+		exc.name = CSTR ("tgamma");
 		exc.retval = __copysign (HUGE_VAL, x);
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
@@ -850,8 +832,7 @@ __kernel_standard(double x, double y, int type)
 	    case 241:
 		/* tgamma(-integer) */
 		exc.type = SING;
-		exc.name = type < 100 ? "tgamma" : (type < 200
-						   ? "tgammaf" : "tgammal");
+		exc.name = CSTR ("tgamma");
 		exc.retval = NAN;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
@@ -869,7 +850,7 @@ __kernel_standard(double x, double y, int type)
 		/* pow(NaN,0.0) */
 		/* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
+		exc.name = CSTR ("pow");
 		exc.retval = x;
 		if (_LIB_VERSION == _IEEE_ ||
 		    _LIB_VERSION == _POSIX_) exc.retval = 1.0;
@@ -883,8 +864,7 @@ __kernel_standard(double x, double y, int type)
 	    case 244:
 		/* exp(finite) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "exp2" : (type < 200
-						  ? "exp2f" : "exp2l");
+		exc.name = CSTR ("exp2");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -900,8 +880,7 @@ __kernel_standard(double x, double y, int type)
 	    case 245:
 		/* exp(finite) underflow */
 		exc.type = UNDERFLOW;
-		exc.name = type < 100 ? "exp2" : (type < 200
-						  ? "exp2f" : "exp2l");
+		exc.name = CSTR ("exp2");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
@@ -915,8 +894,7 @@ __kernel_standard(double x, double y, int type)
 	    case 246:
 		/* exp(finite) overflow */
 		exc.type = OVERFLOW;
-		exc.name = type < 100 ? "exp10" : (type < 200
-						   ? "exp10f" : "exp10l");
+		exc.name = CSTR ("exp10");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = HUGE;
 		else
@@ -932,8 +910,7 @@ __kernel_standard(double x, double y, int type)
 	    case 247:
 		/* exp(finite) underflow */
 		exc.type = UNDERFLOW;
-		exc.name = type < 100 ? "exp10" : (type < 200
-						   ? "exp10f" : "exp10l");
+		exc.name = CSTR ("exp10");
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
@@ -946,8 +923,7 @@ __kernel_standard(double x, double y, int type)
 	    case 248:
 		/* log2(0) */
 		exc.type = SING;
-		exc.name = type < 100 ? "log2" : (type < 200
-						   ? "log2f" : "log2l");
+		exc.name = CSTR ("log2");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -963,8 +939,7 @@ __kernel_standard(double x, double y, int type)
 	    case 249:
 		/* log2(x<0) */
 		exc.type = DOMAIN;
-		exc.name = type < 100 ? "log2" : (type < 200
-						   ? "log2f" : "log2l");
+		exc.name = CSTR ("log2");
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = -HUGE;
 		else
@@ -980,8 +955,7 @@ __kernel_standard(double x, double y, int type)
 	    case 250:
 		/* tgamma(+-0) */
 		exc.type = SING;
-		exc.name = type < 100 ? "tgamma" : (type < 200
-						    ? "tgammaf" : "tgammal");
+		exc.name = CSTR ("tgamma");
 		exc.retval = __copysign (HUGE_VAL, x);
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]