Add -Wswitch-enum and fix warnings.

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).
This commit is contained in:
Carl Worth 2009-10-25 16:03:45 -07:00
parent c7482b4dce
commit 3bd4a2eaaa
3 changed files with 11 additions and 2 deletions

View file

@ -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) CWARNINGS_FLAGS=$(CXXWARNINGS_FLAGS)
CDEPENDS_FLAGS=`pkg-config --cflags glib-2.0 talloc` CDEPENDS_FLAGS=`pkg-config --cflags glib-2.0 talloc`

View file

@ -152,6 +152,8 @@ notmuch_status_to_string (notmuch_status_t status)
switch (status) { switch (status) {
case NOTMUCH_STATUS_SUCCESS: case NOTMUCH_STATUS_SUCCESS:
return "No error occurred"; return "No error occurred";
case NOTMUCH_STATUS_OUT_OF_MEMORY:
return "Out of memory";
case NOTMUCH_STATUS_XAPIAN_EXCEPTION: case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
return "A Xapian exception occurred"; return "A Xapian exception occurred";
case NOTMUCH_STATUS_FILE_ERROR: case NOTMUCH_STATUS_FILE_ERROR:

View file

@ -267,10 +267,16 @@ add_files_recursive (notmuch_database_t *notmuch,
break; break;
/* Fatal issues. Don't process anymore. */ /* Fatal issues. Don't process anymore. */
case NOTMUCH_STATUS_XAPIAN_EXCEPTION: 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; ret = status;
goto DONE; goto DONE;
default: 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); INTERNAL_ERROR ("add_message returned unexpected value: %d", status);
goto DONE; goto DONE;
} }