]> git.notmuchmail.org Git - notmuch/commitdiff
Add -Wswitch-enum and fix warnings.
authorCarl Worth <cworth@cworth.org>
Sun, 25 Oct 2009 23:03:45 +0000 (16:03 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 25 Oct 2009 23:03:45 +0000 (16:03 -0700)
Having to enumerate all the enum values at every switch is annoying,
but this warning actually found a bug, (missing support for
NOTMUCH_STATUS_OUT_OF_MEMORY in notmuch_status_to_string).

Makefile
database.cc
notmuch.c

index 894874ae6f2d3502a5f7eaaf3424e3511e83ba05..f105761625ce8b48cfb925a397ee4c42a506d903 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 PROGS=notmuch
 
 PROGS=notmuch
 
-CXXWARNINGS_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings
+CXXWARNINGS_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings \
+-Wswitch-enum
 CWARNINGS_FLAGS=$(CXXWARNINGS_FLAGS)
 
 CDEPENDS_FLAGS=`pkg-config --cflags glib-2.0 talloc`
 CWARNINGS_FLAGS=$(CXXWARNINGS_FLAGS)
 
 CDEPENDS_FLAGS=`pkg-config --cflags glib-2.0 talloc`
index e1ea324d5163466ad784939d7e23830171026475..b1b95e9dd6fdf02dc3b1d1917f1cddb0adbf2e7a 100644 (file)
@@ -152,6 +152,8 @@ notmuch_status_to_string (notmuch_status_t status)
     switch (status) {
     case NOTMUCH_STATUS_SUCCESS:
        return "No error occurred";
     switch (status) {
     case NOTMUCH_STATUS_SUCCESS:
        return "No error occurred";
+    case NOTMUCH_STATUS_OUT_OF_MEMORY:
+       return "Out of memory";
     case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
        return "A Xapian exception occurred";
     case NOTMUCH_STATUS_FILE_ERROR:
     case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
        return "A Xapian exception occurred";
     case NOTMUCH_STATUS_FILE_ERROR:
index ef93ded9b3a848297e1d72c960801eb528a48500..fbd773d710fdc74e9549af70532f0537c311e8d1 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -267,10 +267,16 @@ add_files_recursive (notmuch_database_t *notmuch,
                        break;
                    /* Fatal issues. Don't process anymore. */
                    case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
                        break;
                    /* Fatal issues. Don't process anymore. */
                    case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
-                       fprintf (stderr, "A Xapian error was encountered. Halting processing.\n");
+                   case NOTMUCH_STATUS_OUT_OF_MEMORY:
+                       fprintf (stderr, "Error: %s. Halting processing.\n",
+                                notmuch_status_to_string (status));
                        ret = status;
                        goto DONE;
                    default:
                        ret = status;
                        goto DONE;
                    default:
+                   case NOTMUCH_STATUS_FILE_ERROR:
+                   case NOTMUCH_STATUS_NULL_POINTER:
+                   case NOTMUCH_STATUS_TAG_TOO_LONG:
+                   case NOTMUCH_STATUS_LAST_STATUS:
                        INTERNAL_ERROR ("add_message returned unexpected value: %d",  status);
                        goto DONE;
                }
                        INTERNAL_ERROR ("add_message returned unexpected value: %d",  status);
                        goto DONE;
                }