Merge tag 'perf-tools-fixes-for-v6.9-2024-04-19' of git://git.kernel.org/pub/scm...
[linux-2.6-block.git] / include / linux / idr.h
index a0dce14090a9e1d239500897caaea9c1b05ea9f8..da5f5fa4a3a6ae2be38dec9bb7c5ac73ff8df6e2 100644 (file)
@@ -200,7 +200,7 @@ static inline void idr_preload_end(void)
  */
 #define idr_for_each_entry_ul(idr, entry, tmp, id)                     \
        for (tmp = 0, id = 0;                                           \
-            tmp <= id && ((entry) = idr_get_next_ul(idr, &(id))) != NULL; \
+            ((entry) = tmp <= id ? idr_get_next_ul(idr, &(id)) : NULL) != NULL; \
             tmp = id, ++id)
 
 /**
@@ -224,10 +224,12 @@ static inline void idr_preload_end(void)
  * @id: Entry ID.
  *
  * Continue to iterate over entries, continuing after the current position.
+ * After normal termination @entry is left with the value NULL.  This
+ * is convenient for a "not found" value.
  */
 #define idr_for_each_entry_continue_ul(idr, entry, tmp, id)            \
        for (tmp = id;                                                  \
-            tmp <= id && ((entry) = idr_get_next_ul(idr, &(id))) != NULL; \
+            ((entry) = tmp <= id ? idr_get_next_ul(idr, &(id)) : NULL) != NULL; \
             tmp = id, ++id)
 
 /*