]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Formatting
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 1 Jul 2015 15:32:47 +0000 (11:32 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 1 Jul 2015 15:33:19 +0000 (11:33 -0400)
src/modules/rlm_couchbase/rlm_couchbase.c

index c0a820b523f9fd8622fb0b79183f4df0a4b416db..02ea030688d3b20a4d690dfbd3c6f398b3cd06dd 100644 (file)
@@ -224,7 +224,7 @@ static rlm_rcode_t mod_authorize(void *instance, REQUEST *request)
                /* set return */
                rcode = RLM_MODULE_FAIL;
                /* return */
-               goto free_and_return;
+               goto finish;
        }
 
        /* debugging */
@@ -236,7 +236,7 @@ static rlm_rcode_t mod_authorize(void *instance, REQUEST *request)
        /* inject reply value pairs defined in this json oblect */
        mod_json_object_to_value_pairs(cookie->jobj, "reply", request);
 
-       free_and_return:
+       finish:
 
        /* free json object */
        if (cookie->jobj) {
@@ -321,7 +321,7 @@ static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
                /* set return */
                rcode = RLM_MODULE_NOOP;
                /* return */
-               goto free_and_return;
+               goto finish;
        }
 
        /* attempt to fetch document */
@@ -388,7 +388,7 @@ static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
                /* don't doing anything */
                rcode = RLM_MODULE_NOOP;
                /* return */
-               goto free_and_return;
+               goto finish;
        }
 
        /* loop through pairs and add to json document */
@@ -409,7 +409,7 @@ static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
                /* set return */
                rcode = RLM_MODULE_FAIL;
                /* return */
-               goto free_and_return;
+               goto finish;
        }
 
        /* debugging */
@@ -423,8 +423,7 @@ static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
                RERROR("failed to store document (%s): %s (0x%x)", dockey, lcb_strerror(NULL, cb_error), cb_error);
        }
 
-       free_and_return:
-
+finish:
        /* free and reset json object */
        if (cookie->jobj) {
                json_object_put(cookie->jobj);
@@ -524,7 +523,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                /* set return */
                rcode = RLM_MODULE_FAIL;
                /* return */
-               goto free_and_return;
+               goto finish;
        }
 
        /* debugging */
@@ -546,7 +545,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                /* set return */
                rcode = RLM_MODULE_FAIL;
                /* return */
-               goto free_and_return;
+               goto finish;
        }
 
        /* check for document id in return */
@@ -556,7 +555,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                /* set return */
                rcode = RLM_MODULE_FAIL;
                /* return */
-               goto free_and_return;
+               goto finish;
        }
 
        /* get and hold rows */
@@ -575,7 +574,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                /* set return */
                rcode = RLM_MODULE_FAIL;
                /* return */
-               goto free_and_return;
+               goto finish;
        }
 
        /* debugging */
@@ -590,7 +589,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
        /* check count */
        if (request->simul_count < request->simul_max) {
                rcode = RLM_MODULE_OK;
-               goto free_and_return;
+               goto finish;
        }
 
        /*
@@ -599,7 +598,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
         */
        if (inst->verify_simul != true) {
                rcode = RLM_MODULE_OK;
-               goto free_and_return;
+               goto finish;
        }
 
        /* debugging */
@@ -651,7 +650,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                        /* set return */
                        rcode = RLM_MODULE_FAIL;
                        /* return */
-                       goto free_and_return;
+                       goto finish;
                }
 
                /* debugging */
@@ -663,14 +662,14 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                        if (!json_object_object_get_ex(cookie->jobj, element, &jval)){
                                RDEBUG("cannot zap stale entry without username");
                                rcode = RLM_MODULE_FAIL;
-                               goto free_and_return;
+                               goto finish;
                        }
                        /* copy json string value to user_name */
                        user_name = talloc_typed_strdup(request, json_object_get_string(jval));
                } else {
                        RDEBUG("failed to find map entry for User-Name attribute");
                        rcode = RLM_MODULE_FAIL;
-                       goto free_and_return;
+                       goto finish;
                }
 
                /* get element name for Acct-Session-Id attribute */
@@ -679,14 +678,14 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                        if (!json_object_object_get_ex(cookie->jobj, element, &jval)){
                                RDEBUG("cannot zap stale entry without session id");
                                rcode = RLM_MODULE_FAIL;
-                               goto free_and_return;
+                               goto finish;
                        }
                        /* copy json string value to session_id */
                        session_id = talloc_typed_strdup(request, json_object_get_string(jval));
                } else {
                        RDEBUG("failed to find map entry for Acct-Session-Id attribute");
                        rcode = RLM_MODULE_FAIL;
-                       goto free_and_return;
+                       goto finish;
                }
 
                /* get element name for NAS-IP-Address attribute */
@@ -782,26 +781,17 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                        /* check failed - return error */
                        REDEBUG("failed to check the terminal server for user '%s'", user_name);
                        rcode = RLM_MODULE_FAIL;
-                       goto free_and_return;
+                       goto finish;
                }
 
                /* free and reset document user name talloc */
-               if (user_name) {
-                       talloc_free(user_name);
-                       user_name = NULL;
-               }
+               if (user_name) TALLOC_FREE(user_name);
 
                /* free and reset document calling station id talloc */
-               if (cs_id) {
-                       talloc_free(cs_id);
-                       cs_id = NULL;
-               }
+               if (cs_id) TALLOC_FREE(cs_id);
 
                /* free and reset document session id talloc */
-               if (session_id) {
-                       talloc_free(session_id);
-                       session_id = NULL;
-               }
+               if (session_id) TALLOC_FREE(session_id);
 
                /* free and reset json object before fetching next row */
                if (cookie->jobj) {
@@ -811,30 +801,16 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
        }
 
        /* debugging */
-       RDEBUG("retained %d open sessions for %s after verification",
+       RDEBUG("Retained %d open sessions for %s after verification",
               request->simul_count, request->username->vp_strvalue);
 
-       free_and_return:
-
-       /* free document user name talloc */
-       if (user_name) {
-               talloc_free(user_name);
-       }
-
-       /* free document calling station id talloc */
-       if (cs_id) {
-               talloc_free(cs_id);
-       }
-
-       /* free document session id talloc */
-       if (session_id) {
-               talloc_free(session_id);
-       }
+finish:
+       if (user_name) talloc_free(user_name);
+       if (cs_id) talloc_free(cs_id);
+       if (session_id) talloc_free(session_id);
 
        /* free rows */
-       if (jrows) {
-               json_object_put(jrows);
-       }
+       if (jrows) json_object_put(jrows);
 
        /* free and reset json object */
        if (cookie->jobj) {
@@ -842,10 +818,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
                cookie->jobj = NULL;
        }
 
-       /* release handle */
-       if (handle) {
-               fr_connection_release(inst->pool, handle);
-       }
+       if (handle) fr_connection_release(inst->pool, handle);
 
        /*
         * The Auth module apparently looks at request->simul_count,
@@ -865,19 +838,11 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request) {
  */
 static int mod_detach(void *instance)
 {
-       rlm_couchbase_t *inst = instance;  /* instance struct */
+       rlm_couchbase_t *inst = instance;
 
-       /* free json object attribute map */
-       if (inst->map) {
-               json_object_put(inst->map);
-       }
-
-       /* destroy connection pool */
-       if (inst->pool) {
-               fr_connection_pool_free(inst->pool);
-       }
+       if (inst->map) json_object_put(inst->map);
+       if (inst->pool) fr_connection_pool_free(inst->pool);
 
-       /* return okay */
        return 0;
 }