[balsa/gtk3] Correct zero-divide protection
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Correct zero-divide protection
- Date: Sun, 19 May 2013 11:17:03 +0000 (UTC)
commit 7c7f245e263b7ce9dd5cc31717d260eb2e854a09
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat May 18 20:09:58 2013 -0400
Correct zero-divide protection
* libbalsa/mailbox_local.c: avoid zero-divide.
* libbalsa/mailbox_maildir.c (libbalsa_mailbox_maildir_open): do
not change LibBalsaMailboxLocal::sync_time or ::sync_cnt.
* libbalsa/mailbox_mbox.c (libbalsa_mailbox_mbox_open): ditto.
* libbalsa/mailbox_mh.c (libbalsa_mailbox_mh_open): ditto.
ChangeLog | 8 ++++++++
libbalsa/mailbox_local.c | 3 ++-
libbalsa/mailbox_maildir.c | 2 --
libbalsa/mailbox_mbox.c | 3 ---
libbalsa/mailbox_mh.c | 2 --
5 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3bc10ae..2b5c9ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2013-05-18 Peter Bloomfield
+ * libbalsa/mailbox_local.c: avoid zero-divide.
+ * libbalsa/mailbox_maildir.c (libbalsa_mailbox_maildir_open): do
+ not change LibBalsaMailboxLocal::sync_time or ::sync_cnt.
+ * libbalsa/mailbox_mbox.c (libbalsa_mailbox_mbox_open): ditto.
+ * libbalsa/mailbox_mh.c (libbalsa_mailbox_mh_open): ditto.
+
+2013-05-18 Peter Bloomfield
+
* libbalsa/mailbox_local.c: restore syncing mailbox in a thread.
2013-05-16 Peter Bloomfield
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index 1bb3108..292bb52 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -2197,7 +2197,8 @@ lbm_local_sync_queue(LibBalsaMailboxLocal * local)
/* queue sync job so that the delay is at least five times longer
* than the syncing time. Otherwise large mailbox owners will be
* annnoyed. */
- schedule_delay = (local->sync_time*5000)/local->sync_cnt;
+ schedule_delay =
+ local->sync_cnt ? (local->sync_time * 5000) / local->sync_cnt : 0;
local->sync_id = g_timeout_add_full(G_PRIORITY_LOW, schedule_delay,
(GSourceFunc)lbm_local_sync_idle,
local, NULL);
diff --git a/libbalsa/mailbox_maildir.c b/libbalsa/mailbox_maildir.c
index 88b8324..23628d3 100644
--- a/libbalsa/mailbox_maildir.c
+++ b/libbalsa/mailbox_maildir.c
@@ -505,8 +505,6 @@ libbalsa_mailbox_maildir_open(LibBalsaMailbox * mailbox, GError **err)
mailbox->unread_messages = 0;
lbm_maildir_parse_subdirs(mdir);
- LIBBALSA_MAILBOX_LOCAL(mailbox)->sync_time = 0;
- LIBBALSA_MAILBOX_LOCAL(mailbox)->sync_cnt = 1;
#ifdef DEBUG
g_print(_("%s: Opening %s Refcount: %d\n"),
"LibBalsaMailboxMaildir", mailbox->name, mailbox->open_ref);
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index f1e21f7..98e0d8d 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -742,9 +742,6 @@ libbalsa_mailbox_mbox_open(LibBalsaMailbox * mailbox, GError **err)
lbm_mbox_restore(mbox);
parse_mailbox(mbox);
}
-
- LIBBALSA_MAILBOX_LOCAL(mailbox)->sync_time = time(NULL) - t0;
- LIBBALSA_MAILBOX_LOCAL(mailbox)->sync_cnt = 1;
mbox_unlock(mailbox, gmime_stream);
libbalsa_mime_stream_shared_unlock(gmime_stream);
diff --git a/libbalsa/mailbox_mh.c b/libbalsa/mailbox_mh.c
index 5d428ff..f9c7541 100644
--- a/libbalsa/mailbox_mh.c
+++ b/libbalsa/mailbox_mh.c
@@ -541,8 +541,6 @@ libbalsa_mailbox_mh_open(LibBalsaMailbox * mailbox, GError **err)
mailbox->unread_messages = 0;
lbm_mh_parse_both(mh);
- LIBBALSA_MAILBOX_LOCAL(mailbox)->sync_time = 0;
- LIBBALSA_MAILBOX_LOCAL(mailbox)->sync_cnt = 1;
#ifdef DEBUG
g_print(_("%s: Opening %s Refcount: %d\n"),
"LibBalsaMailboxMh", mailbox->name, mailbox->open_ref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]