X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.c;h=c5fef0e800961782a1941d2999a4be6f4c6146c0;hp=f16192fb6b5f2a1fea206fde94b202e7eb409aca;hb=be9e3ee3132457ea5936bd1225294bdfe3949a4c;hpb=a8ae2cd214bca3c89b0f9a5566c227459eec40f5 diff --git a/notmuch.c b/notmuch.c index f16192fb..c5fef0e8 100644 --- a/notmuch.c +++ b/notmuch.c @@ -43,6 +43,20 @@ #include /* g_strdup_printf */ +/* There's no point in continuing when we've detected that we've done + * something wrong internally (as opposed to the user passing in a + * bogus value). + * + * Note that __location__ comes from talloc.h. + */ +#define INTERNAL_ERROR(format, ...) \ + do { \ + fprintf(stderr, \ + "Internal error: " format " (%s)\n", \ + ##__VA_ARGS__, __location__); \ + exit (1); \ + } while (0) + #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0])) typedef int (*command_function_t) (int argc, char *argv[]); @@ -255,8 +269,7 @@ add_files_recursive (notmuch_database_t *notmuch, ret = status; goto DONE; default: - fprintf (stderr, "Internal error: add_message returned unexpected value: %d\n", status); - ret = status; + INTERNAL_ERROR ("add_message returned unexpected value: %d", status); goto DONE; } if (state->processed_files % 1000 == 0) @@ -818,7 +831,8 @@ restore_command (int argc, char *argv[]) notmuch_status_to_string (status)); } } else { - fprintf (stderr, "%s ", tag); + fprintf (stderr, "%s%s", + tag == tags ? "" : " ", tag); } }