From 8183db10db6377ac58ad048a4c827425a614695c Mon Sep 17 00:00:00 2001 From: Vincent Chen Date: Mon, 27 May 2019 14:17:21 +0800 Subject: 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 Acked-by: Greentime Hu Signed-off-by: Greentime Hu --- include/math-emu/op-2.h | 17 +++++++---------- include/math-emu/op-common.h | 11 ++++++----- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'include/math-emu') diff --git a/include/math-emu/op-2.h b/include/math-emu/op-2.h index 13a374f51a22..244522b02076 100644 --- a/include/math-emu/op-2.h +++ b/include/math-emu/op-2.h @@ -567,16 +567,13 @@ */ #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 { \ 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; \ -- cgit v1.2.3-59-g8ed1b