]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/macro.h
Merge pull request #15442 from poettering/fido2
[thirdparty/systemd.git] / src / basic / macro.h
index fd8772f377f04e36de3e612a274017f1d0f303e8..ceea8176f5b85321e7966b4e747c386f8ed79980 100644 (file)
@@ -538,6 +538,12 @@ static inline int __coverity_check_and_return__(int condition) {
                 (y) = (_t);                        \
         } while (false)
 
+/* Iterates through a specified list of pointers. Accepts NULL pointers, but uses (void*) -1 as internal marker for EOL. */
+#define FOREACH_POINTER(p, x, ...)                                                      \
+        for (typeof(p) *_l = (typeof(p)[]) { ({ p = x; }), ##__VA_ARGS__, (void*) -1 }; \
+             p != (typeof(p)) (void*) -1;                                               \
+             p = *(++_l))
+
 /* Define C11 thread_local attribute even on older gcc compiler
  * version */
 #ifndef thread_local