groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 12/13: [grn]: Slightly refactor.


From: G. Branden Robinson
Subject: [groff] 12/13: [grn]: Slightly refactor.
Date: Sat, 16 Apr 2022 04:37:33 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit d247763cfe9e71fd453ac828d35ab8b207c962fd
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Apr 15 09:09:26 2022 +1000

    [grn]: Slightly refactor.
    
    * src/preproc/grn/hdb.cpp (DBGetType): Lower fatal diagnostics to errors
      when encounting invalid element type characters.  Return a value
      interpreted by our caller as an error indication instead.  Helps
      compilers determine that we're not implicitly falling through our
      cases.  Addresses "-Wimplicit-fallthrough" warnings from GCC.
---
 ChangeLog               |  9 +++++++++
 src/preproc/grn/hdb.cpp | 17 ++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 133ec36a..0d3d8ee2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-04-15  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/grn/hdb.cpp (DBGetType): Lower fatal diagnostics
+       to errors when encounting invalid element type characters.
+       Return a value interpreted by our caller as an error indication
+       instead.  Helps compilers determine that we're not implicitly
+       falling through our cases.  Addresses "-Wimplicit-fallthrough"
+       warnings from GCC.
+
 2022-04-15  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/preproc/grn/hdb.cpp (DBRead): Add more validity checking.
diff --git a/src/preproc/grn/hdb.cpp b/src/preproc/grn/hdb.cpp
index e8cd9675..9ba3eaa8 100644
--- a/src/preproc/grn/hdb.cpp
+++ b/src/preproc/grn/hdb.cpp
@@ -325,9 +325,9 @@ DBGetType(char *s)
     case 'R':
       return (CENTRIGHT);
     default:
-      fatal_with_file_and_line(gremlinfile, lineno,
+      error_with_file_and_line(gremlinfile, lineno,
                               "unknown element type '%1'", s);
-      // fatal_with_file_and_line() does not return
+      return -1;
     }
   case 'B':
     switch (s[3]) {
@@ -338,9 +338,9 @@ DBGetType(char *s)
     case 'R':
       return (BOTRIGHT);
     default:
-      fatal_with_file_and_line(gremlinfile, lineno,
+      error_with_file_and_line(gremlinfile, lineno,
                               "unknown element type '%1'", s);
-      // fatal_with_file_and_line() does not return
+      return -1;
     }
   case 'T':
     switch (s[3]) {
@@ -351,16 +351,15 @@ DBGetType(char *s)
     case 'R':
       return (TOPRIGHT);
     default:
-      fatal_with_file_and_line(gremlinfile, lineno,
+      error_with_file_and_line(gremlinfile, lineno,
                               "unknown element type '%1'", s);
-      // fatal_with_file_and_line() does not return
+      return -1;
     }
   default:
-    fatal_with_file_and_line(gremlinfile, lineno,
+    error_with_file_and_line(gremlinfile, lineno,
                             "unknown element type '%1'", s);
+    return -1;
   }
-
-  return 0;                            /* never reached */
 }
 
 #ifdef UW_FASTSCAN



reply via email to

[Prev in Thread] Current Thread [Next in Thread]