summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorentin Noël <corentin.noel@collabora.com>2022-08-09 11:07:14 +0200
committerCorentin Noël <corentin.noel@collabora.com>2022-08-09 11:43:32 +0200
commitc7d7f8e8fed38fee172d46705f50118ec9549fe1 (patch)
tree011abca3367778cfb80a9a1f1f463877687e99f0
parent52ab5132a4f7c4d982c13183e937775e379a975a (diff)
downloadlibrest-c7d7f8e8fed38fee172d46705f50118ec9549fe1.tar.gz
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
-rw-r--r--rest/rest-params.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/rest/rest-params.c b/rest/rest-params.c
index f2ac286..bddd3c1 100644
--- a/rest/rest-params.c
+++ b/rest/rest-params.c
@@ -281,12 +281,14 @@ 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) (optional) (nullable) (transfer none): a location to store the name,
+ * or %NULL
+ * @param: (out) (optional) (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,10 +304,20 @@ 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)
+ {
+ if (param)
+ *param = NULL;
+ if (name)
+ *name = NULL;
+ return FALSE;
+ }
+
+ if (param)
+ *param = cur->data;
+ if (name)
+ *name = rest_param_get_name (*param);
- *param = cur->data;
- *name = rest_param_get_name (*param);
return TRUE;
}