lib: run uncrustify

This is the result of running

     $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h *.cc

in the lib directory
This commit is contained in:
uncrustify 2021-03-13 08:45:34 -04:00 committed by David Bremner
parent 97fadd0645
commit 8aeba1228a
17 changed files with 130 additions and 81 deletions

View file

@ -152,7 +152,8 @@ notmuch_database_get_config_list (notmuch_database_t *notmuch,
talloc_set_destructor (list, _notmuch_config_list_destroy);
} catch (const Xapian::Error &error) {
_notmuch_database_log (notmuch, "A Xapian exception occurred getting metadata iterator: %s.\n",
_notmuch_database_log (notmuch,
"A Xapian exception occurred getting metadata iterator: %s.\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
@ -183,7 +184,9 @@ notmuch_config_list_valid (notmuch_config_list_t *metadata)
return true;
}
static inline char * _key_from_iterator (notmuch_config_list_t *list) {
static inline char *
_key_from_iterator (notmuch_config_list_t *list)
{
return talloc_strdup (list, (*list->iterator).c_str () + CONFIG_PREFIX.length ());
}
@ -289,7 +292,8 @@ notmuch_config_get_values (notmuch_database_t *notmuch, notmuch_config_key_t key
}
notmuch_bool_t
notmuch_config_values_valid (notmuch_config_values_t *values) {
notmuch_config_values_valid (notmuch_config_values_t *values)
{
if (! values)
return false;
@ -297,12 +301,14 @@ notmuch_config_values_valid (notmuch_config_values_t *values) {
}
const char *
notmuch_config_values_get (notmuch_config_values_t *values) {
notmuch_config_values_get (notmuch_config_values_t *values)
{
return talloc_strndup (values, values->iterator, values->tok_len);
}
void
notmuch_config_values_start (notmuch_config_values_t *values) {
notmuch_config_values_start (notmuch_config_values_t *values)
{
if (values == NULL)
return;
if (values->children) {
@ -315,13 +321,15 @@ notmuch_config_values_start (notmuch_config_values_t *values) {
}
void
notmuch_config_values_move_to_next (notmuch_config_values_t *values) {
notmuch_config_values_move_to_next (notmuch_config_values_t *values)
{
values->iterator += values->tok_len;
values->iterator = strsplit_len (values->iterator, ';', &(values->tok_len));
}
void
notmuch_config_values_destroy (notmuch_config_values_t *values) {
notmuch_config_values_destroy (notmuch_config_values_t *values)
{
talloc_free (values);
}
@ -386,7 +394,8 @@ notmuch_config_get_bool (notmuch_database_t *notmuch, notmuch_config_key_t key,
}
static const char *
_notmuch_config_key_to_string (notmuch_config_key_t key) {
_notmuch_config_key_to_string (notmuch_config_key_t key)
{
switch (key) {
case NOTMUCH_CONFIG_DATABASE_PATH:
return "database.path";
@ -412,7 +421,8 @@ _notmuch_config_key_to_string (notmuch_config_key_t key) {
}
static const char *
_notmuch_config_default (void *ctx, notmuch_config_key_t key) {
_notmuch_config_default (void *ctx, notmuch_config_key_t key)
{
char *path;
switch (key) {
@ -443,8 +453,10 @@ _notmuch_config_default (void *ctx, notmuch_config_key_t key) {
}
notmuch_status_t
_notmuch_config_load_defaults (notmuch_database_t *notmuch) {
_notmuch_config_load_defaults (notmuch_database_t *notmuch)
{
notmuch_config_key_t key;
for (key = NOTMUCH_CONFIG_FIRST;
key < NOTMUCH_CONFIG_LAST;
key = notmuch_config_key_t (key + 1)) {
@ -453,25 +465,29 @@ _notmuch_config_load_defaults (notmuch_database_t *notmuch) {
val = _notmuch_string_map_get (notmuch->config, key_string);
if (! val) {
_notmuch_string_map_set (notmuch->config, key_string, _notmuch_config_default (notmuch, key));
_notmuch_string_map_set (notmuch->config, key_string, _notmuch_config_default (notmuch,
key));
}
}
return NOTMUCH_STATUS_SUCCESS;
}
const char *
notmuch_config_get (notmuch_database_t *notmuch, notmuch_config_key_t key) {
notmuch_config_get (notmuch_database_t *notmuch, notmuch_config_key_t key)
{
return _notmuch_string_map_get (notmuch->config, _notmuch_config_key_to_string (key));
}
notmuch_status_t
notmuch_config_set (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val) {
notmuch_config_set (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val)
{
return notmuch_database_set_config (notmuch, _notmuch_config_key_to_string (key), val);
}
void
_notmuch_config_cache (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val) {
_notmuch_config_cache (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val)
{
_notmuch_string_map_set (notmuch->config, _notmuch_config_key_to_string (key), val);
}

View file

@ -49,7 +49,8 @@ typedef struct {
#define LOG_XAPIAN_EXCEPTION(message, error) _log_xapian_exception (__location__, message, error)
static void
_log_xapian_exception (const char *where, notmuch_database_t *notmuch, const Xapian::Error error) {
_log_xapian_exception (const char *where, notmuch_database_t *notmuch, const Xapian::Error error)
{
_notmuch_database_log (notmuch,
"A Xapian exception occurred at %s: %s\n",
where,
@ -506,7 +507,8 @@ notmuch_database_close (notmuch_database_t *notmuch)
} catch (const Xapian::Error &error) {
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
if (! notmuch->exception_reported) {
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred closing database: %s\n",
_notmuch_database_log (notmuch,
"Error: A Xapian exception occurred closing database: %s\n",
error.get_msg ().c_str ());
}
}
@ -627,7 +629,8 @@ notmuch_status_t
notmuch_database_compact_db (notmuch_database_t *notmuch,
const char *backup_path,
notmuch_compact_status_cb_t status_cb,
void *closure) {
void *closure)
{
void *local;
char *notmuch_path, *xapian_path, *compact_xapian_path;
const char *path;
@ -692,7 +695,8 @@ notmuch_database_compact_db (notmuch_database_t *notmuch,
try {
NotmuchCompactor compactor (status_cb, closure);
notmuch->xapian_db->compact (compact_xapian_path, Xapian::DBCOMPACT_NO_RENUMBER, 0, compactor);
notmuch->xapian_db->compact (compact_xapian_path, Xapian::DBCOMPACT_NO_RENUMBER, 0,
compactor);
} catch (const Xapian::Error &error) {
_notmuch_database_log (notmuch, "Error while compacting: %s\n", error.get_msg ().c_str ());
ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
@ -1065,7 +1069,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
if (private_status) {
_notmuch_database_log (notmuch,
"Upgrade failed while creating ghost messages.\n");
status = COERCE_STATUS (private_status, "Unexpected status from _notmuch_message_initialize_ghost");
status = COERCE_STATUS (private_status,
"Unexpected status from _notmuch_message_initialize_ghost");
goto DONE;
}
@ -1498,7 +1503,8 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
status = NOTMUCH_STATUS_OUT_OF_MEMORY;
}
} catch (const Xapian::Error &error) {
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred finding message by filename: %s\n",
_notmuch_database_log (notmuch,
"Error: A Xapian exception occurred finding message by filename: %s\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;

View file

@ -52,8 +52,10 @@ struct _notmuch_directory {
#define LOG_XAPIAN_EXCEPTION(directory, error) _log_xapian_exception (__location__, directory, error)
static void
_log_xapian_exception (const char *where, notmuch_directory_t *dir, const Xapian::Error error) {
_log_xapian_exception (const char *where, notmuch_directory_t *dir, const Xapian::Error error)
{
notmuch_database_t *notmuch = dir->notmuch;
_notmuch_database_log (notmuch,
"A Xapian exception occurred at %s: %s\n",
where,

View file

@ -260,7 +260,8 @@ notmuch_filter_discard_non_term_new (GMimeContentType *content_type)
.value_table = NULL,
};
type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info, (GTypeFlags) 0);
type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info,
(GTypeFlags) 0);
}
filter = (NotmuchFilterDiscardNonTerm *) g_object_new (type, NULL);
@ -455,7 +456,8 @@ _index_mime_part (notmuch_message_t *message,
msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) {
toindex = _notmuch_repair_crypto_payload_skip_legacy_display (child);
if (toindex != child)
notmuch_message_add_property (message, "index.repaired", "skip-protected-headers-legacy-display");
notmuch_message_add_property (message, "index.repaired",
"skip-protected-headers-legacy-display");
}
_index_mime_part (message, indexopts, toindex, msg_crypto);
}
@ -467,7 +469,8 @@ _index_mime_part (notmuch_message_t *message,
mime_message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (part));
_index_mime_part (message, indexopts, g_mime_message_get_mime_part (mime_message), msg_crypto);
_index_mime_part (message, indexopts, g_mime_message_get_mime_part (mime_message),
msg_crypto);
goto DONE;
}
@ -567,6 +570,7 @@ _index_encrypted_mime_part (notmuch_message_t *message,
bool attempted = false;
GMimeDecryptResult *decrypt_result = NULL;
bool get_sk = (notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_TRUE);
clear = _notmuch_crypto_decrypt (&attempted, notmuch_indexopts_get_decrypt_policy (indexopts),
message, encrypted_data, get_sk ? &decrypt_result : NULL, &err);
if (! attempted)
@ -595,7 +599,8 @@ _index_encrypted_mime_part (notmuch_message_t *message,
notmuch_status_to_string (status));
if (get_sk) {
status = notmuch_message_add_property (message, "session-key",
g_mime_decrypt_result_get_session_key (decrypt_result));
g_mime_decrypt_result_get_session_key (
decrypt_result));
if (status)
_notmuch_database_log (notmuch, "failed to add session-key "
"property (%d)\n", status);
@ -603,11 +608,14 @@ _index_encrypted_mime_part (notmuch_message_t *message,
g_object_unref (decrypt_result);
}
GMimeObject *toindex = clear;
if (_notmuch_message_crypto_potential_payload (msg_crypto, clear, encrypted_data, GMIME_MULTIPART_ENCRYPTED_CONTENT) &&
if (_notmuch_message_crypto_potential_payload (msg_crypto, clear, encrypted_data,
GMIME_MULTIPART_ENCRYPTED_CONTENT) &&
msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) {
toindex = _notmuch_repair_crypto_payload_skip_legacy_display (clear);
if (toindex != clear)
notmuch_message_add_property (message, "index.repaired", "skip-protected-headers-legacy-display");
notmuch_message_add_property (message, "index.repaired",
"skip-protected-headers-legacy-display");
}
_index_mime_part (message, indexopts, toindex, msg_crypto);
g_object_unref (clear);
@ -640,7 +648,8 @@ _index_pkcs7_part (notmuch_message_t *message,
if (p7type == GMIME_SECURE_MIME_TYPE_SIGNED_DATA) {
sigs = g_mime_application_pkcs7_mime_verify (pkcs7, GMIME_VERIFY_NONE, &mimeobj, &err);
if (sigs == NULL) {
_notmuch_database_log (notmuch, "Failed to verify PKCS#7 SignedData during indexing. (%d:%d) [%s]\n",
_notmuch_database_log (notmuch,
"Failed to verify PKCS#7 SignedData during indexing. (%d:%d) [%s]\n",
err->domain, err->code, err->message);
g_error_free (err);
goto DONE;
@ -651,7 +660,8 @@ _index_pkcs7_part (notmuch_message_t *message,
msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) {
toindex = _notmuch_repair_crypto_payload_skip_legacy_display (mimeobj);
if (toindex != mimeobj)
notmuch_message_add_property (message, "index.repaired", "skip-protected-headers-legacy-display");
notmuch_message_add_property (message, "index.repaired",
"skip-protected-headers-legacy-display");
}
_index_mime_part (message, indexopts, toindex, msg_crypto);
} else if (p7type == GMIME_SECURE_MIME_TYPE_ENVELOPED_DATA) {

View file

@ -31,6 +31,7 @@ notmuch_database_get_default_indexopts (notmuch_database_t *db)
char *decrypt_policy;
notmuch_status_t err = notmuch_database_get_config (db, "index.decrypt", &decrypt_policy);
if (err)
return NULL;

View file

@ -65,6 +65,7 @@ _notmuch_message_file_open_ctx (notmuch_database_t *notmuch,
return NULL;
const char *prefix = notmuch_database_get_path (notmuch);
if (prefix == NULL)
goto FAIL;

View file

@ -43,11 +43,13 @@ notmuch_message_count_properties (notmuch_message_t *message, const char *key, u
return NOTMUCH_STATUS_NULL_POINTER;
notmuch_string_map_t *map;
map = _notmuch_message_property_map (message);
if (! map)
return NOTMUCH_STATUS_NULL_POINTER;
notmuch_string_map_iterator_t *matcher = _notmuch_string_map_iterator_create (map, key, true);
if (! matcher)
return NOTMUCH_STATUS_OUT_OF_MEMORY;

View file

@ -93,8 +93,10 @@ _notmuch_message_destructor (notmuch_message_t *message)
#define LOG_XAPIAN_EXCEPTION(message, error) _log_xapian_exception (__location__, message, error)
static void
_log_xapian_exception (const char *where, notmuch_message_t *message, const Xapian::Error error) {
_log_xapian_exception (const char *where, notmuch_message_t *message, const Xapian::Error error)
{
notmuch_database_t *notmuch = notmuch_message_get_database (message);
_notmuch_database_log (notmuch,
"A Xapian exception occurred at %s: %s\n",
where,
@ -286,7 +288,8 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch,
doc_id = _notmuch_database_generate_doc_id (notmuch);
} catch (const Xapian::Error &error) {
_notmuch_database_log (notmuch_message_get_database (message), "A Xapian exception occurred creating message: %s\n",
_notmuch_database_log (notmuch_message_get_database (message),
"A Xapian exception occurred creating message: %s\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
*status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
@ -318,6 +321,7 @@ _notmuch_message_get_term (notmuch_message_t *message,
return NULL;
const std::string &term = *i;
if (strncmp (term.c_str (), prefix, prefix_len))
return NULL;
@ -1765,6 +1769,7 @@ notmuch_message_has_maildir_flag (notmuch_message_t *message, char flag)
{
notmuch_status_t status;
notmuch_bool_t ret;
status = notmuch_message_has_maildir_flag_st (message, flag, &ret);
if (status)
return FALSE;
@ -2202,7 +2207,7 @@ notmuch_message_reindex (notmuch_message_t *message,
orig_thread_id = notmuch_message_get_thread_id (message);
if (! orig_thread_id) {
/* the following is correct as long as there is only one reason
n_m_get_thread_id returns NULL
* n_m_get_thread_id returns NULL
*/
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
}

View file

@ -2403,7 +2403,8 @@ notmuch_database_get_config (notmuch_database_t *db, const char *key, char **val
* @since libnotmuch 4.4 (notmuch 0.23)
*/
notmuch_status_t
notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out);
notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix,
notmuch_config_list_t **out);
/**
* Is 'config_list' iterator valid (i.e. _key, _value, _move_to_next can be called).

View file

@ -319,8 +319,10 @@ notmuch_database_open_with_config (const char *database_path,
notmuch->term_gen = new Xapian::TermGenerator;
notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));
notmuch->value_range_processor = new Xapian::NumberRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);
notmuch->date_range_processor = new ParseTimeRangeProcessor (NOTMUCH_VALUE_TIMESTAMP, "date:");
notmuch->last_mod_range_processor = new Xapian::NumberRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:");
notmuch->date_range_processor = new ParseTimeRangeProcessor (NOTMUCH_VALUE_TIMESTAMP,
"date:");
notmuch->last_mod_range_processor = new Xapian::NumberRangeProcessor (NOTMUCH_VALUE_LAST_MOD,
"lastmod:");
notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
notmuch->query_parser->set_database (*notmuch->xapian_db);
notmuch->query_parser->set_stemmer (Xapian::Stem ("english"));

View file

@ -40,11 +40,13 @@ ThreadFieldProcessor::operator() (const std::string & str)
std::set<std::string> terms;
if (! subquery)
throw Xapian::QueryParserError ("failed to create subquery for '" + subquery_str + "'");
throw Xapian::QueryParserError ("failed to create subquery for '" + subquery_str +
"'");
status = notmuch_query_search_messages (subquery, &messages);
if (status)
throw Xapian::QueryParserError ("failed to search messages for '" + subquery_str + "'");
throw Xapian::QueryParserError ("failed to search messages for '" + subquery_str +
"'");
for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) {
std::string term = thread_prefix;

View file

@ -505,7 +505,8 @@ _resolve_thread_relationships (notmuch_thread_t *thread)
notmuch_messages_valid (roots);
notmuch_messages_move_to_next (roots)) {
notmuch_message_t *message = notmuch_messages_get (roots);
if (_notmuch_messages_has_next (roots) || ! _notmuch_message_list_empty (thread->toplevel_list))
if (_notmuch_messages_has_next (roots) || ! _notmuch_message_list_empty (
thread->toplevel_list))
_parent_or_toplevel (thread, message);
else
_notmuch_message_list_add_message (thread->toplevel_list, message);