fix fesetround error checking
authorSzabolcs Nagy <nsz@port70.net>
Mon, 10 Sep 2018 19:06:21 +0000 (19:06 +0000)
committerRich Felker <dalias@aerifal.cx>
Wed, 10 Oct 2018 20:15:51 +0000 (16:15 -0400)
Rounding modes are not bit flags, but arbitrary non-negative integers.

src/fenv/fesetround.c

index 50e58f11a3f2d7b2cf36650d16433c693d01d176..4e2f164dd5e12d1d866d88e9203c1c1d76f969f6 100644 (file)
@@ -7,18 +7,17 @@ hidden int __fesetround(int);
 
 int fesetround(int r)
 {
-       if (r & ~(
-               FE_TONEAREST
+       if (r != FE_TONEAREST
 #ifdef FE_DOWNWARD
-               |FE_DOWNWARD
+               && r != FE_DOWNWARD
 #endif
 #ifdef FE_UPWARD
-               |FE_UPWARD
+               && r != FE_UPWARD
 #endif
 #ifdef FE_TOWARDZERO
-               |FE_TOWARDZERO
+               && r != FE_TOWARDZERO
 #endif
-               ))
+       )
                return -1;
        return __fesetround(r);
 }