]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
math-emu: Use statement expressions to fix Wshift-count-overflow warning
authorVincent Chen <vincentc@andestech.com>
Mon, 27 May 2019 06:17:21 +0000 (14:17 +0800)
committerGreentime Hu <greentime@andestech.com>
Fri, 31 May 2019 07:23:25 +0000 (15:23 +0800)
To avoid "shift count >= width of type" warning, using statement
expressions to implement the conditional controlling before constant shift

The modification in op-2.h is taken from the glibc
commit 'sysdeps/unix/sysv/lin ("fe0b1e854ad32")'.

Signed-off-by: Vincent Chen <vincentc@andestech.com>
Acked-by: Greentime Hu <greentime@andestech.com>
Signed-off-by: Greentime Hu <greentime@andestech.com>
include/math-emu/op-2.h
include/math-emu/op-common.h

index 13a374f51a225bf77f9b19189a1145001fae3c5a..244522b020769cb96aeadf7cb64823b3493088ea 100644 (file)
  */
 
 #define _FP_FRAC_ASSEMBLE_2(r, X, rsize)       \
-  do {                                         \
-    if (rsize <= _FP_W_TYPE_SIZE)              \
-      r = X##_f0;                              \
-    else                                       \
-      {                                                \
-       r = X##_f1;                             \
-       r <<= _FP_W_TYPE_SIZE;                  \
-       r += X##_f0;                            \
-      }                                                \
-  } while (0)
+       (void) (((rsize) <= _FP_W_TYPE_SIZE)    \
+               ? ({ (r) = X##_f0; })           \
+               : ({                            \
+                    (r) = X##_f1;              \
+                    (r) <<= _FP_W_TYPE_SIZE;   \
+                    (r) += X##_f0;             \
+                   }))
 
 #define _FP_FRAC_DISASSEMBLE_2(X, r, rsize)                            \
   do {                                                                 \
index 6bdf8c61d221f7267914974958f96f2cc2156460..f37d12877754b05a3f534097d7fd7c957326c94e 100644 (file)
@@ -795,11 +795,12 @@ do {                                                                      \
          ur_ = (unsigned rtype) -r;                                    \
        else                                                            \
          ur_ = (unsigned rtype) r;                                     \
-       if (rsize <= _FP_W_TYPE_SIZE)                                   \
-         __FP_CLZ(X##_e, ur_);                                         \
-       else                                                            \
-         __FP_CLZ_2(X##_e, (_FP_W_TYPE)(ur_ >> _FP_W_TYPE_SIZE),       \
-                    (_FP_W_TYPE)ur_);                                  \
+       (void) (((rsize) <= _FP_W_TYPE_SIZE)                            \
+               ? ({ __FP_CLZ(X##_e, ur_); })                           \
+               : ({                                                    \
+                    __FP_CLZ_2(X##_e, (_FP_W_TYPE)(ur_ >> _FP_W_TYPE_SIZE),  \
+                                                           (_FP_W_TYPE)ur_); \
+                 }));                                                  \
        if (rsize < _FP_W_TYPE_SIZE)                                    \
                X##_e -= (_FP_W_TYPE_SIZE - rsize);                     \
        X##_e = rsize - X##_e - 1;                                      \