systemd/backport-list-fix-double-evaluation.patch
wangyuhang a4f95d3244 sync patch from systemd community
(cherry picked from commit 88369f234ec01b60fb047caf87b90ef10a92b0db)
2023-10-10 10:04:24 +08:00

37 lines
1.5 KiB
Diff

From 42094f7b796cdf4df467ba31529962c643a08cae Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Thu, 20 Apr 2023 04:04:03 +0900
Subject: [PATCH] list: fix double evaluation
(cherry picked from commit 24a5370bbc1b52fee52d8891f66af13e9d77d799)
(cherry picked from commit 7b437659b15c0cd87b5720b3570dcd5e5ad9abca)
(cherry picked from commit 73f7c65d34d507c75b3044e2205d1393e43a7534)
Conflict:code context adaptation
Reference:https://github.com/systemd/systemd-stable/commit/42094f7b796cdf4df467ba31529962c643a08cae
---
src/basic/list.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/basic/list.h b/src/basic/list.h
index 58e83a6cb2..0dba7648e6 100644
--- a/src/basic/list.h
+++ b/src/basic/list.h
@@ -133,8 +133,11 @@
} \
} while (false)
-#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; \
+ })
#define LIST_FOREACH(name,i,head) \
for ((i) = (head); (i); (i) = (i)->name##_next)
--
2.33.0