[librest/tintou/annotations: 2/4] params: Fix annotations with rest_params_iter_next




commit 5ef1c070eac6af87b620bdc98934a7e03f8b9962
Author: Corentin Noël <corentin noel collabora com>
Date:   Tue Aug 9 11:07:14 2022 +0200

    params: Fix annotations with rest_params_iter_next
    
    The parameters are not optional as they are always accessed. They can be NULL
    when the iter is finished, actually always set it so that we are sure to
    always have an initialized variable

 rest/rest-params.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/rest/rest-params.c b/rest/rest-params.c
index f2ac286..8cb7605 100644
--- a/rest/rest-params.c
+++ b/rest/rest-params.c
@@ -281,12 +281,12 @@ rest_params_iter_init (RestParamsIter *iter,
 /**
  * rest_params_iter_next:
  * @iter: an initialized #RestParamsIter
- * @name: (out) (optional): a location to store the name, or %NULL
- * @param: (out) (optional): a location to store the #RestParam, or %NULL
+ * @name: (out) (nullable) (transfer none): a location to store the name, or %NULL
+ * @param: (out) (nullable) (transfer none): a location to store the #RestParam, or %NULL
  *
  * Advances @iter and retrieves the name and/or parameter that are now pointed
- * at as a result of this advancement.  If FALSE is returned, @name and @param
- * are not set and the iterator becomes invalid.
+ * at as a result of this advancement.  If %FALSE is returned, @name and @param
+ * are set to %NULL and the iterator becomes invalid.
  *
  * Returns: %FALSE if the end of the #RestParams has been reached, %TRUE otherwise.
  **/
@@ -302,7 +302,12 @@ rest_params_iter_next (RestParamsIter  *iter,
   iter->position++;
   cur = g_list_nth (iter->params->params, iter->position);
 
-  if (cur == NULL) return FALSE;
+  if (cur == NULL)
+    {
+      *param = NULL;
+      *name = NULL;
+      return FALSE;
+    }
 
   *param = cur->data;
   *name = rest_param_get_name (*param);


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