[Commits] [SCM] claws branch, gtk3, updated. 3.16.0-129-g69e78a5

ticho at claws-mail.org ticho at claws-mail.org
Sun Mar 25 12:41:05 CEST 2018


The branch, gtk3 has been updated
       via  69e78a5c4ea363205d4bbe2cbc56aea45768acd6 (commit)
       via  137d4d92f6d197f5d6aec5887d08281d3f2743d6 (commit)
       via  4984812b23b97287b892a07f13ad73bd2245d81b (commit)
       via  94f38a8fdeba557eb3fce230e9ea4eb9941e655d (commit)
       via  7b09966c179ff8cf275288d325ecda3b3f4a278c (commit)
       via  72c9f2413c835b60b09cfecf898a7483539f3367 (commit)
      from  e4274cfcd78d8039995c4f897e3f900ac3c7987e (commit)

Summary of changes:
 src/avatars.c                                      |   11 +++---
 src/common/hooks.c                                 |   14 ++++----
 src/common/hooks.h                                 |    6 ++--
 src/gtk/logwindow.h                                |    2 +-
 src/main.c                                         |   12 +++----
 src/plugins/acpi_notifier/acpi_notifier.c          |    4 +--
 src/plugins/address_keeper/address_keeper.c        |    4 +--
 src/plugins/attachwarner/attachwarner.c            |    4 +--
 src/plugins/bogofilter/bogofilter.c                |   14 ++++----
 src/plugins/bsfilter/bsfilter.c                    |   14 ++++----
 src/plugins/clamd/clamav_plugin.c                  |    4 +--
 src/plugins/clamd/libclamd/clamd-plugin.c          |   36 ++++++++++++--------
 src/plugins/demo/demo.c                            |    4 +--
 src/plugins/fetchinfo/fetchinfo_plugin.c           |    4 +--
 src/plugins/gdata/gdata_plugin.c                   |   10 +++---
 src/plugins/libravatar/libravatar.c                |   16 ++++-----
 src/plugins/newmail/newmail.c                      |    4 +--
 .../notification/notification_foldercheck.c        |    4 +--
 src/plugins/notification/notification_plugin.c     |   32 ++++++++---------
 src/plugins/perl/perl_plugin.c                     |    8 ++---
 src/plugins/pgpcore/autocompletion.c               |    6 ++--
 src/plugins/python/python_plugin.c                 |    4 +--
 src/plugins/spamassassin/spamassassin.c            |   17 +++++----
 src/plugins/vcalendar/vcal_manager.c               |    7 ++--
 src/plugins/vcalendar/vcalendar.c                  |   27 ++++-----------
 src/procheader.c                                   |    8 ++---
 src/statusbar.c                                    |    8 ++---
 27 files changed, 139 insertions(+), 145 deletions(-)


- Log -----------------------------------------------------------------
commit 69e78a5c4ea363205d4bbe2cbc56aea45768acd6
Author: wwp <wwp at free.fr>
Date:   Mon Mar 19 11:03:09 2018 +0100

    Fixed hook_id declarations to be gulong instead of guint.
    Made statusbar's hook_id static.
    Rework hook_id magic value, now 0 instead of -1, and use a define (HOOK_NONE)
    everywhere instead of 0. Any hook_id must be initialized to HOOK_NONE.
    Hook_id that get invalidated or reset get the same HOOK_NONE value.

diff --git a/src/avatars.c b/src/avatars.c
index e731194..372f30b 100644
--- a/src/avatars.c
+++ b/src/avatars.c
@@ -32,7 +32,7 @@
 #include "prefs_common.h"
 #include "avatars.h"
 
-static guint avatar_render_hook_id = -1;
+static gulong avatar_render_hook_id = HOOK_NONE;
 
 AvatarRender *avatars_avatarrender_new(MsgInfo *msginfo)
 {
@@ -93,21 +93,20 @@ gboolean avatars_internal_rendering_hook(gpointer source, gpointer data)
 
 void avatars_init(void)
 {
-	if (avatar_render_hook_id != (guint) -1) {
+	if (avatar_render_hook_id != HOOK_NONE) {
 		g_warning("Internal avatars rendering already initialized");
 		return;
 	}
 	avatar_render_hook_id = hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST, avatars_internal_rendering_hook, NULL);
-	if (avatar_render_hook_id == (guint) -1) {
+	if (avatar_render_hook_id == HOOK_NONE) {
 		g_warning("Failed to register avatars internal rendering hook");
 	}
 }
 
 void avatars_done(void)
 {
-	if (avatar_render_hook_id != (guint) -1) {
+	if (avatar_render_hook_id != HOOK_NONE) {
 		hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST, avatar_render_hook_id);
-		avatar_render_hook_id = -1;
+		avatar_render_hook_id = HOOK_NONE;
 	}
 }
-
diff --git a/src/common/hooks.c b/src/common/hooks.c
index b66e54e..230fb71 100644
--- a/src/common/hooks.c
+++ b/src/common/hooks.c
@@ -46,21 +46,21 @@ static GHookList *hooks_get_hooklist(const gchar *hooklist_name)
 	return hooklist;
 }
 
-guint hooks_register_hook(const gchar *hooklist_name,
+gulong hooks_register_hook(const gchar *hooklist_name,
 			  SylpheedHookFunction hook_func,
 			  gpointer userdata)
 {
 	GHookList *hooklist;
 	GHook *hook;
 
-	cm_return_val_if_fail(hooklist_name != NULL, (guint)-1);
-	cm_return_val_if_fail(hook_func != NULL, (guint)-1);
+	cm_return_val_if_fail(hooklist_name != NULL, HOOK_NONE);
+	cm_return_val_if_fail(hook_func != NULL, HOOK_NONE);
 	
 	hooklist = hooks_get_hooklist(hooklist_name);
-	cm_return_val_if_fail(hooklist != NULL, (guint)-1);
+	cm_return_val_if_fail(hooklist != NULL, HOOK_NONE);
 
 	hook = g_hook_alloc(hooklist);
-	cm_return_val_if_fail(hook != NULL, (guint)-1);
+	cm_return_val_if_fail(hook != NULL, HOOK_NONE);
 
 	hook->func = hook_func;
 	hook->data = userdata;
@@ -68,12 +68,14 @@ guint hooks_register_hook(const gchar *hooklist_name,
 	g_hook_append(hooklist, hook);
 
 	debug_print("registered new hook for '%s' as id %lu\n", hooklist_name, hook->hook_id);
+	if (hook->hook_id == HOOK_NONE)
+		g_error("unexpected hook ID 0");
 
 	return hook->hook_id;
 }
 
 void hooks_unregister_hook(const gchar *hooklist_name,
-			   guint hook_id)
+			   gulong hook_id)
 {
 	GHookList *hooklist;
 	GHook *hook;
diff --git a/src/common/hooks.h b/src/common/hooks.h
index 84de822..bbb4d3e 100644
--- a/src/common/hooks.h
+++ b/src/common/hooks.h
@@ -22,14 +22,16 @@
 
 #include <glib.h>
 
+#define HOOK_NONE 0
+
 typedef gboolean (*SylpheedHookFunction)	(gpointer source,
 						 gpointer userdata);
 
-guint hooks_register_hook	(const gchar		*hooklist_name,
+gulong hooks_register_hook	(const gchar		*hooklist_name,
 				 SylpheedHookFunction	 hook_func,
 				 gpointer		 userdata);
 void hooks_unregister_hook	(const gchar		*hooklist_name,
-				 guint			 hook_id);
+				 gulong			 hook_id);
 gboolean hooks_invoke		(const gchar		*hooklist_name,
 				 gpointer		 source);
 
diff --git a/src/gtk/logwindow.h b/src/gtk/logwindow.h
index 318b745..75a7def 100644
--- a/src/gtk/logwindow.h
+++ b/src/gtk/logwindow.h
@@ -44,7 +44,7 @@ struct _LogWindow
 
 	gboolean clip;
 	guint	 clip_length;
-	guint 	 hook_id;
+	gulong 	 hook_id;
 	GtkTextBuffer *buffer;
 	GtkTextTag *error_tag;
 	GtkTextMark *end_mark;
diff --git a/src/main.c b/src/main.c
index cb86e59..a0b8f82 100644
--- a/src/main.c
+++ b/src/main.c
@@ -864,17 +864,17 @@ static void main_dump_features_list(gboolean show_debug_only)
 }
 
 #ifdef HAVE_DBUS_GLIB
-static guint dbus_item_hook_id = -1;
-static guint dbus_folder_hook_id = -1;
+static gulong dbus_item_hook_id = HOOK_NONE;
+static gulong dbus_folder_hook_id = HOOK_NONE;
 
 static void uninstall_dbus_status_handler(void)
 {
 	if(awn_proxy)
 		g_object_unref(awn_proxy);
 	awn_proxy = NULL;
-	if (dbus_item_hook_id != (guint) -1)
+	if (dbus_item_hook_id != HOOK_NONE)
 		hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, dbus_item_hook_id);
-	if (dbus_folder_hook_id != (guint) -1)
+	if (dbus_folder_hook_id != HOOK_NONE)
 		hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, dbus_folder_hook_id);
 }
 
