]> Savannah Git Hosting - gnulib.git/commitdiff
dfa: attempt to pacify Coverity
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 20 May 2024 16:52:52 +0000 (09:52 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 20 May 2024 16:54:46 +0000 (09:54 -0700)
* 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
lib/dfa.c

index a138378822e198410b154d2696a7af80ca7c05e3..997f51f3b5efcc3e45ed7fb813b348bc18bd8685 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-05-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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  <bruno@clisp.org>
 
        Make it easy to generate debug info for libbacktrace on macOS.
index c79afddcd9189b20bb3f209af7cdcd78d3540da0..0ccb1671766ca8ecf606461487ea25c80101ded5 100644 (file)
--- 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;