* <many> fix small conversion errors (-Wconversion)

This commit is contained in:
Dirk-Jan C. Binnema
2010-09-26 17:29:54 +03:00
parent 3fa552a81e
commit fb1651e184
11 changed files with 70 additions and 46 deletions

View File

@ -1,4 +1,4 @@
## Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2008-2010 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
@ -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

View File

@ -38,11 +38,12 @@ 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;

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2008-2010 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 the
@ -17,7 +17,11 @@
**
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG_H*/
#include "mu-cmd.h"
#include <errno.h>
#include <string.h>
@ -29,9 +33,7 @@
#include "mu-util-db.h"
#include "mu-msg.h"
#include "mu-index.h"
#include "mu-cmd.h"
static gboolean MU_CAUGHT_SIGNAL;
@ -111,15 +113,32 @@ 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;
@ -130,14 +149,7 @@ index_msg_cb (MuIndexStats* stats, void *user_data)
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;
}

View File

@ -17,7 +17,11 @@
**
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG_H*/
#include "mu-index.h"
#include <stdlib.h>
#include <string.h>
@ -27,7 +31,6 @@
#include <errno.h>
#include "mu-maildir.h"
#include "mu-index.h"
#include "mu-store.h"
#include "mu-util.h"
#include "mu-util-db.h"

View File

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

View File

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

View File

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

View File

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

View File

@ -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);
/**

View File

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

View File

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