@@ -948,14 +948,14 @@ static void install_dbus_status_handler(void)
 			"/com/google/code/Awn",
 			"com.google.code.Awn");
 	dbus_item_hook_id = hooks_register_hook (FOLDER_ITEM_UPDATE_HOOKLIST, dbus_status_update_item_hook, NULL);
-	if (dbus_item_hook_id == (guint) -1) {
+	if (dbus_item_hook_id == HOOK_NONE) {
 		g_warning("Failed to register folder item update hook");
 		uninstall_dbus_status_handler();
 		return;
 	}
 
 	dbus_folder_hook_id = hooks_register_hook (FOLDER_UPDATE_HOOKLIST, dbus_status_update_folder_hook, NULL);
-	if (dbus_folder_hook_id == (guint) -1) {
+	if (dbus_folder_hook_id == HOOK_NONE) {
 		g_warning("Failed to register folder update hook");
 		uninstall_dbus_status_handler();
 		return;
diff --git a/src/plugins/acpi_notifier/acpi_notifier.c b/src/plugins/acpi_notifier/acpi_notifier.c
index 03051a7..50430c6 100644
--- a/src/plugins/acpi_notifier/acpi_notifier.c
+++ b/src/plugins/acpi_notifier/acpi_notifier.c
@@ -97,8 +97,8 @@ PredefinedAcpis known_implementations[] = {
 	{NULL, NULL, NULL, NULL, FALSE, NULL}
 };
 
-static guint folder_hook_id;
-static guint alertpanel_hook_id;
+static gulong folder_hook_id = HOOK_NONE;
+static gulong alertpanel_hook_id = HOOK_NONE;
 
 struct AcpiNotifierPage
 {
diff --git a/src/plugins/address_keeper/address_keeper.c b/src/plugins/address_keeper/address_keeper.c
index c85b6fb..a5aab85 100644
--- a/src/plugins/address_keeper/address_keeper.c
+++ b/src/plugins/address_keeper/address_keeper.c
@@ -33,7 +33,7 @@
 #include "prefs_common.h"
 
 /** Identifier for the hook. */
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 
 /**
  * Extracts name from an address.
@@ -248,7 +248,7 @@ gint plugin_init(gchar **error)
 	hook_id = hooks_register_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, 
 				      addrk_before_send_hook, NULL);
 	
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register check before send hook"));
 		return -1;
 	}
diff --git a/src/plugins/attachwarner/attachwarner.c b/src/plugins/attachwarner/attachwarner.c
index 3f782f5..9132604 100644
--- a/src/plugins/attachwarner/attachwarner.c
+++ b/src/plugins/attachwarner/attachwarner.c
@@ -31,7 +31,7 @@
 #include "prefs_common.h"
 
 /** Identifier for the hook. */
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 
 static AttachWarnerMention *aw_matcherlist_string_match(MatcherList *matchers, gchar *str, gchar *sig_separator)
 {
@@ -248,7 +248,7 @@ gint plugin_init(gchar **error)
 	hook_id = hooks_register_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, 
 				      attwarn_before_send_hook, NULL);
 	
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register check before send hook"));
 		return -1;
 	}
diff --git a/src/plugins/bogofilter/bogofilter.c b/src/plugins/bogofilter/bogofilter.c
index 85c5ddb..a0823e9 100644
--- a/src/plugins/bogofilter/bogofilter.c
+++ b/src/plugins/bogofilter/bogofilter.c
@@ -80,7 +80,7 @@
 
 #define PLUGIN_NAME (_("Bogofilter"))
 
-static guint hook_id = -1;
+static gulong hook_id = HOOK_NONE;
 static MessageCallback message_callback;
 
 static BogofilterConfig config;
@@ -901,7 +901,7 @@ gint plugin_init(gchar **error)
 {
 	gchar *rcpath;
 
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 
 	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
 				VERSION_NUMERIC, PLUGIN_NAME, error))
@@ -959,7 +959,7 @@ FolderItem *bogofilter_get_spam_folder(MsgInfo *msginfo)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		bogofilter_unregister_hook();
 	}
 #ifdef USE_PTHREAD
@@ -1021,9 +1021,9 @@ struct PluginFeature *plugin_provides(void)
 
 void bogofilter_register_hook(void)
 {
-	if (hook_id == (guint) -1)
+	if (hook_id == HOOK_NONE)
 		hook_id = hooks_register_hook(MAIL_LISTFILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -1031,8 +1031,8 @@ void bogofilter_register_hook(void)
 
 void bogofilter_unregister_hook(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		hooks_unregister_hook(MAIL_LISTFILTERING_HOOKLIST, hook_id);
 	}
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 }
diff --git a/src/plugins/bsfilter/bsfilter.c b/src/plugins/bsfilter/bsfilter.c
index 9390983..58e0126 100644
--- a/src/plugins/bsfilter/bsfilter.c
+++ b/src/plugins/bsfilter/bsfilter.c
@@ -81,7 +81,7 @@
 
 #define PLUGIN_NAME (_("Bsfilter"))
 
-static guint hook_id = -1;
+static gulong hook_id = HOOK_NONE;
 static MessageCallback message_callback;
 
 static BsfilterConfig config;
@@ -530,7 +530,7 @@ void bsfilter_set_message_callback(MessageCallback callback)
 gint plugin_init(gchar **error)
 {
 	gchar *rcpath;
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 
 	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
 				VERSION_NUMERIC, PLUGIN_NAME, error))
@@ -592,7 +592,7 @@ FolderItem *bsfilter_get_spam_folder(MsgInfo *msginfo)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		bsfilter_unregister_hook();
 	}
 #ifdef USE_PTHREAD
