mu: fix some compiler warnings

This commit is contained in:
djcb
2016-12-11 18:33:31 +02:00
parent edcef28ac4
commit 78275278cf
8 changed files with 107 additions and 124 deletions

View File

@ -20,14 +20,27 @@ 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= \
libmu.la

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
*

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2008-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2008-2016 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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;
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);
}
@ -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;
}
};

View File

@ -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)
{

View File

@ -1,4 +1,4 @@
## Copyright (C) 2010-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2010-2016 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## 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 \
AM_CFLAGS= \
$(WARN_CFLAGS) \
-Wno-switch-enum \
-DMU_SCRIPTS_DIR="\"$(pkgdatadir)/scripts/\""
AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
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 \