Markup more SQL functions as nonnull
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 22 May 2014 11:19:05 +0000 (12:19 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 22 May 2014 11:19:26 +0000 (12:19 +0100)
src/modules/rlm_sql/rlm_sql.h
src/modules/rlm_sql/sql.c

index 7900b55..af31d6a 100644 (file)
@@ -152,10 +152,9 @@ int     sql_getvpdata(rlm_sql_t *inst, rlm_sql_handle_t **handle, TALLOC_CTX *ct
 int     sql_read_naslist(rlm_sql_handle_t *handle);
 int     sql_read_clients(rlm_sql_handle_t *handle);
 int     sql_dict_init(rlm_sql_handle_t *handle);
-void   rlm_sql_query_log(rlm_sql_t *inst, REQUEST *request,
-                         sql_acct_section_t *section, char const *query);
-int    rlm_sql_select_query(rlm_sql_handle_t **handle, rlm_sql_t *inst, char const *query);
-int    rlm_sql_query(rlm_sql_handle_t **handle, rlm_sql_t *inst, char const *query);
+void   CC_HINT(nonnull) rlm_sql_query_log(rlm_sql_t *inst, REQUEST *request, sql_acct_section_t *section, char const *query);
+int    CC_HINT(nonnull) rlm_sql_select_query(rlm_sql_handle_t **handle, rlm_sql_t *inst, char const *query);
+int    CC_HINT(nonnull) rlm_sql_query(rlm_sql_handle_t **handle, rlm_sql_t *inst, char const *query);
 int    rlm_sql_fetch_row(rlm_sql_handle_t **handle, rlm_sql_t *inst);
 int    sql_set_user(rlm_sql_t *inst, REQUEST *request, char const *username);
 #endif
index 2c16ef2..458b174 100644 (file)
@@ -360,19 +360,22 @@ static void rlm_sql_query_debug(rlm_sql_handle_t *handle, rlm_sql_t *inst)
        }
 }
 
-/*************************************************************************
- *
- *     Function: rlm_sql_query
- *
- *     Purpose: call the module's sql_query and implement re-connect
- *
- *************************************************************************/
+/** Call the driver's sql_query method, reconnecting if necessary.
+ *
+ * @param handle to query the database with. *handle should not be NULL, as this indicates
+ *       previous reconnection attempt has failed.
+ * @param inst rlm_sql instance data.
+ * @param query to execute. Should not be zero length.
+ * @return RLM_SQL_OK on success, RLM_SQL_RECONNECT if a new handle is required (also sets *handle = NULL),
+ *         RLM_SQL_QUERY_ERROR/RLM_SQL_ERROR on invalid query or connection error, RLM_SQL_DUPLICATE on constraints
+ *         violation.
+ */
 int rlm_sql_query(rlm_sql_handle_t **handle, rlm_sql_t *inst, char const *query)
 {
        int ret = RLM_SQL_ERROR;
 
        /* There's no query to run, return an error */
-       if (!query || (query[0] == '\0')) return RLM_SQL_QUERY_ERROR;
+       if (query[0] == '\0') return RLM_SQL_QUERY_ERROR;
 
        /* There's no handle, we need a new one */
        if (!*handle) return RLM_SQL_RECONNECT;
@@ -415,19 +418,21 @@ int rlm_sql_query(rlm_sql_handle_t **handle, rlm_sql_t *inst, char const *query)
        }
 }
 
-/*************************************************************************
- *
- *     Function: rlm_sql_select_query
- *
- *     Purpose: call the module's sql_select_query and implement re-connect
+/** Call the driver's sql_select_query method, reconnecting if necessary.
  *
- *************************************************************************/
+ * @param handle to query the database with. *handle should not be NULL, as this indicates
+ *       previous reconnection attempt has failed.
+ * @param inst rlm_sql instance data.
+ * @param query to execute. Should not be zero length.
+ * @return RLM_SQL_OK on success, RLM_SQL_RECONNECT if a new handle is required (also sets *handle = NULL),
+ *         RLM_SQL_QUERY_ERROR/RLM_SQL_ERROR on invalid query or connection error.
+ */
 int rlm_sql_select_query(rlm_sql_handle_t **handle, rlm_sql_t *inst, char const *query)
 {
        int ret = RLM_SQL_ERROR;
 
        /* There's no query to run, return an error */
-       if (!query || (query[0] == '\0')) return RLM_SQL_QUERY_ERROR;
+       if (query[0] == '\0') return RLM_SQL_QUERY_ERROR;
 
        /* There's no handle, we need a new one */
        if (!*handle) return RLM_SQL_RECONNECT;
@@ -457,13 +462,9 @@ int rlm_sql_select_query(rlm_sql_handle_t **handle, rlm_sql_t *inst, char const
 
                case RLM_SQL_QUERY_ERROR:
                case RLM_SQL_ERROR:
+               default:
                        rlm_sql_query_error(*handle, inst);
                        break;
-
-               case RLM_SQL_DUPLICATE:
-                       rlm_sql_query_debug(*handle, inst);
-                       break;
-
                }
 
                return ret;