@@ -654,9 +654,9 @@ struct PluginFeature *plugin_provides(void)
 
 void bsfilter_register_hook(void)
 {
-	if (hook_id == (guint) -1)
+	if (hook_id == HOOK_NONE)
 		hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -664,8 +664,8 @@ void bsfilter_register_hook(void)
 
 void bsfilter_unregister_hook(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
 	}
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 }
diff --git a/src/plugins/clamd/clamav_plugin.c b/src/plugins/clamd/clamav_plugin.c
index 8a2736c..7bb3b39 100644
--- a/src/plugins/clamd/clamav_plugin.c
+++ b/src/plugins/clamd/clamav_plugin.c
@@ -46,7 +46,7 @@
 
 #define PLUGIN_NAME (_("Clam AntiVirus"))
 
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 static MessageCallback message_callback;
 
 static ClamAvConfig config;
@@ -276,7 +276,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register mail filtering hook"));
 		return -1;
 	}
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
index d5f484c..3df83cd 100644
--- a/src/plugins/demo/demo.c
+++ b/src/plugins/demo/demo.c
@@ -39,7 +39,7 @@ gboolean my_log_hook(gpointer source, gpointer data)
 	return FALSE;
 }
 
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 
 gint plugin_init(gchar **error)
 {
@@ -48,7 +48,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, my_log_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register log text hook"));
 		return -1;
 	}
diff --git a/src/plugins/fetchinfo/fetchinfo_plugin.c b/src/plugins/fetchinfo/fetchinfo_plugin.c
index bf350dd..032c53c 100644
--- a/src/plugins/fetchinfo/fetchinfo_plugin.c
+++ b/src/plugins/fetchinfo/fetchinfo_plugin.c
@@ -44,7 +44,7 @@
 #include "procheader.h"
 #include "plugin.h"
 
-static guint mail_receive_hook_id;
+static gulong mail_receive_hook_id = HOOK_NONE;
 
 static FetchinfoConfig config;
 
