From: Paul Eggert <eggert@cs.ucla.edu>
To: Darren Kenny <darren.kenny@oracle.com>
Cc: bug-gnulib@gnu.org
Subject: Re: [PATCH 3/3] lib/regexec: Resolve unused variable
Date: Mon, 23 Aug 2021 14:04:44 -0700 [thread overview]
Message-ID: <be4e2382-cc93-f81d-eaef-61f1accd83a4@cs.ucla.edu> (raw)
In-Reply-To: <m27dgcjvid.fsf@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 1378 bytes --]
On 8/23/21 3:38 AM, Darren Kenny wrote:
> What I did here was to not overwrite the value if DEBUG is set,
> since it appeared to never be checked anyway within the for-loop.
Yes, but although your patch pacified Coverity I still don't understand
exactly why. I'd like to get to the bottom of it before continuing.
> I can only assume (pun not intended) that this
> is ending up as a no-op for our build, which means that Coverity sees it
> as never being read after the for-loop.
I'm working blind here, since Coverity's documentation is secret, which
means you'll need to help out by reading its documentation and/or
running Coverity yourself. Can you do that and let us know the following?
* What values does Coverity define the macros __GNUC__ and
__GNUC_MINOR__ to? Or does it leave these symbols undefined?
* Similarly for _MSC_VER (defined by Microsoft C compilers).
* Does Coverity support the __builtin_unreachable and/or __builtin_trap
functions, like GCC does? (See their use in verify.h.)
* Does Coverity support __assume, like Microsoft C does? (Also see
verify.h.)
* Does Coverity support __has_builtin, like GCC and Clang do? (Again,
see verify.h.)
* Are you compiling with -DGCC_LINT and/or -Dlint?
* Does the attached patch work for you? If not, why not, and what sort
of improvements could be made?
Thanks.
[-- Attachment #2: coverity2.diff --]
[-- Type: text/x-patch, Size: 576 bytes --]
diff --git a/lib/verify.h b/lib/verify.h
index a8ca59b09..3cd71b280 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -305,6 +305,8 @@ template <int w>
--enable-gcc-warnings, which compiles with -Dlint. It's nicer
when 'assume' silences warnings even with older GCCs. */
# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
+#elif defined __COVERITY__
+# define assume(R) ((R) ? (void) 0 : __coverity_panic__ ())
#else
/* Some tools grok NOTREACHED, e.g., Oracle Studio 12.6. */
# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0)
next prev parent reply other threads:[~2021-08-23 21:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-18 15:44 [PATCH 0/3] Some Coverity fixes from GRUB Darren Kenny
2021-06-18 15:44 ` [PATCH 1/3] lib/regexec: Fix possible null-dereference Darren Kenny
2021-08-11 7:28 ` Paul Eggert
2021-08-23 10:05 ` Darren Kenny
2021-08-23 20:09 ` Paul Eggert
2021-08-24 15:11 ` Darren Kenny
2021-08-24 18:52 ` Paul Eggert
2021-06-18 15:44 ` [PATCH 2/3] lib/argp-help: Fix possible dereference of a NULL state Darren Kenny
2021-06-18 17:36 ` Bruno Haible
2021-06-21 9:32 ` Darren Kenny
2021-06-18 15:44 ` [PATCH 3/3] lib/regexec: Resolve unused variable Darren Kenny
2021-08-11 7:24 ` Paul Eggert
2021-08-23 10:38 ` Darren Kenny
2021-08-23 13:00 ` Bruno Haible
2021-08-23 21:04 ` Paul Eggert [this message]
2021-08-06 14:29 ` [PATCH 0/3] Some Coverity fixes from GRUB Darren Kenny
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
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=be4e2382-cc93-f81d-eaef-61f1accd83a4@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=bug-gnulib@gnu.org \
--cc=darren.kenny@oracle.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).