From: Anton Johansson via <qemu-devel@nongnu.org>
To: qemu-devel@nongnu.org
Cc: ale@rev.ng, bcain@quicinc.com, richard.henderson@linaro.org,
pbonzini@redhat.com, peter.maydell@linaro.org
Subject: [PATCH] target/hexagon: Emit comments to silence coverity
Date: Fri, 2 Jun 2023 21:06:59 +0200 [thread overview]
Message-ID: <20230602190659.6342-1-anjo@rev.ng> (raw)
idef-parser emits safety checks around shifts and extensions to deal
with shift amounts larger than the TCGv size and extensions of 0-bit
regions. These safety checks sometimes result in dead branches, which
coverity detects and warns about.
This commits silences these dead code warnings in emitted code by using
markup comments.
Signed-off-by: Anton Johansson <anjo@rev.ng>
---
target/hexagon/idef-parser/parser-helpers.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/target/hexagon/idef-parser/parser-helpers.c b/target/hexagon/idef-parser/parser-helpers.c
index 7b5ebafec2..59ef018d44 100644
--- a/target/hexagon/idef-parser/parser-helpers.c
+++ b/target/hexagon/idef-parser/parser-helpers.c
@@ -636,6 +636,7 @@ static void gen_asl_op(Context *c, YYLTYPE *locp, unsigned bit_width,
} break;
case REG_IMM: {
OUT(c, locp, "if (", op2, " >= ", &bit_width, ") {\n");
+ OUT(c, locp, "/* coverity[dead_error_condition] */\n");
OUT(c, locp, "tcg_gen_movi_", bit_suffix, "(", res, ", 0);\n");
OUT(c, locp, "} else {\n");
OUT(c, locp, "tcg_gen_shli_", bit_suffix,
@@ -691,7 +692,8 @@ static void gen_asr_op(Context *c, YYLTYPE *locp, unsigned bit_width,
gen_c_int_type(c, locp, bit_width, signedness);
OUT(c, locp, " shift = ", op2, ";\n");
OUT(c, locp, "if (", op2, " >= ", &bit_width, ") {\n");
- OUT(c, locp, " shift = ", &bit_width, " - 1;\n");
+ OUT(c, locp, "/* coverity[dead_error_condition] */\n");
+ OUT(c, locp, "shift = ", &bit_width, " - 1;\n");
OUT(c, locp, "}\n");
OUT(c, locp, "tcg_gen_sari_", bit_suffix,
"(", res, ", ", op1, ", shift);\n}\n");
@@ -1060,6 +1062,7 @@ static HexValue gen_extend_imm_width_op(Context *c,
");\n");
if (need_guarding) {
OUT(c, locp, "} else {\n");
+ OUT(c, locp, "/* coverity[dead_error_condition] */\n");
OUT(c, locp, "tcg_gen_movi_i", &dst_width, "(", &res,
", 0);\n");
OUT(c, locp, "}\n");
--
2.39.1
reply other threads:[~2023-06-02 19:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230602190659.6342-1-anjo@rev.ng \
--to=qemu-devel@nongnu.org \
--cc=ale@rev.ng \
--cc=anjo@rev.ng \
--cc=bcain@quicinc.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=richard.henderson@linaro.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;
as well as URLs for NNTP newsgroup(s).