From a516e451b61aa40e2d8d9f643d537495a47d8e2e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 20 May 2024 09:52:52 -0700 Subject: [PATCH] dfa: attempt to pacify Coverity MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lib/dfa.c (lex): Use ‘assume’ rather than ‘abort’, to try to pacify Coverity. (maybe_disable_superset_dfa): Use ‘assume’ here too, for consistency. Using ‘assume’ should make the code a tiny bit faster, though at the cost of having undefined behavior instead of nicely aborting. --- ChangeLog | 9 +++++++++ lib/dfa.c | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a138378822..997f51f3b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-05-20 Paul Eggert + + dfa: attempt to pacify Coverity + * lib/dfa.c (lex): Use ‘assume’ rather than ‘abort’, + to try to pacify Coverity. + (maybe_disable_superset_dfa): Use ‘assume’ here too, for consistency. + Using ‘assume’ should make the code a tiny bit faster, though + at the cost of having undefined behavior instead of nicely aborting. + 2024-05-20 Bruno Haible Make it easy to generate debug info for libbacktrace on macOS. diff --git a/lib/dfa.c b/lib/dfa.c index c79afddcd9..0ccb167176 100644 --- a/lib/dfa.c +++ b/lib/dfa.c @@ -1221,8 +1221,7 @@ lex (struct dfa *dfa) { /* This loop should consume at most a backslash and some other character. */ - if (2 <= i) - abort (); + assume (i < 2); if (! dfa->lex.left) return dfa->lex.lasttok = END; @@ -3727,7 +3726,7 @@ maybe_disable_superset_dfa (struct dfa *d) { case ANYCHAR: /* Lowered. */ - abort (); + assume (false); case BACKREF: have_backref = true; break; -- 2.39.5