From: Paul Eggert Date: Mon, 20 May 2024 16:52:52 +0000 (-0700) Subject: dfa: attempt to pacify Coverity X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a516e451b61aa40e2d8d9f643d537495a47d8e2e;p=gnulib.git 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. --- 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;