Skip to content
Snippets Groups Projects
Commit 0e58a8f3 authored by Raymond Toy's avatar Raymond Toy
Browse files

Use enum names in switch statement and fix warning.

Instead of using random integers in the switch statement, use the
fdlibm enum values.

Also fix a compiler warning that ret might be used uninitialized.  Fix
this by adding a default case, which should never happen.
parent 82821f30
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,7 @@ fdlibm_setexception(double x, enum FDLIBM_EXCEPTION type) ...@@ -46,7 +46,7 @@ fdlibm_setexception(double x, enum FDLIBM_EXCEPTION type)
double ret; double ret;
switch (type) { switch (type) {
case 0: case FDLIBM_DIVIDE_BY_ZERO:
/* Division by zero. Use the sign of x to get the correct /* Division by zero. Use the sign of x to get the correct
* signed infinity * signed infinity
*/ */
...@@ -54,17 +54,17 @@ fdlibm_setexception(double x, enum FDLIBM_EXCEPTION type) ...@@ -54,17 +54,17 @@ fdlibm_setexception(double x, enum FDLIBM_EXCEPTION type)
ret = copysign(INFINITY, x); ret = copysign(INFINITY, x);
break; break;
case 1: case FDLIBM_UNDERFLOW:
/* Underflow. Use the sign of x to get a signed zero. */ /* Underflow. Use the sign of x to get a signed zero. */
feraiseexcept(FE_UNDERFLOW); feraiseexcept(FE_UNDERFLOW);
ret = copysign(0.0, x); ret = copysign(0.0, x);
break; break;
case 2: case FDLIBM_OVERFLOW:
/* overflow */ /* overflow */
feraiseexcept(FE_OVERFLOW); feraiseexcept(FE_OVERFLOW);
ret = copysign(INFINITY, x); ret = copysign(INFINITY, x);
break; break;
case 3: case FDLIBM_INVALID:
{ {
/* invalid */ /* invalid */
...@@ -88,6 +88,10 @@ fdlibm_setexception(double x, enum FDLIBM_EXCEPTION type) ...@@ -88,6 +88,10 @@ fdlibm_setexception(double x, enum FDLIBM_EXCEPTION type)
break; break;
} }
default:
/* Shouldn't happen! */
ret = 0.0;
break;
} }
return ret; return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment