From 78275278cf5cf6a522e212e2ec69f86ef9ad16eb Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 11 Dec 2016 18:33:31 +0200 Subject: [PATCH] mu: fix some compiler warnings --- lib/Makefile.am | 137 +++++++++++++++++++++++++--------------------- lib/mu-contacts.c | 10 ++-- lib/mu-msg-part.c | 2 +- lib/mu-msg.c | 2 +- lib/mu-msg.h | 14 +---- lib/mu-query.cc | 28 +++++----- lib/mu-util.c | 23 +------- mu/Makefile.am | 15 +++-- 8 files changed, 107 insertions(+), 124 deletions(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index 064423d5..49dd915f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -20,77 +20,90 @@ include $(top_srcdir)/gtest.mk # before decending into tests/ SUBDIRS= . tests -AM_CPPFLAGS=$(XAPIAN_CXXFLAGS) $(GMIME_CFLAGS) $(GLIB_CFLAGS) $(GUILE_CFLAGS) +AM_CFLAGS= \ + $(WARN_CFLAGS) \ + -Wno-format-nonliteral \ + -Wno-switch-enum \ + $(GMIME_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GUILE_CFLAGS) + +AM_CXXFLAGS= \ + $(WARN_CXXFLAGS) \ + $(GMIME_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(XAPIAN_CXXFLAGS) \ + $(GUILE_CFLAGS) # don't use -Werror, as it might break on other compilers # use -Wno-unused-parameters, because some callbacks may not # really need all the params they get -AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter \ --Wdeclaration-after-statement -Wno-variadic-macros -AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter +# AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter \ +# -Wdeclaration-after-statement -Wno-variadic-macros +# AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter -noinst_LTLIBRARIES= \ +noinst_LTLIBRARIES= \ libmu.la -libmu_la_SOURCES= \ - mu-bookmarks.c \ - mu-bookmarks.h \ - mu-contacts.c \ - mu-contacts.h \ - mu-container.c \ - mu-container.h \ - mu-date.c \ - mu-date.h \ - mu-flags.h \ - mu-flags.c \ - mu-index.c \ - mu-index.h \ - mu-log.c \ - mu-log.h \ - mu-maildir.c \ - mu-maildir.h \ - mu-msg-crypto.c \ - mu-msg-doc.cc \ - mu-msg-doc.h \ - mu-msg-fields.c \ - mu-msg-fields.h \ - mu-msg-file.c \ - mu-msg-file.h \ - mu-msg-iter.cc \ - mu-msg-iter.h \ - mu-msg-part.c \ - mu-msg-part.h \ - mu-msg-prio.c \ - mu-msg-prio.h \ - mu-msg-priv.h \ - mu-msg-sexp.c \ - mu-msg.c \ - mu-msg.h \ - mu-msg.h \ - mu-query.cc \ - mu-query.h \ - mu-runtime.c \ - mu-runtime.h \ - mu-script.c \ - mu-script.h \ - mu-store.cc \ - mu-store.h \ - mu-store-read.cc \ - mu-store-write.cc \ - mu-store-priv.hh \ - mu-str.c \ - mu-str.h \ - mu-threader.c \ - mu-threader.h \ - mu-util.c \ +libmu_la_SOURCES= \ + mu-bookmarks.c \ + mu-bookmarks.h \ + mu-contacts.c \ + mu-contacts.h \ + mu-container.c \ + mu-container.h \ + mu-date.c \ + mu-date.h \ + mu-flags.h \ + mu-flags.c \ + mu-index.c \ + mu-index.h \ + mu-log.c \ + mu-log.h \ + mu-maildir.c \ + mu-maildir.h \ + mu-msg-crypto.c \ + mu-msg-doc.cc \ + mu-msg-doc.h \ + mu-msg-fields.c \ + mu-msg-fields.h \ + mu-msg-file.c \ + mu-msg-file.h \ + mu-msg-iter.cc \ + mu-msg-iter.h \ + mu-msg-part.c \ + mu-msg-part.h \ + mu-msg-prio.c \ + mu-msg-prio.h \ + mu-msg-priv.h \ + mu-msg-sexp.c \ + mu-msg.c \ + mu-msg.h \ + mu-msg.h \ + mu-query.cc \ + mu-query.h \ + mu-runtime.c \ + mu-runtime.h \ + mu-script.c \ + mu-script.h \ + mu-store.cc \ + mu-store.h \ + mu-store-read.cc \ + mu-store-write.cc \ + mu-store-priv.hh \ + mu-str.c \ + mu-str.h \ + mu-threader.c \ + mu-threader.h \ + mu-util.c \ mu-util.h -libmu_la_LIBADD= \ - $(XAPIAN_LIBS) \ - $(GMIME_LIBS) \ - $(GLIB_LIBS) \ +libmu_la_LIBADD= \ + $(XAPIAN_LIBS) \ + $(GMIME_LIBS) \ + $(GLIB_LIBS) \ $(GUILE_LIBS) -EXTRA_DIST= \ - mu-msg-crypto.c \ +EXTRA_DIST= \ + mu-msg-crypto.c \ doxyfile.in diff --git a/lib/mu-contacts.c b/lib/mu-contacts.c index 48646ac3..e3bda562 100644 --- a/lib/mu-contacts.c +++ b/lib/mu-contacts.c @@ -48,7 +48,7 @@ static ContactInfo *contact_info_new (char *email, char *name, gboolean personal, time_t tstamp, unsigned freq); struct _MuContacts { - GKeyFile *_ccache; + GKeyFile *_ccache; gchar *_path; GHashTable *_hash; @@ -245,7 +245,7 @@ encode_email_address (const char *addr) /* downcase the domain-part of the email address, but only if it * consists of ascii (to prevent screwing up idna addresses) */ -char* +static char* downcase_domain_maybe (const char *addr) { char *addr_conv, *at, *cur; @@ -291,7 +291,7 @@ mu_contacts_add (MuContacts *self, const char *addr, const char *name, g_return_val_if_fail (addr, FALSE); group = encode_email_address (addr); - + cinfo = (ContactInfo*) g_hash_table_lookup (self->_hash, group); if (!cinfo) { char *addr_dc; @@ -306,7 +306,7 @@ mu_contacts_add (MuContacts *self, const char *addr, const char *name, * personal */ if (personal) cinfo->_personal = TRUE; - + if (cinfo->_tstamp < tstamp) { if (!mu_str_is_empty(name)) { /* update the name to the last one used, unless it's @@ -458,7 +458,7 @@ mu_contacts_destroy (MuContacts *self) mu_contacts_serialize (self)) MU_WRITE_LOG("serialized contacts cache %s", self->_path); - + if (self->_ccache) g_key_file_free (self->_ccache); diff --git a/lib/mu-msg-part.c b/lib/mu-msg-part.c index a686df58..a1037fe7 100644 --- a/lib/mu-msg-part.c +++ b/lib/mu-msg-part.c @@ -650,7 +650,7 @@ mu_msg_part_foreach (MuMsg *msg, MuMsgOptions opts, } -gboolean +static gboolean write_part_to_fd (GMimePart *part, int fd, GError **err) { GMimeStream *stream; diff --git a/lib/mu-msg.c b/lib/mu-msg.c index c1b1132d..c9359035 100644 --- a/lib/mu-msg.c +++ b/lib/mu-msg.c @@ -807,7 +807,7 @@ mu_msg_is_readable (MuMsg *self) * from the /bar * that we got */ -char* +static char* get_target_mdir (MuMsg *msg, const char *target_maildir, GError **err) { char *rootmaildir, *rv; diff --git a/lib/mu-msg.h b/lib/mu-msg.h index ba64efbb..150d466f 100644 --- a/lib/mu-msg.h +++ b/lib/mu-msg.h @@ -82,7 +82,7 @@ typedef enum _MuMsgOptions MuMsgOptions; */ MuMsg *mu_msg_new_from_file (const char* filepath, const char *maildir, GError **err) - G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** @@ -280,18 +280,6 @@ const char* mu_msg_get_msgid (MuMsg *msg); const char* mu_msg_get_mailing_list (MuMsg *msg); -/** - * get any arbitrary header from this message - * - * @param msg a valid MuMsg* instance - * @header the header requested - * - * @return the header requested or NULL in case of error or if there - * is no such header. the returned string should *not* be modified or freed. - */ -const char* mu_msg_get_header (MuMsg *msg, - const char* header); - /** * get the message date/time (the Date: field) as time_t, using UTC * diff --git a/lib/mu-query.cc b/lib/mu-query.cc index a32094d5..f7bc1e9e 100644 --- a/lib/mu-query.cc +++ b/lib/mu-query.cc @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2013 Dirk-Jan C. Binnema +** Copyright (C) 2008-2016 Dirk-Jan C. Binnema ** ** 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 @@ -61,22 +61,22 @@ public: private: std::string to_sortable (std::string& s, bool is_begin) { - const char* str; - time_t t; + const char* tmp; + time_t t; // note: if s is empty and not is_begin, xapian seems // to repeat it. if (s.empty() || g_str_has_suffix (s.c_str(), "..")) { - str = mu_date_complete_s ("", is_begin); + tmp = mu_date_complete_s ("", is_begin); } else { - str = mu_date_interpret_s (s.c_str(), + tmp = mu_date_interpret_s (s.c_str(), is_begin ? TRUE: FALSE); - str = mu_date_complete_s (str, is_begin ? TRUE: FALSE); - t = mu_date_str_to_time_t (str, TRUE /*local*/); - str = mu_date_time_t_to_str_s (t, FALSE /*UTC*/); + tmp = mu_date_complete_s (tmp, is_begin ? TRUE: FALSE); + t = mu_date_str_to_time_t (tmp, TRUE /*local*/); + tmp = mu_date_time_t_to_str_s (t, FALSE /*UTC*/); } - return s = std::string(str); + return s = std::string(tmp); } @@ -117,7 +117,7 @@ public: begin = Xapian::sortable_serialise (atol(begin.c_str())); end = Xapian::sortable_serialise (atol(end.c_str())); - + /* swap if b > e */ if (begin > end) std::swap (begin, end); @@ -145,12 +145,12 @@ private: } bool substitute_size (std::string& size) { - gchar str[16]; + gchar buf[16]; gint64 num = mu_str_size_parse_bkm(size.c_str()); if (num < 0) throw Xapian::QueryParserError ("invalid size"); - snprintf (str, sizeof(str), "%" G_GUINT64_FORMAT, num); - size = str; + snprintf (buf, sizeof(buf), "%" G_GUINT64_FORMAT, num); + size = buf; return true; } }; @@ -414,7 +414,7 @@ static GHashTable* get_thread_ids (MuMsgIter *iter, GHashTable **orig_set) { GHashTable *ids; - + ids = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, NULL); *orig_set = g_hash_table_new_full (g_str_hash, g_str_equal, diff --git a/lib/mu-util.c b/lib/mu-util.c index 13f45f2c..37d0e936 100644 --- a/lib/mu-util.c +++ b/lib/mu-util.c @@ -117,28 +117,6 @@ mu_util_dir_expand (const char *path) return g_strdup (resolved); } - -char* -mu_util_create_tmpdir (void) -{ - gchar *dirname; - - dirname = g_strdup_printf ("%s%cmu-%d%c%x", - g_get_tmp_dir(), - G_DIR_SEPARATOR, - getuid(), - G_DIR_SEPARATOR, - (int)random()*getpid()*(int)time(NULL)); - - if (!mu_util_create_dir_maybe (dirname, 0700, FALSE)) { - g_free (dirname); - return NULL; - } - - return dirname; -} - - GQuark mu_util_error_quark (void) { @@ -482,6 +460,7 @@ mu_util_g_set_error (GError **err, MuError errcode, const char *frm, ...) } + static gboolean print_args (FILE *stream, const char *frm, va_list args) { diff --git a/mu/Makefile.am b/mu/Makefile.am index fcc18356..c8260341 100644 --- a/mu/Makefile.am +++ b/mu/Makefile.am @@ -1,4 +1,4 @@ -## Copyright (C) 2010-2013 Dirk-Jan C. Binnema +## Copyright (C) 2010-2016 Dirk-Jan C. Binnema ## ## 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 @@ -25,10 +25,13 @@ AM_CPPFLAGS=-I${top_srcdir}/lib $(GLIB_CFLAGS) # don't use -Werror, as it might break on other compilers # use -Wno-unused-parameters, because some callbacks may not # really need all the params they get -AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement \ - -Wno-variadic-macros \ - -DMU_SCRIPTS_DIR="\"$(pkgdatadir)/scripts/\"" -AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter +AM_CFLAGS= \ + $(WARN_CFLAGS) \ + -Wno-switch-enum \ + -DMU_SCRIPTS_DIR="\"$(pkgdatadir)/scripts/\"" + +AM_CXXFLAGS= \ + $(WARN_CXXFLAGS) bin_PROGRAMS= \ mu @@ -52,7 +55,7 @@ BUILT_SOURCES= \ mu-help-strings.h mu-help-strings.h: mu-help-strings.txt mu-help-strings.awk - $(AWK) -f ${top_srcdir}/mu/mu-help-strings.awk < $< > $@ + $(AM_V_GEN) $(AWK) -f ${top_srcdir}/mu/mu-help-strings.awk < $< > $@ mu_LDADD= \ ${top_builddir}/lib/libmu.la \