]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
list: fix double evaluation
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 Apr 2023 19:04:03 +0000 (04:04 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 20 Apr 2023 07:20:08 +0000 (09:20 +0200)
src/basic/list.h

index ffc8bd830453ecd3c451966c88749f45717a4502..e4e5dff3ea2678568efdbf692e4ca1a32f457a22 100644 (file)
@@ -46,7 +46,7 @@
 
 /* Remove an item from the list */
 #define LIST_REMOVE(name,head,item)                                     \
-        ({                                                            \
+        ({                                                              \
                 typeof(*(head)) **_head = &(head), *_item = (item);     \
                 assert(_item);                                          \
                 if (_item->name##_next)                                 \
                 _b;                                                     \
         })
 
-#define LIST_JUST_US(name,item)                                         \
-        (!(item)->name##_prev && !(item)->name##_next)
+#define LIST_JUST_US(name, item)                                        \
+        ({                                                              \
+                typeof(*(item)) *_item = (item);                        \
+                !(_item)->name##_prev && !(_item)->name##_next;         \
+        })
 
 /* The type of the iterator 'i' is automatically determined by the type of 'head', and declared in the
  * loop. Hence, do not declare the same variable in the outer scope. Sometimes, we set 'head' through