1 Star 0 Fork 50

zhongling.h/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0499-unit-make-UNIT-cast-function-deal-with-NULL-pointers.patch 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:46 . update to systemd-239-45.el8.src.rpm
From a11334f0eae67b5159a416193e2e37634281000a Mon Sep 17 00:00:00 2001
From: Lennart Poettering <[email protected]>
Date: Thu, 8 Nov 2018 09:33:31 +0100
Subject: [PATCH] unit: make UNIT() cast function deal with NULL pointers
Fixes: #10681
(cherry picked from commit bbf11206230d1b089118971f98a047151cb5c4fa)
Related: #1871827
---
src/core/unit.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/core/unit.h b/src/core/unit.h
index 6e37fd6f5a..ec45b5fb48 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -597,7 +597,12 @@ extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
}
/* For casting the various unit types into a unit */
-#define UNIT(u) (&(u)->meta)
+#define UNIT(u) \
+ ({ \
+ typeof(u) _u_ = (u); \
+ Unit *_w_ = _u_ ? &(_u_)->meta : NULL; \
+ _w_; \
+ })
#define UNIT_HAS_EXEC_CONTEXT(u) (UNIT_VTABLE(u)->exec_context_offset > 0)
#define UNIT_HAS_CGROUP_CONTEXT(u) (UNIT_VTABLE(u)->cgroup_context_offset > 0)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhonglingh/systemd.git
[email protected]:zhonglingh/systemd.git
zhonglingh
systemd
systemd
a8

搜索帮助