]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod/docs: document kmod_list iterators
authorEmil Velikov <emil.l.velikov@gmail.com>
Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 6 Sep 2024 16:56:01 +0000 (11:56 -0500)
... and change the argument names to match the other kmod_list APIs.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod.h

index 2883d155320fbe650558441f677ba5e479c79abe..cf440c979e9c5f49674fb6d47389b81a8ba114d7 100644 (file)
@@ -267,15 +267,29 @@ const char *kmod_get_dirname(const struct kmod_ctx *ctx);
  */
 struct kmod_list;
 
-#define kmod_list_foreach(list_entry, first_entry) \
-       for (list_entry = first_entry; \
-               list_entry != NULL; \
-               list_entry = kmod_list_next(first_entry, list_entry))
-
-#define kmod_list_foreach_reverse(list_entry, first_entry) \
-       for (list_entry = kmod_list_last(first_entry); \
-               list_entry != NULL; \
-               list_entry = kmod_list_prev(first_entry, list_entry))
+/**
+ * kmod_list_foreach:
+ * @curr: the current node in the list
+ * @list: the head of the list
+ *
+ * Iterate over the list @list.
+ */
+#define kmod_list_foreach(curr, list) \
+       for (curr = list; \
+               curr != NULL; \
+               curr = kmod_list_next(list, curr))
+
+/**
+ * kmod_list_foreach_reverse:
+ * @curr: the current node in the list
+ * @list: the head of the list
+ *
+ * Iterate in reverse over the list @list.
+ */
+#define kmod_list_foreach_reverse(curr, list) \
+       for (curr = kmod_list_last(list); \
+               curr != NULL; \
+               curr = kmod_list_prev(list, curr))
 
 /**
  * kmod_list_last: