/pidgin/main: bd0a2508b477: Fix some other coverity warnings
Tomasz Wasilczyk
twasilczyk at pidgin.im
Tue May 6 14:37:04 EDT 2014
Changeset: bd0a2508b477a0d3987aedd5a70709fd3bae9c9f
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-05-06 20:36 +0200
Branch: release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/bd0a2508b477
Description:
Fix some other coverity warnings
diffstat:
libpurple/protocols/yahoo/libymsg.c | 4 ++-
libpurple/protocols/zephyr/ZReadAscii.c | 7 ++++-
libpurple/protocols/zephyr/ZRetSubs.c | 1 +
libpurple/protocols/zephyr/zephyr.c | 49 ++++++++++++++++++--------------
pidgin/gtksourceundomanager.c | 10 ++++--
5 files changed, 45 insertions(+), 26 deletions(-)
diffs (168 lines):
diff --git a/libpurple/protocols/yahoo/libymsg.c b/libpurple/protocols/yahoo/libymsg.c
--- a/libpurple/protocols/yahoo/libymsg.c
+++ b/libpurple/protocols/yahoo/libymsg.c
@@ -990,7 +990,9 @@ static void yahoo_process_sms_message(Pu
return;
}
- if( (pkt->status == -1) || (pkt->status == YAHOO_STATUS_DISCONNECTED) ) {
+ if ((int)pkt->status < 0)
+ pkt->status = YAHOO_STATUS_DISCONNECTED;
+ if (pkt->status == YAHOO_STATUS_DISCONNECTED) {
if (server_msg) {
PurpleConversation *c;
c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms->from, account);
diff --git a/libpurple/protocols/zephyr/ZReadAscii.c b/libpurple/protocols/zephyr/ZReadAscii.c
--- a/libpurple/protocols/zephyr/ZReadAscii.c
+++ b/libpurple/protocols/zephyr/ZReadAscii.c
@@ -58,12 +58,17 @@ Code_t ZReadAscii32(ptr, len, value_ptr)
unsigned long *value_ptr;
{
unsigned char buf[4];
+ unsigned long value = 0;
Code_t retval;
retval = ZReadAscii(ptr, len, buf, 4);
if (retval != ZERR_NONE)
return retval;
- *value_ptr = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
+ value |= buf[0] << 24;
+ value |= buf[1] << 16;
+ value |= buf[2] << 8;
+ value |= buf[3];
+ *value_ptr = value;
return ZERR_NONE;
}
diff --git a/libpurple/protocols/zephyr/ZRetSubs.c b/libpurple/protocols/zephyr/ZRetSubs.c
--- a/libpurple/protocols/zephyr/ZRetSubs.c
+++ b/libpurple/protocols/zephyr/ZRetSubs.c
@@ -132,6 +132,7 @@ static Code_t Z_RetSubs(notice, nsubs, a
__subscriptions_num = __subscriptions_num / 3;
+ free(__subscriptions_list);
__subscriptions_list = (ZSubscription_t *)
malloc((unsigned)(__subscriptions_num*
sizeof(ZSubscription_t)));
diff --git a/libpurple/protocols/zephyr/zephyr.c b/libpurple/protocols/zephyr/zephyr.c
--- a/libpurple/protocols/zephyr/zephyr.c
+++ b/libpurple/protocols/zephyr/zephyr.c
@@ -214,18 +214,18 @@ static char *zephyr_strip_local_realm(ze
* wouldn't do this. but it is so i will. */
/* just for debugging */
-static void handle_unknown(ZNotice_t notice)
+static void handle_unknown(ZNotice_t *notice)
{
- purple_debug_error("zephyr","z_packet: %s\n", notice.z_packet);
- purple_debug_error("zephyr","z_version: %s\n", notice.z_version);
- purple_debug_error("zephyr","z_kind: %d\n", (int)(notice.z_kind));
- purple_debug_error("zephyr","z_class: %s\n", notice.z_class);
- purple_debug_error("zephyr","z_class_inst: %s\n", notice.z_class_inst);
- purple_debug_error("zephyr","z_opcode: %s\n", notice.z_opcode);
- purple_debug_error("zephyr","z_sender: %s\n", notice.z_sender);
- purple_debug_error("zephyr","z_recipient: %s\n", notice.z_recipient);
- purple_debug_error("zephyr","z_message: %s\n", notice.z_message);
- purple_debug_error("zephyr","z_message_len: %d\n", notice.z_message_len);
+ purple_debug_error("zephyr","z_packet: %s\n", notice->z_packet);
+ purple_debug_error("zephyr","z_version: %s\n", notice->z_version);
+ purple_debug_error("zephyr","z_kind: %d\n", (int)(notice->z_kind));
+ purple_debug_error("zephyr","z_class: %s\n", notice->z_class);
+ purple_debug_error("zephyr","z_class_inst: %s\n", notice->z_class_inst);
+ purple_debug_error("zephyr","z_opcode: %s\n", notice->z_opcode);
+ purple_debug_error("zephyr","z_sender: %s\n", notice->z_sender);
+ purple_debug_error("zephyr","z_recipient: %s\n", notice->z_recipient);
+ purple_debug_error("zephyr","z_message: %s\n", notice->z_message);
+ purple_debug_error("zephyr","z_message_len: %d\n", notice->z_message_len);
}
@@ -749,21 +749,28 @@ static gboolean pending_zloc(zephyr_acco
/* Called when the server notifies us a message couldn't get sent */
-static void message_failed(PurpleConnection *gc, ZNotice_t notice, struct sockaddr_in from)
+static void message_failed(PurpleConnection *gc, ZNotice_t *notice, struct sockaddr_in from)
{
- if (g_ascii_strcasecmp(notice.z_class, "message")) {
- gchar* chat_failed = g_strdup_printf(_("Unable to send to chat %s,%s,%s"),notice.z_class,notice.z_class_inst,notice.z_recipient);
+ if (g_ascii_strcasecmp(notice->z_class, "message")) {
+ gchar* chat_failed = g_strdup_printf(
+ _("Unable to send to chat %s,%s,%s"),
+ notice->z_class, notice->z_class_inst,
+ notice->z_recipient);
purple_notify_error(gc,"",chat_failed,NULL);
g_free(chat_failed);
} else {
- purple_notify_error(gc, notice.z_recipient, _("User is offline"), NULL);
+ purple_notify_error(gc, notice->z_recipient,
+ _("User is offline"), NULL);
}
}
-static void handle_message(PurpleConnection *gc,ZNotice_t notice)
+static void handle_message(PurpleConnection *gc, ZNotice_t *notice_p)
{
+ ZNotice_t notice;
zephyr_account* zephyr = gc->proto_data;
+ memcpy(¬ice, notice_p, sizeof(notice)); /* TODO - use pointer? */
+
if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) {
/* well, we'll be updating in 20 seconds anyway, might as well ignore this. */
} else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) {
@@ -1132,7 +1139,7 @@ static gint check_notify_tzc(gpointer da
notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2";
notice.z_message_len = strlen(msg) + 3;
notice.z_message = buf;
- handle_message(gc, notice);
+ handle_message(gc, ¬ice);
g_free(msg);
/* g_free(zsig); */
g_free(buf);
@@ -1231,20 +1238,20 @@ static gint check_notify_zeph02(gpointer
case UNSAFE:
case UNACKED:
case ACKED:
- handle_message(gc,notice);
+ handle_message(gc, ¬ice);
break;
case SERVACK:
if (!(g_ascii_strcasecmp(notice.z_message, ZSRVACK_NOTSENT))) {
- message_failed(gc,notice, from);
+ message_failed(gc, ¬ice, from);
}
break;
case CLIENTACK:
purple_debug_error("zephyr", "Client ack received\n");
- handle_unknown(notice); /* XXX: is it really unknown? */
+ handle_unknown(¬ice); /* XXX: is it really unknown? */
break;
default:
/* we'll just ignore things for now */
- handle_unknown(notice);
+ handle_unknown(¬ice);
purple_debug_error("zephyr", "Unhandled notice.\n");
break;
}
diff --git a/pidgin/gtksourceundomanager.c b/pidgin/gtksourceundomanager.c
--- a/pidgin/gtksourceundomanager.c
+++ b/pidgin/gtksourceundomanager.c
@@ -988,9 +988,13 @@ gtk_source_undo_manager_merge_action (Gt
if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
{
- if ((last_action->action.delete.forward != undo_action->action.delete.forward) ||
- ((last_action->action.delete.start != undo_action->action.delete.start) &&
- (last_action->action.delete.start != undo_action->action.delete.end)))
+ GtkSourceUndoDeleteAction *last_del, *undo_del;
+
+ last_del = &last_action->action.delete;
+ undo_del = &undo_action->action.delete;
+
+ if (last_del->forward != undo_del->forward ||
+ (last_del->start != undo_del->start && last_del->start != undo_del->end))
{
last_action->mergeable = FALSE;
return FALSE;
More information about the Commits
mailing list