mu: fix some compiler warnings

and whitespace.
This commit is contained in:
Dirk-Jan C. Binnema 2021-03-12 22:20:48 +02:00
parent 6e9bfb6300
commit 6e9a60c385
2 changed files with 28 additions and 25 deletions

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2011-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2011-2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -83,11 +83,11 @@ typedef struct _FlagData FlagData;
#define MU_GUILE_INITIALIZED_OR_ERROR \ #define MU_GUILE_INITIALIZED_OR_ERROR \
do { if (!(mu_guile_initialized())) \ do { if (!(mu_guile_initialized())) \
mu_guile_error (FUNC_NAME, 0, \ mu_guile_error (FUNC_NAME, 0, \
"mu not initialized; call mu:initialize", \ "mu not initialized; call mu:initialize", \
SCM_UNDEFINED); \ SCM_UNDEFINED); \
return SCM_UNSPECIFIED; \ return SCM_UNSPECIFIED; \
} while (0) } while (0)
static void static void
@ -99,7 +99,7 @@ check_flag (MuFlags flag, FlagData *fdata)
return; return;
switch (flag) { switch (flag) {
case MU_FLAG_NONE: break; case MU_FLAG_NONE: break;
case MU_FLAG_NEW: flag_scm = SYMB_FLAG_NEW; break; case MU_FLAG_NEW: flag_scm = SYMB_FLAG_NEW; break;
case MU_FLAG_PASSED: flag_scm = SYMB_FLAG_PASSED; break; case MU_FLAG_PASSED: flag_scm = SYMB_FLAG_PASSED; break;
case MU_FLAG_REPLIED: flag_scm = SYMB_FLAG_REPLIED; break; case MU_FLAG_REPLIED: flag_scm = SYMB_FLAG_REPLIED; break;
@ -111,7 +111,7 @@ check_flag (MuFlags flag, FlagData *fdata)
case MU_FLAG_ENCRYPTED: flag_scm = SYMB_FLAG_ENCRYPTED; break; case MU_FLAG_ENCRYPTED: flag_scm = SYMB_FLAG_ENCRYPTED; break;
case MU_FLAG_HAS_ATTACH: flag_scm = SYMB_FLAG_HAS_ATTACH; break; case MU_FLAG_HAS_ATTACH: flag_scm = SYMB_FLAG_HAS_ATTACH; break;
case MU_FLAG_UNREAD: flag_scm = SYMB_FLAG_UNREAD; break; case MU_FLAG_UNREAD: flag_scm = SYMB_FLAG_UNREAD; break;
case MU_FLAG_LIST: flag_scm = SYMB_FLAG_LIST; break; case MU_FLAG_LIST: flag_scm = SYMB_FLAG_LIST; break;
default: flag_scm = SCM_UNDEFINED; default: flag_scm = SCM_UNDEFINED;
} }
@ -304,15 +304,19 @@ SCM_DEFINE (get_contacts, "mu:c:get-contacts", 2, 0, 0,
else { else {
mu_guile_error (FUNC_NAME, 0, "invalid contact type", mu_guile_error (FUNC_NAME, 0, "invalid contact type",
SCM_UNDEFINED); SCM_UNDEFINED);
return SCM_UNSPECIFIED; return SCM_UNSPECIFIED;
} }
} }
ecdata.lst = SCM_EOL; ecdata.lst = SCM_EOL;
msgwrap = (MuMsgWrapper*) SCM_CDR(MSG); msgwrap = (MuMsgWrapper*) SCM_CDR(MSG);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
mu_msg_contact_foreach (msgwrap->_msg, mu_msg_contact_foreach (msgwrap->_msg,
(MuMsgContactForeachFunc)contacts_to_list, (MuMsgContactForeachFunc)contacts_to_list,
&ecdata); &ecdata);
#pragma GCC diagnostic pop
/* explicitly close the file backend, so we won't run out of fds */ /* explicitly close the file backend, so we won't run out of fds */
mu_msg_unload_msg_file (msgwrap->_msg); mu_msg_unload_msg_file (msgwrap->_msg);
@ -422,7 +426,7 @@ static Mu::Option<Mu::QueryResults>
get_query_results (Mu::Query& query, const char* expr, int maxnum) get_query_results (Mu::Query& query, const char* expr, int maxnum)
{ {
return query.run(expr, MU_MSG_FIELD_ID_NONE, return query.run(expr, MU_MSG_FIELD_ID_NONE,
Mu::QueryFlags::None, maxnum); Mu::QueryFlags::None, maxnum);
} }
@ -448,25 +452,25 @@ SCM_DEFINE (for_each_message, "mu:c:for-each-message", 3, 0, 0,
return SCM_UNSPECIFIED; /* nothing to do */ return SCM_UNSPECIFIED; /* nothing to do */
if (EXPR == SCM_BOOL_T) if (EXPR == SCM_BOOL_T)
expr = strdup (""); /* note, "" matches *all* messages */ expr = strdup (""); /* note, "" matches *all* messages */
else else
expr = scm_to_utf8_string(EXPR); expr = scm_to_utf8_string(EXPR);
const auto res{get_query_results(mu_guile_query(), expr, const auto res{get_query_results(mu_guile_query(), expr,
scm_to_int(MAXNUM))}; scm_to_int(MAXNUM))};
free (expr); free (expr);
if (!res) if (!res)
return SCM_UNSPECIFIED; return SCM_UNSPECIFIED;
for (auto&& mi: *res) { for (auto&& mi: *res) {
auto msg{mi.floating_msg()}; auto msg{mi.floating_msg()};
if (msg) { if (msg) {
auto msgsmob{mu_guile_msg_to_scm (mu_msg_ref(msg))}; auto msgsmob{mu_guile_msg_to_scm (mu_msg_ref(msg))};
scm_call_1 (FUNC, msgsmob); scm_call_1 (FUNC, msgsmob);
} }
} }
return SCM_UNSPECIFIED; return SCM_UNSPECIFIED;
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -507,7 +511,7 @@ define_symbols (void)
SYMB_FLAG_HAS_ATTACH = register_symbol ("mu:flag:has-attach"); SYMB_FLAG_HAS_ATTACH = register_symbol ("mu:flag:has-attach");
SYMB_FLAG_UNREAD = register_symbol ("mu:flag:unread"); SYMB_FLAG_UNREAD = register_symbol ("mu:flag:unread");
SYMB_FLAG_LIST = register_symbol ("mu:flag:list"); SYMB_FLAG_LIST = register_symbol ("mu:flag:list");
} }

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2012-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2012-2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -137,8 +137,7 @@ mu_script_info_matches_regex (MuScriptInfo *msi, const char *rxstr,
void void
mu_script_info_list_destroy (GSList *lst) mu_script_info_list_destroy (GSList *lst)
{ {
g_slist_foreach (lst, (GFunc)script_info_destroy, NULL); g_slist_free_full(lst, (GDestroyNotify)script_info_destroy);
g_slist_free (lst);
} }