diff options
author | Vincent Chen <vincentc@andestech.com> | 2019-05-27 14:17:21 +0800 |
---|---|---|
committer | Greentime Hu <greentime@andestech.com> | 2019-05-31 15:23:25 +0800 |
commit | 8183db10db6377ac58ad048a4c827425a614695c (patch) | |
tree | 254cbc061694aca21fcd6885ced86adb8015189e /include/math-emu/op-common.h | |
parent | a188339ca5a396acc588e5851ed7e19f66b0ebd9 (diff) |
math-emu: Use statement expressions to fix Wshift-count-overflow warning
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>
Diffstat (limited to 'include/math-emu/op-common.h')
-rw-r--r-- | include/math-emu/op-common.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/include/math-emu/op-common.h b/include/math-emu/op-common.h index 6bdf8c61d221..f37d12877754 100644 --- a/include/math-emu/op-common.h +++ b/include/math-emu/op-common.h @@ -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; \ |