From fb1651e184fd57e768d2a3b901d32a33b0f1a4aa Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sun, 26 Sep 2010 17:29:54 +0300 Subject: [PATCH] * fix small conversion errors (-Wconversion) --- man/Makefile.am | 9 ++++---- src/mu-cmd-extract.c | 9 ++++---- src/mu-cmd-index.c | 52 +++++++++++++++++++++++++++----------------- src/mu-index.c | 5 ++++- src/mu-log.c | 2 +- src/mu-maildir.c | 17 ++++++++++----- src/mu-msg-part.c | 5 ++--- src/mu-msg.c | 7 +++--- src/mu-msg.h | 2 +- src/mu-store.cc | 6 ++--- src/mu-util.c | 2 +- 11 files changed, 70 insertions(+), 46 deletions(-) diff --git a/man/Makefile.am b/man/Makefile.am index 769f4d9b..f63883b5 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Dirk-Jan C. Binnema +## Copyright (C) 2008-2010 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 @@ -17,10 +17,11 @@ include $(top_srcdir)/gtest.mk dist_man_MANS = \ - mu.1 \ + mu-cleanup.1 \ + mu-easy.1 \ + mu-extract.1 \ mu-find.1 \ mu-index.1 \ - mu-cleanup.1 \ mu-mkdir.1 \ mu-view.1 \ - mu-extract.1 + mu.1 diff --git a/src/mu-cmd-extract.c b/src/mu-cmd-extract.c index 92c0f5ed..ad3526de 100644 --- a/src/mu-cmd-extract.c +++ b/src/mu-cmd-extract.c @@ -38,16 +38,17 @@ save_numbered_parts (MuMsg *msg, MuConfigOptions *opts) for (rv = TRUE, cur = parts; cur && *cur; ++cur) { - int idx; + unsigned idx; + int i; char *endptr; - idx = (int)strtol (*cur, &endptr, 10); - if (idx < 0 || *cur == endptr) { + idx = (unsigned)(i = strtol (*cur, &endptr, 10)); + if (i < 0 || *cur == endptr) { g_warning ("invalid MIME-part index '%s'", *cur); rv = FALSE; break; } - + if (!mu_msg_mime_part_save (msg, idx, opts->targetdir, opts->overwrite)) { g_warning ("failed to save MIME-part %d", idx); diff --git a/src/mu-cmd-index.c b/src/mu-cmd-index.c index 288c2c44..abb03932 100644 --- a/src/mu-cmd-index.c +++ b/src/mu-cmd-index.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2010 Dirk-Jan C. Binnema +** Copyright (C) 2008-2010 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 the @@ -17,7 +17,11 @@ ** */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif /*HAVE_CONFIG_H*/ + +#include "mu-cmd.h" #include #include @@ -29,17 +33,15 @@ #include "mu-util-db.h" #include "mu-msg.h" - #include "mu-index.h" -#include "mu-cmd.h" static gboolean MU_CAUGHT_SIGNAL; static void maybe_newline (gboolean quiet) { - if (!quiet) - g_print ("\n"); +if (!quiet) + g_print ("\n"); } static void @@ -111,34 +113,44 @@ index_msg_silent_cb (MuIndexStats* stats, void *user_data) return MU_CAUGHT_SIGNAL ? MU_STOP: MU_OK; } - -static MuResult -index_msg_cb (MuIndexStats* stats, void *user_data) +static unsigned +print_stats (MuIndexStats* stats) { char *kars="-\\|/"; char output[120]; static int i = 0; - static int len = 0; + unsigned len = 0; + + len = (unsigned) snprintf (output, sizeof(output), + "%c processing mail; processed: %u; " + "updated/new: %u, cleaned-up: %u", + (unsigned)kars[++i % 4], + (unsigned)stats->_processed, + (unsigned)stats->_updated, + (unsigned)stats->_cleaned_up); + + g_print ("%s", output); + return len; +} + + +static MuResult +index_msg_cb (MuIndexStats* stats, void *user_data) +{ + static unsigned len = 0; if (MU_CAUGHT_SIGNAL) return MU_STOP; if (stats->_processed % 25) - return MU_OK; + return MU_OK; while (len --> 0) /* note the --> operator :-) */ g_print ("\b"); - - len = snprintf (output, sizeof(output), - "%c processing mail; processed: %u; " - "updated/new: %u, cleaned-up: %u", - (unsigned)kars[++i % 4], - (unsigned)stats->_processed, - (unsigned)stats->_updated, - (unsigned)stats->_cleaned_up); - g_print ("%s", output); - + + len = print_stats (stats); + return MU_CAUGHT_SIGNAL ? MU_STOP: MU_OK; } diff --git a/src/mu-index.c b/src/mu-index.c index a2bd21e8..e4211da5 100644 --- a/src/mu-index.c +++ b/src/mu-index.c @@ -17,7 +17,11 @@ ** */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif /*HAVE_CONFIG_H*/ + +#include "mu-index.h" #include #include @@ -27,7 +31,6 @@ #include #include "mu-maildir.h" -#include "mu-index.h" #include "mu-store.h" #include "mu-util.h" #include "mu-util-db.h" diff --git a/src/mu-log.c b/src/mu-log.c index 51557bc9..6cebf68e 100644 --- a/src/mu-log.c +++ b/src/mu-log.c @@ -242,7 +242,7 @@ log_write (const char* domain, GLogLevelFlags level, if (len == sizeof(buf)) buf[sizeof(buf)-2] = '\n'; - len = write (MU_LOG->_fd, buf, len); + len = write (MU_LOG->_fd, buf, (size_t)len); if (len < 0) fprintf (stderr, "%s: failed to write to log: %s\n", __FUNCTION__, strerror(errno)); diff --git a/src/mu-maildir.c b/src/mu-maildir.c index 9dba0c97..f65a3c00 100644 --- a/src/mu-maildir.c +++ b/src/mu-maildir.c @@ -53,7 +53,7 @@ fullpath_s (const char* path, const char* name) static gboolean -create_maildir (const char *path, int mode) +create_maildir (const char *path, mode_t mode) { int i; const gchar* subdirs[] = {"new", "cur", "tmp"}; @@ -73,8 +73,7 @@ create_maildir (const char *path, int mode) /* static buffer */ fullpath = fullpath_s (path, subdirs[i]); - - rv = g_mkdir_with_parents (fullpath, mode); + rv = g_mkdir_with_parents (fullpath, (int)mode); if (rv != 0) { g_warning ("g_mkdir_with_parents failed: %s", strerror (errno)); @@ -457,10 +456,18 @@ dirent_destroy (struct dirent *entry) } #ifdef HAVE_STRUCT_DIRENT_D_INO -static gint +static int dirent_cmp (struct dirent *d1, struct dirent *d2) { - return d1->d_ino - d2->d_ino; + /* we do it his way instead of a simple d1->d_ino - d2->d_ino + * because this way, we don't need 64-bit numbers for the + * actual sorting */ + if (d1->d_ino < d2->d_ino) + return -1; + else if (d1->d_ino > d2->d_ino) + return 1; + else + return 0; } #endif /*HAVE_STRUCT_DIRENT_D_INO*/ diff --git a/src/mu-msg-part.c b/src/mu-msg-part.c index 6121b8a4..ba57f5fb 100644 --- a/src/mu-msg-part.c +++ b/src/mu-msg-part.c @@ -166,14 +166,13 @@ part_foreach_save_cb (GMimeObject *parent, GMimeObject *part, } gboolean -mu_msg_mime_part_save (MuMsg *msg, int wanted_idx, +mu_msg_mime_part_save (MuMsg *msg, unsigned wanted_idx, const char *targetdir, gboolean overwrite) { - SavePartData spd; + SavePartData spd; const char *msgid; g_return_val_if_fail (msg, FALSE); - g_return_val_if_fail (wanted_idx >= 0, FALSE); spd.idx = 0; spd.wanted_idx = wanted_idx; diff --git a/src/mu-msg.c b/src/mu-msg.c index 8e8bf9ec..0041128b 100644 --- a/src/mu-msg.c +++ b/src/mu-msg.c @@ -39,7 +39,7 @@ static void ref_gmime (void) { if (G_UNLIKELY(_refcount == 0)) { - srandom (getpid()*time(NULL)); + srandom ((unsigned)(getpid()*time(NULL))); g_mime_init(0); } ++_refcount; @@ -101,7 +101,8 @@ init_file_metadata (MuMsg* msg, const char* path, const gchar* mdir) } msg->_timestamp = statbuf.st_mtime; - msg->_size = statbuf.st_size; + /* size_t should be enough for message size... */ + msg->_size = (size_t)statbuf.st_size; msg->_fields[PATH_FIELD] = strdup (path); /* FIXME: maybe try to derive it from the path? */ @@ -362,7 +363,7 @@ mu_msg_get_flags (MuMsg *msg) size_t mu_msg_get_size (MuMsg *msg) { - g_return_val_if_fail (msg, -1); + g_return_val_if_fail (msg, 0); return msg->_size; } diff --git a/src/mu-msg.h b/src/mu-msg.h index 830f039b..b48516d6 100644 --- a/src/mu-msg.h +++ b/src/mu-msg.h @@ -106,7 +106,7 @@ const char* mu_msg_get_summary (MuMsg *msg, size_t max_lines); * @return TRUE if saving succeeded, FALSE otherwise */ gboolean -mu_msg_mime_part_save (MuMsg *msg, int wanted_idx, +mu_msg_mime_part_save (MuMsg *msg, unsigned wanted_idx, const char *targetdir, gboolean overwrite); /** diff --git a/src/mu-store.cc b/src/mu-store.cc index c7cb3491..05d56be1 100644 --- a/src/mu-store.cc +++ b/src/mu-store.cc @@ -78,7 +78,7 @@ mu_store_new (const char* xpath) unsigned mu_store_count (MuStore *store) { - g_return_val_if_fail (store, NULL); + g_return_val_if_fail (store, 0); try { return store->_db->get_doccount(); @@ -413,8 +413,8 @@ mu_store_remove (MuStore *store, const char* msgpath) gboolean mu_store_contains_message (MuStore *store, const char* path) { - g_return_val_if_fail (store, NULL); - g_return_val_if_fail (path, NULL); + g_return_val_if_fail (store, FALSE); + g_return_val_if_fail (path, FALSE); try { const std::string uid (get_message_uid(path)); diff --git a/src/mu-util.c b/src/mu-util.c index 8ef41194..fa1b9120 100644 --- a/src/mu-util.c +++ b/src/mu-util.c @@ -113,7 +113,7 @@ mu_util_init_system (void) gboolean mu_util_check_dir (const gchar* path, gboolean readable, gboolean writeable) { - mode_t mode; + int mode; struct stat statbuf; if (!path)