From a9a9e374e2567caad8601d1781a3b0af8a3dde13 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 19 Jan 2012 17:29:19 -0500 Subject: Silence buildbot warnings about unused results This ignores the results of the two writes in sigint handlers even harder than before. While my libc lacks the declarations that trigger these warnings, this can be tested by adding the following to notmuch.h: __attribute__((warn_unused_result)) ssize_t write(int fd, const void *buf, size_t count); --- notmuch-tag.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'notmuch-tag.c') diff --git a/notmuch-tag.c b/notmuch-tag.c index 292c5da..44fd61f 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -26,7 +26,12 @@ static void handle_sigint (unused (int sig)) { static char msg[] = "Stopping... \n"; - (void) write(2, msg, sizeof(msg)-1); + + /* This write is "opportunistic", so it's okay to ignore the + * result. It is not required for correctness, and if it does + * fail or produce a short write, we want to get out of the signal + * handler as quickly as possible, not retry it. */ + IGNORE_RESULT (write (2, msg, sizeof(msg)-1)); interrupted = 1; } -- cgit v1.2.3 From cc3756aabed5d6e50a481a5d38a5859754206be2 Mon Sep 17 00:00:00 2001 From: Dmitry Kurochkin Date: Sat, 28 Jan 2012 12:02:33 +0400 Subject: tag: remove unused attribute from notmuch_tag_command() arguments Argc and argv arguments are used in notmuch_tag_command() function. So unused attribute is not appropriate for them. --- notmuch-tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'notmuch-tag.c') diff --git a/notmuch-tag.c b/notmuch-tag.c index 44fd61f..36b9b09 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -111,7 +111,7 @@ _optimize_tag_query (void *ctx, const char *orig_query_string, char *argv[], } int -notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[])) +notmuch_tag_command (void *ctx, int argc, char *argv[]) { int *add_tags, *remove_tags; int add_tags_count = 0; -- cgit v1.2.3 From 8e3ff8fb03dc647f1daea4665c35a2214473ced8 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Tue, 27 Mar 2012 00:04:09 +0300 Subject: cli: refactor "notmuch tag" data structures for tagging operations To simplify code, keep all tagging operations in a single array instead of separate add and remove arrays. Apply tag changes in the order specified on the command line, instead of first removing and then adding the tags. This results in a minor functional change: If a tag is both added and removed, the last specified operation is now used. Previously the tag was always added. Change the relevant test to reflect the new behaviour. Signed-off-by: Jani Nikula --- notmuch-tag.c | 83 ++++++++++++++++++++++++++++------------------------------- test/tagging | 2 +- 2 files changed, 40 insertions(+), 45 deletions(-) (limited to 'notmuch-tag.c') diff --git a/notmuch-tag.c b/notmuch-tag.c index 36b9b09..0a6b140 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -53,10 +53,14 @@ _escape_tag (char *buf, const char *tag) return buf; } +typedef struct { + const char *tag; + notmuch_bool_t remove; +} tag_operation_t; + static char * -_optimize_tag_query (void *ctx, const char *orig_query_string, char *argv[], - int *add_tags, int add_tags_count, - int *remove_tags, int remove_tags_count) +_optimize_tag_query (void *ctx, const char *orig_query_string, + const tag_operation_t *tag_ops) { /* This is subtler than it looks. Xapian ignores the '-' operator * at the beginning both queries and parenthesized groups and, @@ -71,15 +75,16 @@ _optimize_tag_query (void *ctx, const char *orig_query_string, char *argv[], int i; unsigned int max_tag_len = 0; + /* Don't optimize if there are no tag changes. */ + if (tag_ops[0].tag == NULL) + return talloc_strdup (ctx, orig_query_string); + /* Allocate a buffer for escaping tags. This is large enough to * hold a fully escaped tag with every character doubled plus * enclosing quotes and a NUL. */ - for (i = 0; i < add_tags_count; i++) - if (strlen (argv[add_tags[i]] + 1) > max_tag_len) - max_tag_len = strlen (argv[add_tags[i]] + 1); - for (i = 0; i < remove_tags_count; i++) - if (strlen (argv[remove_tags[i]] + 1) > max_tag_len) - max_tag_len = strlen (argv[remove_tags[i]] + 1); + for (i = 0; tag_ops[i].tag; i++) + if (strlen (tag_ops[i].tag) > max_tag_len) + max_tag_len = strlen (tag_ops[i].tag); escaped = talloc_array(ctx, char, max_tag_len * 2 + 3); if (!escaped) return NULL; @@ -90,16 +95,11 @@ _optimize_tag_query (void *ctx, const char *orig_query_string, char *argv[], else query_string = talloc_asprintf (ctx, "( %s ) and (", orig_query_string); - for (i = 0; i < add_tags_count && query_string; i++) { + for (i = 0; tag_ops[i].tag && query_string; i++) { query_string = talloc_asprintf_append_buffer ( - query_string, "%snot tag:%s", join, - _escape_tag (escaped, argv[add_tags[i]] + 1)); - join = " or "; - } - for (i = 0; i < remove_tags_count && query_string; i++) { - query_string = talloc_asprintf_append_buffer ( - query_string, "%stag:%s", join, - _escape_tag (escaped, argv[remove_tags[i]] + 1)); + query_string, "%s%stag:%s", join, + tag_ops[i].remove ? "" : "not ", + _escape_tag (escaped, tag_ops[i].tag)); join = " or "; } @@ -113,9 +113,8 @@ _optimize_tag_query (void *ctx, const char *orig_query_string, char *argv[], int notmuch_tag_command (void *ctx, int argc, char *argv[]) { - int *add_tags, *remove_tags; - int add_tags_count = 0; - int remove_tags_count = 0; + tag_operation_t *tag_ops; + int tag_ops_count = 0; char *query_string; notmuch_config_t *config; notmuch_database_t *notmuch; @@ -133,35 +132,33 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) action.sa_flags = SA_RESTART; sigaction (SIGINT, &action, NULL); - add_tags = talloc_size (ctx, argc * sizeof (int)); - if (add_tags == NULL) { - fprintf (stderr, "Out of memory.\n"); - return 1; - } + argc--; argv++; /* skip subcommand argument */ - remove_tags = talloc_size (ctx, argc * sizeof (int)); - if (remove_tags == NULL) { + /* Array of tagging operations (add or remove), terminated with an + * empty element. */ + tag_ops = talloc_array (ctx, tag_operation_t, argc + 1); + if (tag_ops == NULL) { fprintf (stderr, "Out of memory.\n"); return 1; } - argc--; argv++; /* skip subcommand argument */ - for (i = 0; i < argc; i++) { if (strcmp (argv[i], "--") == 0) { i++; break; } - if (argv[i][0] == '+') { - add_tags[add_tags_count++] = i; - } else if (argv[i][0] == '-') { - remove_tags[remove_tags_count++] = i; + if (argv[i][0] == '+' || argv[i][0] == '-') { + tag_ops[tag_ops_count].tag = argv[i] + 1; + tag_ops[tag_ops_count].remove = (argv[i][0] == '-'); + tag_ops_count++; } else { break; } } - if (add_tags_count == 0 && remove_tags_count == 0) { + tag_ops[tag_ops_count].tag = NULL; + + if (tag_ops_count == 0) { fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n"); return 1; } @@ -175,9 +172,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) /* Optimize the query so it excludes messages that already have * the specified set of tags. */ - query_string = _optimize_tag_query (ctx, query_string, argv, - add_tags, add_tags_count, - remove_tags, remove_tags_count); + query_string = _optimize_tag_query (ctx, query_string, tag_ops); if (query_string == NULL) { fprintf (stderr, "Out of memory.\n"); return 1; @@ -211,12 +206,12 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) notmuch_message_freeze (message); - for (i = 0; i < remove_tags_count; i++) - notmuch_message_remove_tag (message, - argv[remove_tags[i]] + 1); - - for (i = 0; i < add_tags_count; i++) - notmuch_message_add_tag (message, argv[add_tags[i]] + 1); + for (i = 0; tag_ops[i].tag; i++) { + if (tag_ops[i].remove) + notmuch_message_remove_tag (message, tag_ops[i].tag); + else + notmuch_message_add_tag (message, tag_ops[i].tag); + } notmuch_message_thaw (message); diff --git a/test/tagging b/test/tagging index 3acf1bc..e4782ed 100755 --- a/test/tagging +++ b/test/tagging @@ -43,7 +43,7 @@ notmuch tag +tag4 -tag4 One notmuch tag -tag4 +tag4 Two output=$(notmuch search \* | notmuch_search_sanitize) test_expect_equal "$output" "\ -thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (:\" inbox tag1 tag4 unread) +thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (:\" inbox tag1 unread) thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)" test_done -- cgit v1.2.3 From 9605e62099b8c5d9e1debc27b31ae1e256703a3b Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Tue, 27 Mar 2012 00:04:10 +0300 Subject: cli: refactor "notmuch tag" query tagging into a separate function Refactor to make tagging code easier to reuse in the future. No functional changes. Signed-off-by: Jani Nikula --- notmuch-tag.c | 104 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 44 deletions(-) (limited to 'notmuch-tag.c') diff --git a/notmuch-tag.c b/notmuch-tag.c index 0a6b140..05feed3 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -110,6 +110,63 @@ _optimize_tag_query (void *ctx, const char *orig_query_string, return query_string; } +/* Tag messages matching 'query_string' according to 'tag_ops', which + * must be an array of tagging operations terminated with an empty + * element. */ +static int +tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string, + tag_operation_t *tag_ops, notmuch_bool_t synchronize_flags) +{ + notmuch_query_t *query; + notmuch_messages_t *messages; + notmuch_message_t *message; + int i; + + /* Optimize the query so it excludes messages that already have + * the specified set of tags. */ + query_string = _optimize_tag_query (ctx, query_string, tag_ops); + if (query_string == NULL) { + fprintf (stderr, "Out of memory.\n"); + return 1; + } + + query = notmuch_query_create (notmuch, query_string); + if (query == NULL) { + fprintf (stderr, "Out of memory.\n"); + return 1; + } + + /* tagging is not interested in any special sort order */ + notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED); + + for (messages = notmuch_query_search_messages (query); + notmuch_messages_valid (messages) && !interrupted; + notmuch_messages_move_to_next (messages)) + { + message = notmuch_messages_get (messages); + + notmuch_message_freeze (message); + + for (i = 0; tag_ops[i].tag; i++) { + if (tag_ops[i].remove) + notmuch_message_remove_tag (message, tag_ops[i].tag); + else + notmuch_message_add_tag (message, tag_ops[i].tag); + } + + notmuch_message_thaw (message); + + if (synchronize_flags) + notmuch_message_tags_to_maildir_flags (message); + + notmuch_message_destroy (message); + } + + notmuch_query_destroy (query); + + return interrupted; +} + int notmuch_tag_command (void *ctx, int argc, char *argv[]) { @@ -118,12 +175,10 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) char *query_string; notmuch_config_t *config; notmuch_database_t *notmuch; - notmuch_query_t *query; - notmuch_messages_t *messages; - notmuch_message_t *message; struct sigaction action; notmuch_bool_t synchronize_flags; int i; + int ret; /* Setup our handler for SIGINT */ memset (&action, 0, sizeof (struct sigaction)); @@ -170,14 +225,6 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) return 1; } - /* Optimize the query so it excludes messages that already have - * the specified set of tags. */ - query_string = _optimize_tag_query (ctx, query_string, tag_ops); - if (query_string == NULL) { - fprintf (stderr, "Out of memory.\n"); - return 1; - } - config = notmuch_config_open (ctx, NULL, NULL); if (config == NULL) return 1; @@ -189,40 +236,9 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config); - query = notmuch_query_create (notmuch, query_string); - if (query == NULL) { - fprintf (stderr, "Out of memory.\n"); - return 1; - } - - /* tagging is not interested in any special sort order */ - notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED); + ret = tag_query (ctx, notmuch, query_string, tag_ops, synchronize_flags); - for (messages = notmuch_query_search_messages (query); - notmuch_messages_valid (messages) && !interrupted; - notmuch_messages_move_to_next (messages)) - { - message = notmuch_messages_get (messages); - - notmuch_message_freeze (message); - - for (i = 0; tag_ops[i].tag; i++) { - if (tag_ops[i].remove) - notmuch_message_remove_tag (message, tag_ops[i].tag); - else - notmuch_message_add_tag (message, tag_ops[i].tag); - } - - notmuch_message_thaw (message); - - if (synchronize_flags) - notmuch_message_tags_to_maildir_flags (message); - - notmuch_message_destroy (message); - } - - notmuch_query_destroy (query); notmuch_database_close (notmuch); - return interrupted; + return ret; } -- cgit v1.2.3 From 6f7469f54744656f90ce215f365d5731e16acd3c Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 22 Apr 2012 14:07:53 +0200 Subject: Use notmuch_database_destroy instead of notmuch_database_close Adapt the notmuch binaries source to the notmuch_database_close split. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de> --- notmuch-count.c | 2 +- notmuch-dump.c | 2 +- notmuch-new.c | 2 +- notmuch-reply.c | 2 +- notmuch-restore.c | 2 +- notmuch-search.c | 2 +- notmuch-show.c | 2 +- notmuch-tag.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'notmuch-tag.c') diff --git a/notmuch-count.c b/notmuch-count.c index b76690c..9c2ad7b 100644 --- a/notmuch-count.c +++ b/notmuch-count.c @@ -107,7 +107,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) } notmuch_query_destroy (query); - notmuch_database_close (notmuch); + notmuch_database_destroy (notmuch); return 0; } diff --git a/notmuch-dump.c b/notmuch-dump.c index a735875..71ab0ea 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -116,7 +116,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[]) fclose (output); notmuch_query_destroy (query); - notmuch_database_close (notmuch); + notmuch_database_destroy (notmuch); return 0; } diff --git a/notmuch-new.c b/notmuch-new.c index 473201e..3ff6304 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -1041,7 +1041,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) fprintf (stderr, "Note: A fatal error was encountered: %s\n", notmuch_status_to_string (ret)); - notmuch_database_close (notmuch); + notmuch_database_destroy (notmuch); if (run_hooks && !ret && !interrupted) ret = notmuch_run_hook (db_path, "post-new"); diff --git a/notmuch-reply.c b/notmuch-reply.c index 0949d9f..da99a13 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -755,7 +755,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) return 1; notmuch_query_destroy (query); - notmuch_database_close (notmuch); + notmuch_database_destroy (notmuch); if (params.cryptoctx) g_object_unref(params.cryptoctx); diff --git a/notmuch-restore.c b/notmuch-restore.c index d3b9246..02b563c 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -192,7 +192,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[]) if (line) free (line); - notmuch_database_close (notmuch); + notmuch_database_destroy (notmuch); if (input != stdin) fclose (input); diff --git a/notmuch-search.c b/notmuch-search.c index 1cc8430..7dfd270 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -545,7 +545,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) } notmuch_query_destroy (query); - notmuch_database_close (notmuch); + notmuch_database_destroy (notmuch); return ret; } diff --git a/notmuch-show.c b/notmuch-show.c index da4a797..3b6667c 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1117,7 +1117,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) } notmuch_query_destroy (query); - notmuch_database_close (notmuch); + notmuch_database_destroy (notmuch); if (params.cryptoctx) g_object_unref(params.cryptoctx); diff --git a/notmuch-tag.c b/notmuch-tag.c index 05feed3..bd56fd1 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -238,7 +238,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) ret = tag_query (ctx, notmuch, query_string, tag_ops, synchronize_flags); - notmuch_database_close (notmuch); + notmuch_database_destroy (notmuch); return ret; } -- cgit v1.2.3 From 5fddc07dc31481453c1af186bf7da241c00cdbf1 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 30 Apr 2012 12:25:33 -0400 Subject: lib/cli: Make notmuch_database_open return a status code It has been a long-standing issue that notmuch_database_open doesn't return any indication of why it failed. This patch changes its prototype to return a notmuch_status_t and set an out-argument to the database itself, like other functions that return both a status and an object. In the interest of atomicity, this also updates every use in the CLI so that notmuch still compiles. Since this patch does not update the bindings, the Python bindings test fails. --- lib/database.cc | 28 +++++++++++++++++++++++----- lib/notmuch.h | 26 +++++++++++++++++++------- notmuch-count.c | 5 ++--- notmuch-dump.c | 5 ++--- notmuch-new.c | 5 ++--- notmuch-reply.c | 5 ++--- notmuch-restore.c | 5 ++--- notmuch-search.c | 5 ++--- notmuch-show.c | 5 ++--- notmuch-tag.c | 5 ++--- test/symbol-test.cc | 3 ++- 11 files changed, 60 insertions(+), 37 deletions(-) (limited to 'notmuch-tag.c') diff --git a/lib/database.cc b/lib/database.cc index 2fefcad..1e66599 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -556,8 +556,9 @@ notmuch_database_create (const char *path) goto DONE; } - notmuch = notmuch_database_open (path, - NOTMUCH_DATABASE_MODE_READ_WRITE); + notmuch_database_open (path, + NOTMUCH_DATABASE_MODE_READ_WRITE, + ¬much); notmuch_database_upgrade (notmuch, NULL, NULL); DONE: @@ -578,10 +579,12 @@ _notmuch_database_ensure_writable (notmuch_database_t *notmuch) return NOTMUCH_STATUS_SUCCESS; } -notmuch_database_t * +notmuch_status_t notmuch_database_open (const char *path, - notmuch_database_mode_t mode) + notmuch_database_mode_t mode, + notmuch_database_t **database) { + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; void *local = talloc_new (NULL); notmuch_database_t *notmuch = NULL; char *notmuch_path, *xapian_path; @@ -590,8 +593,15 @@ notmuch_database_open (const char *path, unsigned int i, version; static int initialized = 0; + if (path == NULL) { + fprintf (stderr, "Error: Cannot open a database for a NULL path.\n"); + status = NOTMUCH_STATUS_NULL_POINTER; + goto DONE; + } + if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) { fprintf (stderr, "Out of memory\n"); + status = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; } @@ -599,11 +609,13 @@ notmuch_database_open (const char *path, if (err) { fprintf (stderr, "Error opening database at %s: %s\n", notmuch_path, strerror (errno)); + status = NOTMUCH_STATUS_FILE_ERROR; goto DONE; } if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) { fprintf (stderr, "Out of memory\n"); + status = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; } @@ -644,6 +656,7 @@ notmuch_database_open (const char *path, notmuch->mode = NOTMUCH_DATABASE_MODE_READ_ONLY; notmuch_database_destroy (notmuch); notmuch = NULL; + status = NOTMUCH_STATUS_FILE_ERROR; goto DONE; } @@ -704,12 +717,17 @@ notmuch_database_open (const char *path, error.get_msg().c_str()); notmuch_database_destroy (notmuch); notmuch = NULL; + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } DONE: talloc_free (local); - return notmuch; + if (database) + *database = notmuch; + else + talloc_free (notmuch); + return status; } void diff --git a/lib/notmuch.h b/lib/notmuch.h index 7d9e092..44b0c46 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -151,9 +151,6 @@ typedef enum { NOTMUCH_DATABASE_MODE_READ_WRITE } notmuch_database_mode_t; -/* XXX: I think I'd like this to take an extra argument of - * notmuch_status_t* for returning a status value on failure. */ - /* Open an existing notmuch database located at 'path'. * * The database should have been created at some time in the past, @@ -168,12 +165,27 @@ typedef enum { * The caller should call notmuch_database_destroy when finished with * this database. * - * In case of any failure, this function returns NULL, (after printing - * an error message on stderr). + * In case of any failure, this function returns an error status and + * sets *database to NULL (after printing an error message on stderr). + * + * Return value: + * + * NOTMUCH_STATUS_SUCCESS: Successfully opened the database. + * + * NOTMUCH_STATUS_NULL_POINTER: The given 'path' argument is NULL. + * + * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory. + * + * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to open the + * database file (such as permission denied, or file not found, + * etc.), or the database version is unknown. + * + * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred. */ -notmuch_database_t * +notmuch_status_t notmuch_database_open (const char *path, - notmuch_database_mode_t mode); + notmuch_database_mode_t mode, + notmuch_database_t **database); /* Close the given notmuch database. * diff --git a/notmuch-count.c b/notmuch-count.c index 9c2ad7b..2f98128 100644 --- a/notmuch-count.c +++ b/notmuch-count.c @@ -66,9 +66,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) if (config == NULL) return 1; - notmuch = notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_ONLY); - if (notmuch == NULL) + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) return 1; query_str = query_string_from_args (ctx, argc-opt_index, argv+opt_index); diff --git a/notmuch-dump.c b/notmuch-dump.c index 71ab0ea..3743214 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -36,9 +36,8 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[]) if (config == NULL) return 1; - notmuch = notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_ONLY); - if (notmuch == NULL) + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) return 1; char *output_file_name = NULL; diff --git a/notmuch-new.c b/notmuch-new.c index 3ff6304..7788743 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -903,9 +903,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) notmuch = notmuch_database_create (db_path); add_files_state.total_files = count; } else { - notmuch = notmuch_database_open (db_path, - NOTMUCH_DATABASE_MODE_READ_WRITE); - if (notmuch == NULL) + if (notmuch_database_open (db_path, NOTMUCH_DATABASE_MODE_READ_WRITE, + ¬much)) return 1; if (notmuch_database_needs_upgrade (notmuch)) { diff --git a/notmuch-reply.c b/notmuch-reply.c index da99a13..7184a5d 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -740,9 +740,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) return 1; } - notmuch = notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_ONLY); - if (notmuch == NULL) + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) return 1; query = notmuch_query_create (notmuch, query_string); diff --git a/notmuch-restore.c b/notmuch-restore.c index 02b563c..4f4096e 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -115,9 +115,8 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[]) if (config == NULL) return 1; - notmuch = notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_WRITE); - if (notmuch == NULL) + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) return 1; synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config); diff --git a/notmuch-search.c b/notmuch-search.c index 7dfd270..3be296d 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -486,9 +486,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) if (config == NULL) return 1; - notmuch = notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_ONLY); - if (notmuch == NULL) + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) return 1; query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index); diff --git a/notmuch-show.c b/notmuch-show.c index 3b6667c..95427d4 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1081,9 +1081,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) return 1; } - notmuch = notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_ONLY); - if (notmuch == NULL) + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) return 1; query = notmuch_query_create (notmuch, query_string); diff --git a/notmuch-tag.c b/notmuch-tag.c index bd56fd1..7d18639 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -229,9 +229,8 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) if (config == NULL) return 1; - notmuch = notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_WRITE); - if (notmuch == NULL) + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) return 1; synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config); diff --git a/test/symbol-test.cc b/test/symbol-test.cc index 1548ca4..3e96c03 100644 --- a/test/symbol-test.cc +++ b/test/symbol-test.cc @@ -4,7 +4,8 @@ int main() { - (void) notmuch_database_open("fakedb", NOTMUCH_DATABASE_MODE_READ_ONLY); + notmuch_database_t *notmuch; + notmuch_database_open("fakedb", NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much); try { (void) new Xapian::WritableDatabase("./nonexistant", Xapian::DB_OPEN); -- cgit v1.2.3