summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-03-17 04:46:51 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-03-17 12:38:15 +0100
commit8e8df8292a898ef8f4ac9107a45e86c83fbb3178 (patch)
tree5ed3f7ac182423237bc0cf9ff50467d4fbf9337a /src
parentMerge pull request #26849 from DaanDeMeyer/fwd-colors (diff)
downloadsystemd-8e8df8292a898ef8f4ac9107a45e86c83fbb3178.tar.xz
systemd-8e8df8292a898ef8f4ac9107a45e86c83fbb3178.zip
exec-util: tighten variable scope a bit
Diffstat (limited to 'src')
-rw-r--r--src/shared/exec-util.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c
index 40e9342cd5..d38bfc9e4a 100644
--- a/src/shared/exec-util.c
+++ b/src/shared/exec-util.c
@@ -203,23 +203,24 @@ int execute_directories(
ExecDirFlags flags) {
char **dirs = (char**) directories;
- _cleanup_free_ char *name = NULL;
_cleanup_close_ int fd = -EBADF;
int r;
pid_t executor_pid;
assert(!strv_isempty(dirs));
- r = path_extract_filename(dirs[0], &name);
- if (r < 0)
- return log_error_errno(r, "Failed to extract file name from '%s': %m", dirs[0]);
-
if (callbacks) {
assert(callback_args);
assert(callbacks[STDOUT_GENERATE]);
assert(callbacks[STDOUT_COLLECT]);
assert(callbacks[STDOUT_CONSUME]);
+ _cleanup_free_ char *name = NULL;
+
+ r = path_extract_filename(dirs[0], &name);
+ if (r < 0)
+ return log_error_errno(r, "Failed to extract file name from '%s': %m", dirs[0]);
+
fd = open_serialization_fd(name);
if (fd < 0)
return log_error_errno(fd, "Failed to open serialization file: %m");