]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.c
Re-enable the warning for unused parameters.
[notmuch] / notmuch.c
index 46c3c63b525f626e18802772a8f0d27dd30f98f9..d98935bd4f73d2045f28466a9ac5156f40c21ac4 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
 
 #include <glib.h> /* g_strdup_printf */
 
+#define unused(x) x __attribute__ ((unused))
+
+/* 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 +271,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)
@@ -386,7 +401,7 @@ count_files (const char *path, int *count)
 }
 
 int
-setup_command (int argc, char *argv[])
+setup_command (unused (int argc), unused (char *argv[]))
 {
     notmuch_database_t *notmuch = NULL;
     char *default_path, *mail_directory = NULL;
@@ -512,7 +527,7 @@ setup_command (int argc, char *argv[])
 }
 
 int
-new_command (int argc, char *argv[])
+new_command (unused (int argc), unused (char *argv[]))
 {
     notmuch_database_t *notmuch;
     const char *mail_directory;
@@ -654,7 +669,7 @@ search_command (int argc, char *argv[])
 }
 
 int
-show_command (int argc, char *argv[])
+show_command (unused (int argc), unused (char *argv[]))
 {
     fprintf (stderr, "Error: show is not implemented yet.\n");
     return 1;
@@ -742,7 +757,8 @@ restore_command (int argc, char *argv[])
     FILE *input;
     notmuch_database_t *notmuch = NULL;
     char *line = NULL;
-    size_t line_size, line_len;
+    size_t line_size;
+    ssize_t line_len;
     regex_t regex;
     int rerr;
     int ret = 0;
@@ -880,7 +896,7 @@ void
 usage (void)
 {
     command_t *command;
-    int i;
+    unsigned int i;
 
     fprintf (stderr, "Usage: notmuch <command> [args...]\n");
     fprintf (stderr, "\n");
@@ -898,7 +914,7 @@ int
 main (int argc, char *argv[])
 {
     command_t *command;
-    int i;
+    unsigned int i;
 
     if (argc == 1)
        return setup_command (0, NULL);