@@ -162,7 +162,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	mail_receive_hook_id = hooks_register_hook(MAIL_RECEIVE_HOOKLIST, mail_receive_hook, NULL);
-	if (mail_receive_hook_id == (guint) -1) {
+	if (mail_receive_hook_id == HOOK_NONE) {
 		/* i18n: Possible error message during plugin load */
 		*error = g_strdup(_("Failed to register mail receive hook"));
 		return -1;
diff --git a/src/plugins/gdata/gdata_plugin.c b/src/plugins/gdata/gdata_plugin.c
index 387522d..e623d96 100644
--- a/src/plugins/gdata/gdata_plugin.c
+++ b/src/plugins/gdata/gdata_plugin.c
@@ -42,9 +42,9 @@
 #include "cm_gdata_contacts.h"
 #include "cm_gdata_prefs.h"
 
-static guint hook_address_completion;
-static guint hook_offline_switch;
-static guint timer_query_contacts = 0;
+static gulong hook_address_completion= 0;
+static gulong hook_offline_switch = 0;
+static gulong timer_query_contacts = 0;
 
 static gboolean my_address_completion_build_list_hook(gpointer source, gpointer data)
 {
@@ -104,13 +104,13 @@ gint plugin_init(gchar **error)
 
   hook_address_completion = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST,
       my_address_completion_build_list_hook, NULL);
-  if(hook_address_completion == (guint) -1) {
+  if(hook_address_completion == 0) {
     *error = g_strdup(_("Failed to register address completion hook in the GData plugin"));
     return -1;
   }
 
   hook_offline_switch = hooks_register_hook(OFFLINE_SWITCH_HOOKLIST, my_offline_switch_hook, NULL);
-  if(hook_offline_switch == (guint) -1) {
+  if(hook_offline_switch == 0) {
     hooks_unregister_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, hook_address_completion);
     *error = g_strdup(_("Failed to register offline switch hook in the GData plugin"));
     return -1;
diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c
index b8da96c..f07c6a2 100644
--- a/src/plugins/libravatar/libravatar.c
+++ b/src/plugins/libravatar/libravatar.c
@@ -49,8 +49,8 @@ static const char *def_mode[] = {
 	"retro"
 };
 
-static guint update_hook_id;
-static guint render_hook_id;
+static gulong update_hook_id = HOOK_NONE;
+static gulong render_hook_id = HOOK_NONE;
 static gchar *cache_dir = NULL; /* dir-separator terminated */
 
 static gboolean libravatar_header_update_hook(gpointer source, gpointer data)
@@ -313,15 +313,15 @@ static void missing_cache_done()
 
 static void unregister_hooks()
 {
-	if (render_hook_id != (guint) -1) {
+	if (render_hook_id != HOOK_NONE) {
 		hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
 				      render_hook_id);
-		render_hook_id = -1;
+		render_hook_id = HOOK_NONE;
 	}
-	if (update_hook_id != (guint) -1) {
+	if (update_hook_id != HOOK_NONE) {
 		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
 				      update_hook_id);
-		update_hook_id = -1;
+		update_hook_id = HOOK_NONE;
 	}
 }
 
@@ -341,7 +341,7 @@ gint plugin_init(gchar **error)
 	update_hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
 					     libravatar_header_update_hook,
 					     NULL);
-	if (update_hook_id == (guint) -1) {
+	if (update_hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register avatar header update hook"));
 		return -1;
 	}
@@ -349,7 +349,7 @@ gint plugin_init(gchar **error)
 	render_hook_id = hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
 					     libravatar_image_render_hook,
 					     NULL);
-	if (render_hook_id == (guint) -1) {
+	if (render_hook_id == HOOK_NONE) {
 		unregister_hooks();
 		*error = g_strdup(_("Failed to register avatar image render hook"));
 		return -1;
diff --git a/src/plugins/newmail/newmail.c b/src/plugins/newmail/newmail.c
index 1d77954..46bc1bc 100644
--- a/src/plugins/newmail/newmail.c
+++ b/src/plugins/newmail/newmail.c
@@ -36,7 +36,7 @@
 #define DEFAULT_DIR	"Mail"
 #define BUFSIZE		2048
 
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 
 static FILE *NewLog   = NULL;
 static char *LogName  = NULL;
@@ -107,7 +107,7 @@ gint plugin_init (gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook (MAIL_POSTFILTERING_HOOKLIST, newmail_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup (_("Failed to register newmail hook"));
 		return (-1);
 	}
diff --git a/src/plugins/notification/notification_foldercheck.c b/src/plugins/notification/notification_foldercheck.c
index 80d6898..43e22c9 100644
--- a/src/plugins/notification/notification_foldercheck.c
+++ b/src/plugins/notification/notification_foldercheck.c
@@ -81,7 +81,7 @@ static GdkPixbuf *foldernoselectopen_pixbuf;
 static GArray *specific_folder_array;
 static guint   specific_folder_array_size;
 
-static guint hook_folder_update;
+static gulong hook_folder_update;
 
 
 /* defines */
@@ -139,7 +139,7 @@ guint notification_register_folder_specific_list(gchar *node_name)
     /* "The hook is registered" is bound to "the array is allocated" */
     hook_folder_update = hooks_register_hook(FOLDER_UPDATE_HOOKLIST,
 					     my_folder_update_hook, NULL);
-    if(hook_folder_update == (guint) -1) {
+    if(hook_folder_update == 0) {
       debug_print("Warning: Failed to register hook to folder update "
 		  "hooklist. "
 		  "Strange things can occur when deleting folders.\n");
diff --git a/src/plugins/notification/notification_plugin.c b/src/plugins/notification/notification_plugin.c
index 1cc8c9f..2798e3a 100644
--- a/src/plugins/notification/notification_plugin.c
+++ b/src/plugins/notification/notification_plugin.c
@@ -64,14 +64,14 @@ static gboolean my_update_theme_hook(gpointer, gpointer);
 static gboolean trayicon_startup_idle(gpointer);
 #endif
 
-static guint hook_f_item;
-static guint hook_f;
-static guint hook_m_info;
-static guint hook_offline;
-static guint hook_mw_close;
-static guint hook_got_iconified;
-static guint hook_account;
-static guint hook_theme_changed;
+static gulong hook_f_item;
+static gulong hook_f;
+static gulong hook_m_info;
+static gulong hook_offline;
+static gulong hook_mw_close;
+static gulong hook_got_iconified;
+static gulong hook_account;
+static gulong hook_theme_changed;
 
 #ifdef NOTIFICATION_BANNER
 static GSList* banner_collected_msgs;
@@ -224,7 +224,7 @@ gint plugin_init(gchar **error)
 
   hook_f_item = hooks_register_hook(FOLDER_ITEM_UPDATE_HOOKLIST,
 				    my_folder_item_update_hook, NULL);
-  if(hook_f_item == (guint) -1) {
+  if(hook_f_item == 0) {
     *error = g_strdup(_("Failed to register folder item update hook in the "
 			"Notification plugin"));
     return -1;
@@ -232,7 +232,7 @@ gint plugin_init(gchar **error)
 
   hook_f = hooks_register_hook(FOLDER_UPDATE_HOOKLIST,
 			       my_folder_update_hook, NULL);
-  if(hook_f == (guint) -1) {
+  if(hook_f == 0) {
     *error = g_strdup(_("Failed to register folder update hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -242,7 +242,7 @@ gint plugin_init(gchar **error)
 
   hook_m_info = hooks_register_hook(MSGINFO_UPDATE_HOOKLIST,
 				    my_msginfo_update_hook, NULL);
-  if(hook_m_info == (guint) -1) {
+  if(hook_m_info == 0) {
     *error = g_strdup(_("Failed to register msginfo update hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -252,7 +252,7 @@ gint plugin_init(gchar **error)
 
   hook_offline = hooks_register_hook(OFFLINE_SWITCH_HOOKLIST,
 				     my_offline_switch_hook, NULL);
-  if(hook_offline == (guint) -1) {
+  if(hook_offline == 0) {
     *error = g_strdup(_("Failed to register offline switch hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -263,7 +263,7 @@ gint plugin_init(gchar **error)
 
   hook_mw_close = hooks_register_hook(MAIN_WINDOW_CLOSE,
 				      my_main_window_close_hook, NULL);
-  if(hook_mw_close == (guint) -1) {
+  if(hook_mw_close == 0) {
     *error = g_strdup(_("Failed to register main window close hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -276,7 +276,7 @@ gint plugin_init(gchar **error)
   hook_got_iconified = hooks_register_hook(MAIN_WINDOW_GOT_ICONIFIED,
 					   my_main_window_got_iconified_hook,
 					   NULL);
-  if(hook_got_iconified == (guint) -1) {
+  if(hook_got_iconified == 0) {
     *error = g_strdup(_("Failed to register got iconified hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -289,7 +289,7 @@ gint plugin_init(gchar **error)
 
   hook_account = hooks_register_hook(ACCOUNT_LIST_CHANGED_HOOKLIST,
 				     my_account_list_changed_hook, NULL);
-  if (hook_account == (guint) -1) {
+  if (hook_account == 0) {
     *error = g_strdup(_("Failed to register account list changed hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -302,7 +302,7 @@ gint plugin_init(gchar **error)
   }
 
   hook_theme_changed = hooks_register_hook(THEME_CHANGED_HOOKLIST, my_update_theme_hook, NULL);
-  if(hook_theme_changed == (guint) -1) {
+  if(hook_theme_changed == 0) {
     *error = g_strdup(_("Failed to register theme change hook in the "
       "Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
diff --git a/src/plugins/perl/perl_plugin.c b/src/plugins/perl/perl_plugin.c
index 1854eb0..3d68b8a 100644
--- a/src/plugins/perl/perl_plugin.c
+++ b/src/plugins/perl/perl_plugin.c
@@ -90,8 +90,8 @@ EXTERN_C void xs_init(pTHX);
 EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
 
 /* plugin stuff */
-static guint             filtering_hook_id;
-static guint             manual_filtering_hook_id;
+static guint             filtering_hook_id = HOOK_NONE;
+static guint             manual_filtering_hook_id = HOOK_NONE;
 static MailFilteringData *mail_filtering_data  = NULL;
 static MsgInfo           *msginfo              = NULL;
 static gboolean          stop_filtering        = FALSE;
@@ -2290,14 +2290,14 @@ gint plugin_init(gchar **error)
   filtering_hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST,
             my_filtering_hook,
             GUINT_TO_POINTER(AUTO_FILTER));
-  if(filtering_hook_id == (guint) -1) {
+  if(filtering_hook_id == HOOK_NONE) {
     *error = g_strdup("Failed to register mail filtering hook");
     return -1;
   }
   manual_filtering_hook_id = hooks_register_hook(MAIL_MANUAL_FILTERING_HOOKLIST,
              my_filtering_hook,
              GUINT_TO_POINTER(MANU_FILTER));
-  if(manual_filtering_hook_id == (guint) -1) {
+  if(manual_filtering_hook_id == HOOK_NONE) {
     hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, filtering_hook_id);
     *error = g_strdup("Failed to register manual mail filtering hook");
     return -1;
diff --git a/src/plugins/pgpcore/autocompletion.c b/src/plugins/pgpcore/autocompletion.c
index a4f15a6..c3d853f 100644
--- a/src/plugins/pgpcore/autocompletion.c
+++ b/src/plugins/pgpcore/autocompletion.c
@@ -39,7 +39,7 @@
 #include "hooks.h"
 #include "utils.h"
 
-static guint autocompletion_hook_id = 0;
+static gulong autocompletion_hook_id = HOOK_NONE;
 
 static gboolean pgp_autocompletion_hook(gpointer source, gpointer data)
 {
@@ -116,7 +116,7 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data)
 
 gboolean autocompletion_done(void)
 {
-	if (autocompletion_hook_id > 0)
+	if (autocompletion_hook_id != HOOK_NONE)
 	{
 		hooks_unregister_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, autocompletion_hook_id);
 
@@ -128,7 +128,7 @@ gboolean autocompletion_done(void)
 
 gint autocompletion_init(gchar ** error)
 {
-	if ((autocompletion_hook_id = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, pgp_autocompletion_hook, NULL)) == -1)
+	if ((autocompletion_hook_id = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, pgp_autocompletion_hook, NULL)) == HOOK_NONE)
 	{
 		*error = g_strdup(_("Failed to register PGP address autocompletion hook"));
 		return -1;
diff --git a/src/plugins/python/python_plugin.c b/src/plugins/python/python_plugin.c
index 1634a76..dc8b1d6 100644
--- a/src/plugins/python/python_plugin.c
+++ b/src/plugins/python/python_plugin.c
@@ -56,7 +56,7 @@ static GSList *python_compose_scripts_names = NULL;
 
 static GtkWidget *python_console = NULL;
 
-static guint hook_compose_create;
+static gulong hook_compose_create = 0;
 
 static gboolean python_console_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
@@ -653,7 +653,7 @@ gint plugin_init(gchar **error)
 
   /* load hooks */
   hook_compose_create = hooks_register_hook(COMPOSE_CREATED_HOOKLIST, my_compose_create_hook, NULL);
-  if(hook_compose_create == (guint) -1) {
+  if(hook_compose_create == 0) {
     *error = g_strdup(_("Failed to register \"compose create hook\" in the Python plugin"));
     return -1;
   }
diff --git a/src/plugins/spamassassin/spamassassin.c b/src/plugins/spamassassin/spamassassin.c
index 84aa9a6..5df6de1 100644
--- a/src/plugins/spamassassin/spamassassin.c
+++ b/src/plugins/spamassassin/spamassassin.c
@@ -81,7 +81,7 @@ enum {
     TIMEOUT_RUNNING = 1 << 1,
 };
 
-static guint hook_id = -1;
+static gulong hook_id = HOOK_NONE;
 static int flags = SPAMC_RAW_MODE | SPAMC_SAFE_FALLBACK | SPAMC_CHECK_ONLY;
 static MessageCallback message_callback;
 
@@ -513,7 +513,7 @@ gboolean spamassassin_check_username(void)
 	if (config.username == NULL || config.username[0] == '\0') {
 		config.username = (gchar*)g_get_user_name();
 		if (config.username == NULL) {
-			if (hook_id != (guint) -1) {
+			if (hook_id != HOOK_NONE) {
 				spamassassin_unregister_hook();
 			}
 			procmsg_unregister_spam_learner(spamassassin_learn);
@@ -533,7 +533,7 @@ gint plugin_init(gchar **error)
 {
 	gchar *rcpath;
 
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 
 	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
 				VERSION_NUMERIC, PLUGIN_NAME, error))
@@ -571,7 +571,7 @@ gint plugin_init(gchar **error)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		spamassassin_unregister_hook();
 	}
 	g_free(config.hostname);
@@ -629,9 +629,9 @@ struct PluginFeature *plugin_provides(void)
 
 void spamassassin_register_hook(void)
 {
-	if (hook_id == (guint) -1)
+	if (hook_id == HOOK_NONE)
 		hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -639,10 +639,10 @@ void spamassassin_register_hook(void)
 
 void spamassassin_unregister_hook(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
 	}
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 }
 
 FolderItem *spamassassin_get_spam_folder(MsgInfo *msginfo)
@@ -670,4 +670,3 @@ FolderItem *spamassassin_get_spam_folder(MsgInfo *msginfo)
 	debug_print("SA spam dir: %s\n", folder_item_get_path(item));
 	return item;
 }
-
diff --git a/src/procheader.c b/src/procheader.c
index d261642..174e283 100644
--- a/src/procheader.c
+++ b/src/procheader.c
@@ -588,7 +588,7 @@ static gboolean avatar_from_some_face(gpointer source, gpointer userdata)
 	return FALSE;
 }
 
-static guint avatar_hook_id = 0;
+static gulong avatar_hook_id = HOOK_NONE;
 
 static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 			     gboolean full, gboolean decrypted)
@@ -644,11 +644,11 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 	
 	msginfo->inreplyto = NULL;
 
-	if (avatar_hook_id == 0 && (prefs_common.enable_avatars & AVATARS_ENABLE_CAPTURE)) {
+	if (avatar_hook_id == HOOK_NONE && (prefs_common.enable_avatars & AVATARS_ENABLE_CAPTURE)) {
 		avatar_hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST, avatar_from_some_face, NULL);
-	} else if (avatar_hook_id != 0 && !(prefs_common.enable_avatars & AVATARS_ENABLE_CAPTURE)) {
+	} else if (avatar_hook_id != HOOK_NONE && !(prefs_common.enable_avatars & AVATARS_ENABLE_CAPTURE)) {
 		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST, avatar_hook_id);
-		avatar_hook_id = 0;
+		avatar_hook_id = HOOK_NONE;
 	}
 
 	while ((hnum = get_one_field(&buf, data, hentry)) != -1) {
diff --git a/src/statusbar.c b/src/statusbar.c
index 12fdb1d..3d59c45 100644
--- a/src/statusbar.c
+++ b/src/statusbar.c
@@ -37,7 +37,7 @@
 #define BUFFSIZE 1024
 
 static GList *statusbar_list = NULL;
-guint statusbar_puts_all_hook_id = -1;
+static gulong statusbar_puts_all_hook_id = HOOK_NONE;
 
 GtkWidget *statusbar_create(void)
 {
@@ -149,12 +149,12 @@ static gboolean statusbar_puts_all_hook (gpointer source, gpointer data)
 
 void statusbar_verbosity_set(gboolean verbose)
 {
-	if (verbose && (statusbar_puts_all_hook_id == (guint) -1)) {
+	if (verbose && (statusbar_puts_all_hook_id == HOOK_NONE)) {
 		statusbar_puts_all_hook_id =
 			hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, statusbar_puts_all_hook, NULL);
-	} else if (!verbose && (statusbar_puts_all_hook_id != (guint) -1)) {
+	} else if (!verbose && (statusbar_puts_all_hook_id != HOOK_NONE)) {
 		hooks_unregister_hook(LOG_APPEND_TEXT_HOOKLIST, statusbar_puts_all_hook_id);
-		statusbar_puts_all_hook_id = -1;
+		statusbar_puts_all_hook_id = HOOK_NONE;
 		statusbar_pop_all();
 	}
 }

commit 137d4d92f6d197f5d6aec5887d08281d3f2743d6
Author: wwp <wwp at free.fr>
Date:   Sat Mar 17 21:53:20 2018 +0100

    Don't compute charset unless necessary (vcalviewer_get_uid_from_mimeinfo()),
    don't compute charset at all when not used (vcalviewer_get_request_values(),
    vcalviewer_get_reply_values(), de facto solves CID 1372373), possible remnants
    of an old implementation that I couldn't even found in log.

diff --git a/src/plugins/vcalendar/vcalendar.c b/src/plugins/vcalendar/vcalendar.c
index eaf2156..4f06765 100644
--- a/src/plugins/vcalendar/vcalendar.c
+++ b/src/plugins/vcalendar/vcalendar.c
@@ -652,18 +652,18 @@ gchar *vcalviewer_get_uid_from_mimeinfo(MimeInfo *mimeinfo)
 	gchar *res = NULL;
 	VCalEvent *event = NULL;
 
-	if (!charset)
-		charset = CS_WINDOWS_1252;
-	
-	if (!strcasecmp(charset, CS_ISO_8859_1))
-		charset = CS_WINDOWS_1252;
-
 	if (procmime_get_part(tmpfile, mimeinfo) < 0) {
 		g_warning("Can't get mimepart file");	
 		g_free(tmpfile);
 		return NULL;
 	}
 	
+	if (!charset)
+		charset = CS_WINDOWS_1252;
+
+	if (!strcasecmp(charset, CS_ISO_8859_1))
+		charset = CS_WINDOWS_1252;
+
 	compstr = file_read_to_str(tmpfile);
 	
 	event = vcal_get_event_from_ical(compstr, charset);
@@ -680,22 +680,14 @@ gchar *vcalviewer_get_uid_from_mimeinfo(MimeInfo *mimeinfo)
 static void vcalviewer_get_request_values(VCalViewer *vcalviewer, MimeInfo *mimeinfo, gboolean is_todo) 
 {
 	VCalEvent *saved_event = NULL;
-	const gchar *charset = procmime_mimeinfo_get_parameter(mimeinfo, "charset");
 	const gchar *saveme =  procmime_mimeinfo_get_parameter(mimeinfo, "vcalsave");
 	
 	if (!vcalviewer->event)
 		return;
 
-	if (!charset)
-		charset = CS_WINDOWS_1252;
-	
-	if (!strcasecmp(charset, CS_ISO_8859_1))
-		charset = CS_WINDOWS_1252;
-
 	/* see if we have it registered and more recent */
 	saved_event = vcal_manager_load_event(vcalviewer->event->uid);
 	if (saved_event && saved_event->sequence >= vcalviewer->event->sequence) {
-		charset = CS_INTERNAL;
 		saved_event->method = vcalviewer->event->method;
 		vcalviewer_display_event(vcalviewer, saved_event);
 		vcal_manager_free_event(saved_event);
@@ -714,7 +706,6 @@ static void vcalviewer_get_request_values(VCalViewer *vcalviewer, MimeInfo *mime
 
 static void vcalviewer_get_reply_values(VCalViewer *vcalviewer, MimeInfo *mimeinfo) 
 {
-	const gchar *charset = procmime_mimeinfo_get_parameter(mimeinfo, "charset");
 	VCalEvent *saved_event = NULL;
 	gchar *attendee = NULL, *label = NULL;
 	Answer *answer = NULL;
@@ -722,12 +713,6 @@ static void vcalviewer_get_reply_values(VCalViewer *vcalviewer, MimeInfo *mimein
 	if (!vcalviewer->event)
 		return;
 
-	if (!charset)
-		charset = CS_WINDOWS_1252;
-	
-	if (!strcasecmp(charset, CS_ISO_8859_1))
-		charset = CS_WINDOWS_1252;
-
 	if (!vcalviewer->event->answers || g_slist_length(vcalviewer->event->answers) > 1) {
 		g_warning("strange, no answers or more than one");
 	} 

commit 4984812b23b97287b892a07f13ad73bd2245d81b
Author: wwp <wwp at free.fr>
Date:   Sat Mar 17 21:28:00 2018 +0100

    Fix possible access to uninitilized folder pointer (CID 1402515),
    add a warning if vcal folder's not found.

diff --git a/src/plugins/vcalendar/vcal_manager.c b/src/plugins/vcalendar/vcal_manager.c
index 251adc9..8b9a9b5 100644
--- a/src/plugins/vcalendar/vcal_manager.c
+++ b/src/plugins/vcalendar/vcal_manager.c
@@ -1451,10 +1451,11 @@ static gboolean vcal_manager_send (PrefsAccount 	*account,
 	g_free(msgpath);
 
 	folder = folder_find_from_name ("vCalendar", vcal_folder_get_class());
-	if (folder)
+	if (folder) {
 		folder_item_scan(folder->inbox);
-
-	vcalviewer_reload(folder->inbox);
+		vcalviewer_reload(folder->inbox);
+	} else
+		g_warning("couldn't find vCalendar folder %s", vcal_folder_get_class());
 	return TRUE;
 }
 

commit 94f38a8fdeba557eb3fce230e9ea4eb9941e655d
Author: wwp <wwp at free.fr>
Date:   Sat Mar 17 20:18:22 2018 +0100

    Save us 35 warnings about hooks_register_hook() return checks.

diff --git a/src/avatars.c b/src/avatars.c
index ce03cdc..e731194 100644
--- a/src/avatars.c
+++ b/src/avatars.c
@@ -93,19 +93,19 @@ gboolean avatars_internal_rendering_hook(gpointer source, gpointer data)
 
 void avatars_init(void)
 {
-	if (avatar_render_hook_id != -1) {
+	if (avatar_render_hook_id != (guint) -1) {
 		g_warning("Internal avatars rendering already initialized");
 		return;
 	}
 	avatar_render_hook_id = hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST, avatars_internal_rendering_hook, NULL);
-	if (avatar_render_hook_id == -1) {
+	if (avatar_render_hook_id == (guint) -1) {
 		g_warning("Failed to register avatars internal rendering hook");
 	}
 }
 
 void avatars_done(void)
 {
-	if (avatar_render_hook_id != -1) {
+	if (avatar_render_hook_id != (guint) -1) {
 		hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST, avatar_render_hook_id);
 		avatar_render_hook_id = -1;
 	}
diff --git a/src/main.c b/src/main.c
index c404a3d..cb86e59 100644
--- a/src/main.c
+++ b/src/main.c
@@ -872,9 +872,9 @@ static void uninstall_dbus_status_handler(void)
 	if(awn_proxy)
 		g_object_unref(awn_proxy);
 	awn_proxy = NULL;
-	if (dbus_item_hook_id != -1)
+	if (dbus_item_hook_id != (guint) -1)
 		hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, dbus_item_hook_id);
-	if (dbus_folder_hook_id != -1)
+	if (dbus_folder_hook_id != (guint) -1)
 		hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, dbus_folder_hook_id);
 }
 
@@ -948,14 +948,14 @@ static void install_dbus_status_handler(void)
 			"/com/google/code/Awn",
 			"com.google.code.Awn");
 	dbus_item_hook_id = hooks_register_hook (FOLDER_ITEM_UPDATE_HOOKLIST, dbus_status_update_item_hook, NULL);
-	if (dbus_item_hook_id == -1) {
+	if (dbus_item_hook_id == (guint) -1) {
 		g_warning("Failed to register folder item update hook");
 		uninstall_dbus_status_handler();
 		return;
 	}
 
 	dbus_folder_hook_id = hooks_register_hook (FOLDER_UPDATE_HOOKLIST, dbus_status_update_folder_hook, NULL);
-	if (dbus_folder_hook_id == -1) {
+	if (dbus_folder_hook_id == (guint) -1) {
 		g_warning("Failed to register folder update hook");
 		uninstall_dbus_status_handler();
 		return;
diff --git a/src/plugins/address_keeper/address_keeper.c b/src/plugins/address_keeper/address_keeper.c
index d85d949..c85b6fb 100644
--- a/src/plugins/address_keeper/address_keeper.c
+++ b/src/plugins/address_keeper/address_keeper.c
@@ -248,7 +248,7 @@ gint plugin_init(gchar **error)
 	hook_id = hooks_register_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, 
 				      addrk_before_send_hook, NULL);
 	
-	if (hook_id == -1) {
+	if (hook_id == (guint) -1) {
 		*error = g_strdup(_("Failed to register check before send hook"));
 		return -1;
 	}
diff --git a/src/plugins/attachwarner/attachwarner.c b/src/plugins/attachwarner/attachwarner.c
index 7ada74b..3f782f5 100644
--- a/src/plugins/attachwarner/attachwarner.c
+++ b/src/plugins/attachwarner/attachwarner.c
@@ -248,7 +248,7 @@ gint plugin_init(gchar **error)
 	hook_id = hooks_register_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, 
 				      attwarn_before_send_hook, NULL);
 	
-	if (hook_id == -1) {
+	if (hook_id == (guint) -1) {
 		*error = g_strdup(_("Failed to register check before send hook"));
 		return -1;
 	}
diff --git a/src/plugins/bogofilter/bogofilter.c b/src/plugins/bogofilter/bogofilter.c
index 07a764b..85c5ddb 100644
--- a/src/plugins/bogofilter/bogofilter.c
+++ b/src/plugins/bogofilter/bogofilter.c
@@ -959,7 +959,7 @@ FolderItem *bogofilter_get_spam_folder(MsgInfo *msginfo)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != -1) {
+	if (hook_id != (guint) -1) {
 		bogofilter_unregister_hook();
 	}
 #ifdef USE_PTHREAD
@@ -1021,9 +1021,9 @@ struct PluginFeature *plugin_provides(void)
 
 void bogofilter_register_hook(void)
 {
-	if (hook_id == -1)
+	if (hook_id == (guint) -1)
 		hook_id = hooks_register_hook(MAIL_LISTFILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == -1) {
+	if (hook_id == (guint) -1) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -1031,7 +1031,7 @@ void bogofilter_register_hook(void)
 
 void bogofilter_unregister_hook(void)
 {
-	if (hook_id != -1) {
+	if (hook_id != (guint) -1) {
 		hooks_unregister_hook(MAIL_LISTFILTERING_HOOKLIST, hook_id);
 	}
 	hook_id = -1;
diff --git a/src/plugins/bsfilter/bsfilter.c b/src/plugins/bsfilter/bsfilter.c
index 127e677..9390983 100644
--- a/src/plugins/bsfilter/bsfilter.c
+++ b/src/plugins/bsfilter/bsfilter.c
@@ -592,7 +592,7 @@ FolderItem *bsfilter_get_spam_folder(MsgInfo *msginfo)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != -1) {
+	if (hook_id != (guint) -1) {
 		bsfilter_unregister_hook();
 	}
 #ifdef USE_PTHREAD
@@ -654,9 +654,9 @@ struct PluginFeature *plugin_provides(void)
 
 void bsfilter_register_hook(void)
 {
-	if (hook_id == -1)
+	if (hook_id == (guint) -1)
 		hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == -1) {
+	if (hook_id == (guint) -1) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -664,7 +664,7 @@ void bsfilter_register_hook(void)
 
 void bsfilter_unregister_hook(void)
 {
-	if (hook_id != -1) {
+	if (hook_id != (guint) -1) {
 		hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
 	}
 	hook_id = -1;
diff --git a/src/plugins/clamd/clamav_plugin.c b/src/plugins/clamd/clamav_plugin.c
index 7653d47..8a2736c 100644
--- a/src/plugins/clamd/clamav_plugin.c
+++ b/src/plugins/clamd/clamav_plugin.c
@@ -276,7 +276,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == -1) {
+	if (hook_id == (guint) -1) {
 		*error = g_strdup(_("Failed to register mail filtering hook"));
 		return -1;
 	}
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
index 751c33f..d5f484c 100644
--- a/src/plugins/demo/demo.c
+++ b/src/plugins/demo/demo.c
@@ -48,7 +48,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, my_log_hook, NULL);
-	if (hook_id == -1) {
+	if (hook_id == (guint) -1) {
 		*error = g_strdup(_("Failed to register log text hook"));
 		return -1;
 	}
diff --git a/src/plugins/fetchinfo/fetchinfo_plugin.c b/src/plugins/fetchinfo/fetchinfo_plugin.c
index 04faead..bf350dd 100644
--- a/src/plugins/fetchinfo/fetchinfo_plugin.c
+++ b/src/plugins/fetchinfo/fetchinfo_plugin.c
@@ -162,7 +162,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	mail_receive_hook_id = hooks_register_hook(MAIL_RECEIVE_HOOKLIST, mail_receive_hook, NULL);
-	if (mail_receive_hook_id == (guint)-1) {
+	if (mail_receive_hook_id == (guint) -1) {
 		/* i18n: Possible error message during plugin load */
 		*error = g_strdup(_("Failed to register mail receive hook"));
 		return -1;
diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c
index 7ce4341..b8da96c 100644
--- a/src/plugins/libravatar/libravatar.c
+++ b/src/plugins/libravatar/libravatar.c
@@ -313,12 +313,12 @@ static void missing_cache_done()
 
 static void unregister_hooks()
 {
-	if (render_hook_id != -1) {
+	if (render_hook_id != (guint) -1) {
 		hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
 				      render_hook_id);
 		render_hook_id = -1;
 	}
-	if (update_hook_id != -1) {
+	if (update_hook_id != (guint) -1) {
 		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
 				      update_hook_id);
 		update_hook_id = -1;
@@ -341,7 +341,7 @@ gint plugin_init(gchar **error)
 	update_hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
 					     libravatar_header_update_hook,
 					     NULL);
-	if (update_hook_id == -1) {
+	if (update_hook_id == (guint) -1) {
 		*error = g_strdup(_("Failed to register avatar header update hook"));
 		return -1;
 	}
@@ -349,7 +349,7 @@ gint plugin_init(gchar **error)
 	render_hook_id = hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
 					     libravatar_image_render_hook,
 					     NULL);
-	if (render_hook_id == -1) {
+	if (render_hook_id == (guint) -1) {
 		unregister_hooks();
 		*error = g_strdup(_("Failed to register avatar image render hook"));
 		return -1;
diff --git a/src/plugins/newmail/newmail.c b/src/plugins/newmail/newmail.c
index 5888748..1d77954 100644
--- a/src/plugins/newmail/newmail.c
+++ b/src/plugins/newmail/newmail.c
@@ -107,7 +107,7 @@ gint plugin_init (gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook (MAIL_POSTFILTERING_HOOKLIST, newmail_hook, NULL);
-	if (hook_id == -1) {
+	if (hook_id == (guint) -1) {
 		*error = g_strdup (_("Failed to register newmail hook"));
 		return (-1);
 	}
diff --git a/src/plugins/notification/notification_plugin.c b/src/plugins/notification/notification_plugin.c
index 0da3c1f..1cc8c9f 100644
--- a/src/plugins/notification/notification_plugin.c
+++ b/src/plugins/notification/notification_plugin.c
@@ -302,7 +302,7 @@ gint plugin_init(gchar **error)
   }
 
   hook_theme_changed = hooks_register_hook(THEME_CHANGED_HOOKLIST, my_update_theme_hook, NULL);
-  if(hook_theme_changed == (guint)-1) {
+  if(hook_theme_changed == (guint) -1) {
     *error = g_strdup(_("Failed to register theme change hook in the "
       "Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
diff --git a/src/plugins/python/python_plugin.c b/src/plugins/python/python_plugin.c
index 0b0d813..1634a76 100644
--- a/src/plugins/python/python_plugin.c
+++ b/src/plugins/python/python_plugin.c
@@ -653,7 +653,7 @@ gint plugin_init(gchar **error)
 
   /* load hooks */
   hook_compose_create = hooks_register_hook(COMPOSE_CREATED_HOOKLIST, my_compose_create_hook, NULL);
-  if(hook_compose_create == (guint)-1) {
+  if(hook_compose_create == (guint) -1) {
     *error = g_strdup(_("Failed to register \"compose create hook\" in the Python plugin"));
     return -1;
   }
diff --git a/src/plugins/spamassassin/spamassassin.c b/src/plugins/spamassassin/spamassassin.c
index 59fd92a..84aa9a6 100644
--- a/src/plugins/spamassassin/spamassassin.c
+++ b/src/plugins/spamassassin/spamassassin.c
@@ -513,7 +513,7 @@ gboolean spamassassin_check_username(void)
 	if (config.username == NULL || config.username[0] == '\0') {
 		config.username = (gchar*)g_get_user_name();
 		if (config.username == NULL) {
-			if (hook_id != -1) {
+			if (hook_id != (guint) -1) {
 				spamassassin_unregister_hook();
 			}
 			procmsg_unregister_spam_learner(spamassassin_learn);
@@ -571,7 +571,7 @@ gint plugin_init(gchar **error)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != -1) {
+	if (hook_id != (guint) -1) {
 		spamassassin_unregister_hook();
 	}
 	g_free(config.hostname);
@@ -629,9 +629,9 @@ struct PluginFeature *plugin_provides(void)
 
 void spamassassin_register_hook(void)
 {
-	if (hook_id == -1)
+	if (hook_id == (guint) -1)
 		hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == -1) {
+	if (hook_id == (guint) -1) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -639,7 +639,7 @@ void spamassassin_register_hook(void)
 
 void spamassassin_unregister_hook(void)
 {
-	if (hook_id != -1) {
+	if (hook_id != (guint) -1) {
 		hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
 	}
 	hook_id = -1;
diff --git a/src/statusbar.c b/src/statusbar.c
index 13d6bb6..12fdb1d 100644
--- a/src/statusbar.c
+++ b/src/statusbar.c
@@ -37,7 +37,7 @@
 #define BUFFSIZE 1024
 
 static GList *statusbar_list = NULL;
-gint statusbar_puts_all_hook_id = -1;
+guint statusbar_puts_all_hook_id = -1;
 
 GtkWidget *statusbar_create(void)
 {
@@ -149,10 +149,10 @@ static gboolean statusbar_puts_all_hook (gpointer source, gpointer data)
 
 void statusbar_verbosity_set(gboolean verbose)
 {
-	if (verbose && (statusbar_puts_all_hook_id == -1)) {
+	if (verbose && (statusbar_puts_all_hook_id == (guint) -1)) {
 		statusbar_puts_all_hook_id =
 			hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, statusbar_puts_all_hook, NULL);
-	} else if (!verbose && (statusbar_puts_all_hook_id != -1)) {
+	} else if (!verbose && (statusbar_puts_all_hook_id != (guint) -1)) {
 		hooks_unregister_hook(LOG_APPEND_TEXT_HOOKLIST, statusbar_puts_all_hook_id);
 		statusbar_puts_all_hook_id = -1;
 		statusbar_pop_all();

commit 7b09966c179ff8cf275288d325ecda3b3f4a278c
Author: wwp <wwp at free.fr>
Date:   Sat Mar 17 20:02:48 2018 +0100

    Few optimizations: avoid strlen when string length is known (read()>0 return);
    end string at real end of string instead of at buffer boundary and
    be sure we print 0-terminated string (clamd_stream_scan());
    clamd_verify_email: discover a strange multi-line response, be sure we
    print 0-terminated string (CID 1220483), debug_print all response lines.

diff --git a/src/plugins/clamd/libclamd/clamd-plugin.c b/src/plugins/clamd/libclamd/clamd-plugin.c
index 23358e5..314f626 100644
--- a/src/plugins/clamd/libclamd/clamd-plugin.c
+++ b/src/plugins/clamd/libclamd/clamd-plugin.c
@@ -389,8 +389,8 @@ Clamd_Stat clamd_init(Clamd_Socket* config) {
 	memset(buf, '\0', sizeof(buf));
 	while ((n_read = read(sock, buf, BUFSIZ - 1)) > 0) {
 		buf[n_read] = '\0';
-		if (buf[strlen(buf) - 1] == '\n')
-			buf[strlen(buf) - 1] = '\0';
+		if (buf[n_read - 1] == '\n')
+			buf[n_read - 1] = '\0';
 		debug_print("Ping result: %s\n", buf);
 		if (strcmp("PONG", buf) == 0)
 			connect = TRUE;
@@ -407,10 +407,10 @@ Clamd_Stat clamd_init(Clamd_Socket* config) {
 	    return NO_CONNECTION;
 	}
 	memset(buf, '\0', sizeof(buf));
-        while ((n_read = read(sock, buf, BUFSIZ - 1)) > 0) {
-	    buf[n_read] = '\0';
-	    if (buf[strlen(buf) - 1] == '\n')
-		buf[strlen(buf) - 1] = '\0';
+	while ((n_read = read(sock, buf, BUFSIZ - 1)) > 0) {
+		buf[n_read] = '\0';
+		if (buf[n_read - 1] == '\n')
+			buf[n_read - 1] = '\0';
 	    debug_print("Version: %s\n", buf);
 	}
 	close(sock);
@@ -462,10 +462,9 @@ static Clamd_Stat clamd_stream_scan(int sock,
 	}
 
 	while ((count = read(fd, (void *) buf, sizeof(buf))) > 0) {
-		buf[sizeof(buf) - 1] = '\0';
-		if (buf[strlen(buf) - 1] == '\n')
-			buf[strlen(buf) - 1] = '\0';
-		debug_print("read: %ld bytes\n", count);
+		buf[count] = '\0';
+		if (buf[count - 1] == '\n')
+			buf[count - 1] = '\0';
 		
 		debug_print("chunk size: %ld\n", count);
 		chunk = htonl(count);
@@ -500,6 +499,7 @@ static Clamd_Stat clamd_stream_scan(int sock,
 		*res = g_strconcat("ERROR -> ", _("Socket read error"), NULL);
 		return SCAN_ERROR;
 	}
+	res[n_read] = '\0';
 	debug_print("received: %s\n", *res);
 	return OK;
 }
@@ -534,6 +534,7 @@ Clamd_Stat clamd_verify_email(const gchar* path, response* result) {
 		debug_print("copy to buf: %s\n", tmp);
 		memcpy(&buf, tmp, BUFSIZ);
 		g_free(tmp);
+		debug_print("response: %s\n", buf);
 	}
 	else {
 		command = g_strconcat(scan, " ", path, "\n", NULL);
@@ -545,13 +546,18 @@ Clamd_Stat clamd_verify_email(const gchar* path, response* result) {
 		}
 		g_free(command);
 		memset(buf, '\0', sizeof(buf));
+		/* shouldn't we read only once here? we're checking the last response line anyway */
 		while ((n_read = read(sock, buf, BUFSIZ - 1)) > 0) {
 			buf[n_read] = '\0';
-			if (buf[strlen(buf) - 1] == '\n')
-				buf[strlen(buf) - 1] = '\0';
+			if (buf[n_read - 1] == '\n')
+				buf[n_read - 1] = '\0';
+			debug_print("response: %s\n", buf);
+		}
+		if (n_read == 0) {
+			buf[n_read] = '\0';
+			debug_print("response: %s\n", buf);
 		}
 	}
-	debug_print("response: %s\n", buf);
 	if (strstr(buf, "ERROR")) {
 		stat = SCAN_ERROR;
 		result->msg = g_strdup(buf);

commit 72c9f2413c835b60b09cfecf898a7483539f3367
Author: wwp <wwp at free.fr>
Date:   Sat Mar 17 19:34:05 2018 +0100

    Fix wrong malloc of clamd_socket struct, CID 1220477.

diff --git a/src/plugins/clamd/libclamd/clamd-plugin.c b/src/plugins/clamd/libclamd/clamd-plugin.c
index 6f1cc59..23358e5 100644
--- a/src/plugins/clamd/libclamd/clamd-plugin.c
+++ b/src/plugins/clamd/libclamd/clamd-plugin.c
@@ -138,7 +138,7 @@ void clamd_create_config_automatic(const gchar* path) {
 					value = g_strdup(g_strchomp(tmp));
 				if (strcmp(clamd_tokens[0], token) == 0) {
 					/* UNIX socket */
-					Socket = (Clamd_Socket *) malloc(sizeof(Clamd_Socket *));
+					Socket = (Clamd_Socket *) malloc(sizeof(Clamd_Socket));
 					if (Socket) {
 						Socket->socket.host = NULL;
 						Socket->socket.port = -1;
@@ -154,7 +154,7 @@ void clamd_create_config_automatic(const gchar* path) {
 				else if (strcmp(clamd_tokens[1], token) == 0) {
 					/* INET socket */
 					if (! Socket) {
-						Socket = (Clamd_Socket *) malloc(sizeof(Clamd_Socket *));
+						Socket = (Clamd_Socket *) malloc(sizeof(Clamd_Socket));
 						if (Socket) {
 							Socket->socket.path = NULL;
 							Socket->socket.port = -1;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list