/soc/2015/jgeboski/facebook: 8d6136db4399: facebook: removed unn...
James Geboski
jgeboski at gmail.com
Wed Jun 3 20:14:47 EDT 2015
Changeset: 8d6136db439968dcda3d8bef05a1a08acc7609ac
Author: James Geboski <jgeboski at gmail.com>
Date: 2015-06-03 20:06 -0400
Branch: facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/8d6136db4399
Description:
facebook: removed unnecessary gotos
diffstat:
libpurple/protocols/facebook/json.c | 13 ++++++-------
libpurple/protocols/facebook/json.h | 3 ---
libpurple/protocols/facebook/mqtt.c | 24 ++++++++++++------------
3 files changed, 18 insertions(+), 22 deletions(-)
diffs (127 lines):
diff --git a/libpurple/protocols/facebook/json.c b/libpurple/protocols/facebook/json.c
--- a/libpurple/protocols/facebook/json.c
+++ b/libpurple/protocols/facebook/json.c
@@ -203,7 +203,8 @@ fb_json_node_get(JsonNode *root, const g
if (err != NULL) {
g_propagate_error(error, err);
- goto error;
+ json_node_free(node);
+ return NULL;
}
rslt = json_node_get_array(node);
@@ -212,22 +213,20 @@ fb_json_node_get(JsonNode *root, const g
if (size < 1) {
g_set_error(error, FB_JSON_ERROR, FB_JSON_ERROR_NOMATCH,
_("No matches for %s"), expr);
- goto error;
+ json_node_free(node);
+ return NULL;
}
if (size > 1) {
g_set_error(error, FB_JSON_ERROR, FB_JSON_ERROR_AMBIGUOUS,
_("Ambiguous matches for %s"), expr);
- goto error;
+ json_node_free(node);
+ return NULL;
}
ret = json_array_dup_element(rslt, 0);
json_node_free(node);
return ret;
-
-error:
- json_node_free(node);
- return NULL;
}
JsonArray *
diff --git a/libpurple/protocols/facebook/json.h b/libpurple/protocols/facebook/json.h
--- a/libpurple/protocols/facebook/json.h
+++ b/libpurple/protocols/facebook/json.h
@@ -67,9 +67,6 @@ void
fb_json_bldr_add_int(JsonBuilder *bldr, const gchar *name, gint64 value);
void
-fb_json_bldr_add_null(JsonBuilder *bldr, const gchar *name);
-
-void
fb_json_bldr_add_str(JsonBuilder *bldr, const gchar *name, const gchar *value);
void
diff --git a/libpurple/protocols/facebook/mqtt.c b/libpurple/protocols/facebook/mqtt.c
--- a/libpurple/protocols/facebook/mqtt.c
+++ b/libpurple/protocols/facebook/mqtt.c
@@ -316,7 +316,9 @@ fb_mqtt_cb_read(gpointer data, gint fd,
g_byte_array_append(priv->rbuf, &byte, sizeof byte);
if (res != sizeof byte) {
- goto error;
+ fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL,
+ _("Failed to read fixed header"));
+ return;
}
mult = 1;
@@ -326,7 +328,9 @@ fb_mqtt_cb_read(gpointer data, gint fd,
g_byte_array_append(priv->rbuf, &byte, sizeof byte);
if (res != sizeof byte) {
- goto error;
+ fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL,
+ _("Failed to read packet size"));
+ return;
}
priv->remz += (byte & 127) * mult;
@@ -339,7 +343,9 @@ fb_mqtt_cb_read(gpointer data, gint fd,
rize = purple_ssl_read(priv->gsc, buf, size);
if (rize < 1) {
- goto error;
+ fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL,
+ _("Failed to read packet data"));
+ return;
}
g_byte_array_append(priv->rbuf, buf, rize);
@@ -351,17 +357,14 @@ fb_mqtt_cb_read(gpointer data, gint fd,
priv->remz = 0;
if (G_UNLIKELY(msg == NULL)) {
- goto error;
+ fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL,
+ _("Failed to parse message"));
+ return;
}
fb_mqtt_read(mqtt, msg);
g_object_unref(msg);
}
-
- return;
-
-error:
- fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, _("Short read"));
}
void
@@ -562,7 +565,6 @@ fb_mqtt_connect(FbMqtt *mqtt, guint8 fla
FbMqttMessage *msg;
va_list ap;
- g_return_if_fail(FB_IS_MQTT(mqtt));
g_return_if_fail(cid != NULL);
g_return_if_fail(!fb_mqtt_connected(mqtt, FALSE));
@@ -611,8 +613,6 @@ fb_mqtt_disconnect(FbMqtt *mqtt)
{
FbMqttMessage *msg;
- g_return_if_fail(FB_IS_MQTT(mqtt));
-
if (G_UNLIKELY(!fb_mqtt_connected(mqtt, FALSE))) {
return;
}
More information about the Commits
mailing list