1 Star 0 Fork 50

zhongling.h/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0449-systemctl-split-out-extra-args-generation-into-helpe.patch 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:46 . update to systemd-239-45.el8.src.rpm
From cfb124260a0a9e68102a373c0d136f792e2d4ea7 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <[email protected]>
Date: Tue, 26 Mar 2019 16:19:35 +0100
Subject: [PATCH] systemctl: split out extra args generation into helper
function of its own
(cherry picked from commit 94369fc0663255bbd327f97dba288ececf51a514)
Related: #846319
---
src/systemctl/systemctl.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 4af9deb98d..e7a8fd559f 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3002,6 +3002,25 @@ static enum action verb_to_action(const char *verb) {
return _ACTION_INVALID;
}
+static const char** make_extra_args(const char *extra_args[static 4]) {
+ size_t n = 0;
+
+ if (arg_scope != UNIT_FILE_SYSTEM)
+ extra_args[n++] = "--user";
+
+ if (arg_transport == BUS_TRANSPORT_REMOTE) {
+ extra_args[n++] = "-H";
+ extra_args[n++] = arg_host;
+ } else if (arg_transport == BUS_TRANSPORT_MACHINE) {
+ extra_args[n++] = "-M";
+ extra_args[n++] = arg_host;
+ } else
+ assert(arg_transport == BUS_TRANSPORT_LOCAL);
+
+ extra_args[n] = NULL;
+ return extra_args;
+}
+
static int start_unit(int argc, char *argv[], void *userdata) {
_cleanup_(bus_wait_for_jobs_freep) BusWaitForJobs *w = NULL;
_cleanup_(wait_context_free) WaitContext wait_context = {};
@@ -3103,22 +3122,9 @@ static int start_unit(int argc, char *argv[], void *userdata) {
}
if (!arg_no_block) {
- const char* extra_args[4] = {};
- int arg_count = 0;
-
- if (arg_scope != UNIT_FILE_SYSTEM)
- extra_args[arg_count++] = "--user";
-
- assert(IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_REMOTE, BUS_TRANSPORT_MACHINE));
- if (arg_transport == BUS_TRANSPORT_REMOTE) {
- extra_args[arg_count++] = "-H";
- extra_args[arg_count++] = arg_host;
- } else if (arg_transport == BUS_TRANSPORT_MACHINE) {
- extra_args[arg_count++] = "-M";
- extra_args[arg_count++] = arg_host;
- }
+ const char* extra_args[4];
- r = bus_wait_for_jobs(w, arg_quiet, extra_args);
+ r = bus_wait_for_jobs(w, arg_quiet, make_extra_args(extra_args));
if (r < 0)
return r;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhonglingh/systemd.git
[email protected]:zhonglingh/systemd.git
zhonglingh
systemd
systemd
a8

搜索帮助