diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-04-04 12:21:00 +0200 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2023-04-04 22:34:18 +0800 |
commit | 51339a9aebc4f8e8f14f684ab8d3ca3eed9cf7d9 (patch) | |
tree | 58569a29810d82309412627cf7b63f55c73e7881 /src/core/service.c | |
parent | 45f540a2974dc732820d20a0e73cfffc94766a70 (diff) | |
download | systemd-51339a9aebc4f8e8f14f684ab8d3ca3eed9cf7d9.tar.gz |
service: minor modernizations
Diffstat (limited to 'src/core/service.c')
-rw-r--r-- | src/core/service.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/core/service.c b/src/core/service.c index bebcf5cb5f..da75540c31 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -3445,30 +3445,30 @@ fail: } static int service_demand_pid_file(Service *s) { - PathSpec *ps; + _cleanup_free_ PathSpec *ps = NULL; assert(s->pid_file); assert(!s->pid_file_pathspec); - ps = new0(PathSpec, 1); + ps = new(PathSpec, 1); if (!ps) return -ENOMEM; - ps->unit = UNIT(s); - ps->path = strdup(s->pid_file); - if (!ps->path) { - free(ps); + *ps = (PathSpec) { + .unit = UNIT(s), + .path = strdup(s->pid_file), + /* PATH_CHANGED would not be enough. There are daemons (sendmail) that keep their PID file + * open all the time. */ + .type = PATH_MODIFIED, + .inotify_fd = -EBADF, + }; + + if (!ps->path) return -ENOMEM; - } path_simplify(ps->path); - /* PATH_CHANGED would not be enough. There are daemons (sendmail) that - * keep their PID file open all the time. */ - ps->type = PATH_MODIFIED; - ps->inotify_fd = -EBADF; - - s->pid_file_pathspec = ps; + s->pid_file_pathspec = TAKE_PTR(ps); return service_watch_pid_file(s); } |