From: Vincent Chen <vincentc@andestech.com>
To: linux-kernel@vger.kernel.org, arnd@arndb.de,
linux-arch@vger.kernel.org, greentime@andestech.com,
green.hu@gmail.com, deanbo422@gmail.com
Cc: vincentc@andestech.com
Subject: [PATCH v2 3/3] math-emu: Use statement expressions to fix Wshift-count-overflow warning
Date: Mon, 27 May 2019 14:17:21 +0800 [thread overview]
Message-ID: <1558937841-4222-4-git-send-email-vincentc@andestech.com> (raw)
In-Reply-To: <1558937841-4222-1-git-send-email-vincentc@andestech.com>
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>
---
Changes in v2
- This is an new patch to fix Wshift-count-overflow warning
include/math-emu/op-2.h | 17 +++++++----------
include/math-emu/op-common.h | 11 ++++++-----
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/include/math-emu/op-2.h b/include/math-emu/op-2.h
index 13a374f..244522b 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 6bdf8c6..f37d128 100644
--- a/include/math-emu/op-common.h
+++ b/include/math-emu/op-common.h
@@ -795,11 +795,12 @@
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; \
--
1.7.1
next prev parent reply other threads:[~2019-05-27 6:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-27 6:17 [PATCH v2 0/3] nds32: Prevent FPU emulator from incorrectly modifying IEX status Vincent Chen
2019-05-27 6:17 ` Vincent Chen
2019-05-27 6:17 ` [PATCH v2 1/3] nds32: Avoid IEX status being incorrectly modified Vincent Chen
2019-05-27 6:17 ` Vincent Chen
2019-05-27 6:17 ` [PATCH v2 2/3] nds32: add new emulations for floating point instruction Vincent Chen
2019-05-27 6:17 ` Vincent Chen
2019-05-27 6:17 ` Vincent Chen [this message]
2019-05-27 6:17 ` [PATCH v2 3/3] math-emu: Use statement expressions to fix Wshift-count-overflow warning Vincent Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1558937841-4222-4-git-send-email-vincentc@andestech.com \
--to=vincentc@andestech.com \
--cc=arnd@arndb.de \
--cc=deanbo422@gmail.com \
--cc=green.hu@gmail.com \
--cc=greentime@andestech.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox