[librest/wip/baedert/tests] OAuth2Proxy: Add preconditions, gtkdoc annotations, etc.



commit 5906076d9241dcb1ba1dabe640973f5f53e4a9ef
Author: Timm Bäder <mail baedert org>
Date:   Tue Aug 2 13:16:05 2016 +0200

    OAuth2Proxy: Add preconditions, gtkdoc annotations, etc.

 rest/oauth2-proxy.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/rest/oauth2-proxy.c b/rest/oauth2-proxy.c
index f082794..6a1d918 100644
--- a/rest/oauth2-proxy.c
+++ b/rest/oauth2-proxy.c
@@ -88,18 +88,15 @@ oauth2_proxy_set_property (GObject *object, guint property_id,
 
   switch (property_id) {
   case PROP_CLIENT_ID:
-    if (priv->client_id)
-      g_free (priv->client_id);
+    g_free (priv->client_id);
     priv->client_id = g_value_dup_string (value);
     break;
   case PROP_AUTH_ENDPOINT:
-    if (priv->auth_endpoint)
-      g_free (priv->auth_endpoint);
+    g_free (priv->auth_endpoint);
     priv->auth_endpoint = g_value_dup_string (value);
     break;
   case PROP_ACCESS_TOKEN:
-    if (priv->access_token)
-      g_free (priv->access_token);
+    g_free (priv->access_token);
     priv->access_token = g_value_dup_string (value);
     break;
   default:
@@ -333,7 +330,9 @@ char *
 oauth2_proxy_build_login_url (OAuth2Proxy *proxy,
                               const char* redirect_uri)
 {
-    return oauth2_proxy_build_login_url_full (proxy, redirect_uri, NULL);
+  g_return_val_if_fail (OAUTH2_IS_PROXY (proxy), NULL);
+
+  return oauth2_proxy_build_login_url_full (proxy, redirect_uri, NULL);
 }
 
 /**
@@ -342,12 +341,15 @@ oauth2_proxy_build_login_url (OAuth2Proxy *proxy,
  *
  * Get the current request or access token.
  *
- * Returns: (nullable): the token, or %NULL if there is no token yet.  This string is owned
- * by #OAuth2Proxy and should not be freed.
+ * Returns: (nullable) (transfer none): the token, or
+ *   %NULL if there is no token yet.  This string is owned
+ *   by #OAuth2Proxy and should not be freed.
  */
 const char *
 oauth2_proxy_get_access_token (OAuth2Proxy *proxy)
 {
+  g_return_val_if_fail (OAUTH2_IS_PROXY (proxy), NULL);
+
   return proxy->priv->access_token;
 }
 
@@ -362,6 +364,7 @@ void
 oauth2_proxy_set_access_token (OAuth2Proxy *proxy, const char *access_token)
 {
   g_return_if_fail (OAUTH2_IS_PROXY (proxy));
+  g_return_if_fail (access_token != NULL);
 
   g_free (proxy->priv->access_token);
   proxy->priv->access_token = g_strdup (access_token);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]