summaryrefslogtreecommitdiff
path: root/rest
diff options
context:
space:
mode:
authorRob Bradford <rob@linux.intel.com>2010-04-14 17:17:02 +0100
committerRoss Burton <ross@linux.intel.com>2010-04-15 10:27:20 +0100
commit60483a6706584b43ac3ac434d626be19d83bb05d (patch)
tree9281e7aabc6ea48601f7251811a91a6c470d6659 /rest
parent067d537e4d8f0e55b7bbd12923e6ec3144bea632 (diff)
proxy/proxy-call/xml-parser: Guard public function entry points
Fixes: http://bugzilla.meego.com/show_bug.cgi?id=273
Diffstat (limited to 'rest')
-rw-r--r--rest/rest-proxy-call.c107
-rw-r--r--rest/rest-proxy.c48
-rw-r--r--rest/rest-xml-parser.c5
3 files changed, 136 insertions, 24 deletions
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index b8ed212..c2ef50d 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -189,7 +189,10 @@ void
rest_proxy_call_set_method (RestProxyCall *call,
const gchar *method)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+ priv = GET_PRIVATE (call);
g_free (priv->method);
@@ -208,7 +211,10 @@ rest_proxy_call_set_method (RestProxyCall *call,
const char *
rest_proxy_call_get_method (RestProxyCall *call)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), NULL);
+ priv = GET_PRIVATE (call);
return priv->method;
}
@@ -228,7 +234,10 @@ void
rest_proxy_call_set_function (RestProxyCall *call,
const gchar *function)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+ priv = GET_PRIVATE (call);
g_free (priv->function);
@@ -249,7 +258,10 @@ rest_proxy_call_add_header (RestProxyCall *call,
const gchar *header,
const gchar *value)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+ priv = GET_PRIVATE (call);
g_hash_table_insert (priv->headers,
g_strdup (header),
@@ -271,6 +283,8 @@ rest_proxy_call_add_headers (RestProxyCall *call,
{
va_list headers;
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+
va_start (headers, call);
rest_proxy_call_add_headers_from_valist (call, headers);
va_end (headers);
@@ -291,6 +305,8 @@ rest_proxy_call_add_headers_from_valist (RestProxyCall *call,
const gchar *header = NULL;
const gchar *value = NULL;
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+
while ((header = va_arg (headers, const gchar *)) != NULL)
{
value = va_arg (headers, const gchar *);
@@ -312,7 +328,10 @@ const gchar *
rest_proxy_call_lookup_header (RestProxyCall *call,
const gchar *header)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), NULL);
+ priv = GET_PRIVATE (call);
return g_hash_table_lookup (priv->headers, header);
}
@@ -328,7 +347,10 @@ void
rest_proxy_call_remove_header (RestProxyCall *call,
const gchar *header)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+ priv = GET_PRIVATE (call);
g_hash_table_remove (priv->headers, header);
}
@@ -347,7 +369,10 @@ rest_proxy_call_add_param (RestProxyCall *call,
const gchar *param,
const gchar *value)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+ priv = GET_PRIVATE (call);
g_hash_table_insert (priv->params,
g_strdup (param),
@@ -369,6 +394,8 @@ rest_proxy_call_add_params (RestProxyCall *call,
{
va_list params;
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+
va_start (params, call);
rest_proxy_call_add_params_from_valist (call, params);
va_end (params);
@@ -389,6 +416,8 @@ rest_proxy_call_add_params_from_valist (RestProxyCall *call,
const gchar *param = NULL;
const gchar *value = NULL;
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+
while ((param = va_arg (params, const gchar *)) != NULL)
{
value = va_arg (params, const gchar *);
@@ -410,7 +439,11 @@ const gchar *
rest_proxy_call_lookup_param (RestProxyCall *call,
const gchar *param)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), NULL);
+
+ priv = GET_PRIVATE (call);
return g_hash_table_lookup (priv->params, param);
}
@@ -426,7 +459,11 @@ void
rest_proxy_call_remove_param (RestProxyCall *call,
const gchar *param)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_if_fail (REST_IS_PROXY_CALL (call));
+
+ priv = GET_PRIVATE (call);
g_hash_table_remove (priv->params, param);
}
@@ -443,7 +480,11 @@ rest_proxy_call_remove_param (RestProxyCall *call,
GHashTable *
rest_proxy_call_get_params (RestProxyCall *call)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), NULL);
+
+ priv = GET_PRIVATE (call);
return g_hash_table_ref (priv->params);
}
@@ -743,6 +784,8 @@ rest_proxy_call_cancel (RestProxyCall *call)
RestProxyCallPrivate *priv;
RestProxyCallAsyncClosure *closure;
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), FALSE);
+
priv = GET_PRIVATE (call);
closure = priv->cur_call_closure;
@@ -793,6 +836,8 @@ rest_proxy_call_run (RestProxyCall *call,
GError *error = NULL;
RestProxyCallRunClosure closure = { NULL, NULL};
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), FALSE);
+
closure.loop = g_main_loop_new (NULL, FALSE);
if (loop_out)
@@ -838,6 +883,8 @@ rest_proxy_call_sync (RestProxyCall *call,
guint status;
gboolean ret;
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), FALSE);
+
priv = GET_PRIVATE (call);
message = prepare_message (call, error_out);
@@ -866,7 +913,11 @@ const gchar *
rest_proxy_call_lookup_response_header (RestProxyCall *call,
const gchar *header)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), NULL);
+
+ priv = GET_PRIVATE (call);
if (!priv->response_headers)
{
@@ -888,7 +939,11 @@ rest_proxy_call_lookup_response_header (RestProxyCall *call,
GHashTable *
rest_proxy_call_get_response_headers (RestProxyCall *call)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), NULL);
+
+ priv = GET_PRIVATE (call);
if (!priv->response_headers)
{
@@ -909,7 +964,12 @@ rest_proxy_call_get_response_headers (RestProxyCall *call)
goffset
rest_proxy_call_get_payload_length (RestProxyCall *call)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), 0);
+
+ priv = GET_PRIVATE (call);
+
return priv->length;
}
@@ -925,7 +985,12 @@ rest_proxy_call_get_payload_length (RestProxyCall *call)
const gchar *
rest_proxy_call_get_payload (RestProxyCall *call)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), NULL);
+
+ priv = GET_PRIVATE (call);
+
return priv->payload;
}
@@ -938,7 +1003,12 @@ rest_proxy_call_get_payload (RestProxyCall *call)
guint
rest_proxy_call_get_status_code (RestProxyCall *call)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), 0);
+
+ priv = GET_PRIVATE (call);
+
return priv->status_code;
}
@@ -954,6 +1024,11 @@ rest_proxy_call_get_status_code (RestProxyCall *call)
const gchar *
rest_proxy_call_get_status_message (RestProxyCall *call)
{
- RestProxyCallPrivate *priv = GET_PRIVATE (call);
+ RestProxyCallPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY_CALL (call), NULL);
+
+ priv = GET_PRIVATE (call);
+
return priv->status_message;
}
diff --git a/rest/rest-proxy.c b/rest/rest-proxy.c
index 67d6acc..4385200 100644
--- a/rest/rest-proxy.c
+++ b/rest/rest-proxy.c
@@ -279,12 +279,15 @@ rest_proxy_bind_valist (RestProxy *proxy,
va_list params)
{
RestProxyClass *proxy_class = REST_PROXY_GET_CLASS (proxy);
+
return proxy_class->bind_valist (proxy, params);
}
gboolean
rest_proxy_bind (RestProxy *proxy, ...)
{
+ g_return_val_if_fail (REST_IS_PROXY (proxy), FALSE);
+
gboolean res;
va_list params;
@@ -296,15 +299,22 @@ rest_proxy_bind (RestProxy *proxy, ...)
}
void
-rest_proxy_set_user_agent (RestProxy *proxy, const char *user_agent)
+rest_proxy_set_user_agent (RestProxy *proxy,
+ const char *user_agent)
{
+ g_return_if_fail (REST_IS_PROXY (proxy));
+
g_object_set (proxy, "user-agent", user_agent, NULL);
}
const gchar *
rest_proxy_get_user_agent (RestProxy *proxy)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY (proxy), NULL);
+
+ priv = GET_PRIVATE (proxy);
return priv->user_agent;
}
@@ -331,7 +341,11 @@ rest_proxy_new_call (RestProxy *proxy)
gboolean
_rest_proxy_get_binding_required (RestProxy *proxy)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY (proxy), FALSE);
+
+ priv = GET_PRIVATE (proxy);
return priv->binding_required;
}
@@ -339,7 +353,11 @@ _rest_proxy_get_binding_required (RestProxy *proxy)
const gchar *
_rest_proxy_get_bound_url (RestProxy *proxy)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY (proxy), NULL);
+
+ priv = GET_PRIVATE (proxy);
if (!priv->url && !priv->binding_required)
{
@@ -419,7 +437,12 @@ void
_rest_proxy_queue_message (RestProxy *proxy,
SoupMessage *message)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv;
+
+ g_return_if_fail (REST_IS_PROXY (proxy));
+ g_return_if_fail (SOUP_IS_MESSAGE (message));
+
+ priv = GET_PRIVATE (proxy);
soup_session_queue_message (priv->session,
message,
@@ -431,8 +454,12 @@ void
_rest_proxy_cancel_message (RestProxy *proxy,
SoupMessage *message)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv;
+ g_return_if_fail (REST_IS_PROXY (proxy));
+ g_return_if_fail (SOUP_IS_MESSAGE (message));
+
+ priv = GET_PRIVATE (proxy);
soup_session_cancel_message (priv->session,
message,
SOUP_STATUS_CANCELLED);
@@ -440,9 +467,14 @@ _rest_proxy_cancel_message (RestProxy *proxy,
guint
_rest_proxy_send_message (RestProxy *proxy,
- SoupMessage *message)
+ SoupMessage *message)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv;
+
+ g_return_val_if_fail (REST_IS_PROXY (proxy), 0);
+ g_return_val_if_fail (SOUP_IS_MESSAGE (message), 0);
+
+ priv = GET_PRIVATE (proxy);
return soup_session_send_message (priv->session_sync, message);
}
diff --git a/rest/rest-xml-parser.c b/rest/rest-xml-parser.c
index db6a748..55b73fa 100644
--- a/rest/rest-xml-parser.c
+++ b/rest/rest-xml-parser.c
@@ -221,6 +221,9 @@ rest_xml_node_find (RestXmlNode *start,
GList *children, *l;
const char *tag_interned;
+ g_return_val_if_fail (start, NULL);
+ g_return_val_if_fail (start->ref_count > 0, NULL);
+
tag_interned = g_intern_string (tag);
g_queue_push_head (&stack, start);
@@ -285,6 +288,8 @@ rest_xml_parser_parse_from_data (RestXmlParser *parser,
GQueue nodes = G_QUEUE_INIT;
gint res = 0;
+ g_return_val_if_fail (REST_IS_XML_PARSER (parser), NULL);
+
_rest_setup_debugging ();
reader = xmlReaderForMemory (data,