]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/service: minor cleanup for service_add_fd_store
authorMike Yuan <me@yhndnzj.com>
Sun, 3 Mar 2024 09:56:57 +0000 (17:56 +0800)
committerMike Yuan <me@yhndnzj.com>
Sun, 3 Mar 2024 10:53:05 +0000 (18:53 +0800)
src/core/service.c

index 9ba2e09a8111867c5b45ecbc689f06cdc1a04f1e..e575e246642591b75cf7dcb36c28135be5fda407 100644 (file)
@@ -523,7 +523,8 @@ static int service_add_fd_store(Service *s, int fd_in, const char *name, bool do
         if (fstat(fd, &st) < 0)
                 return -errno;
 
-        log_unit_debug(UNIT(s), "Trying to stash fd for dev=" DEVNUM_FORMAT_STR "/inode=%" PRIu64, DEVNUM_FORMAT_VAL(st.st_dev), (uint64_t) st.st_ino);
+        log_unit_debug(UNIT(s), "Trying to stash fd for dev=" DEVNUM_FORMAT_STR "/inode=%" PRIu64,
+                       DEVNUM_FORMAT_VAL(st.st_dev), (uint64_t) st.st_ino);
 
         if (s->n_fd_store >= s->n_fd_store_max)
                 /* Our store is full.  Use this errno rather than E[NM]FILE to distinguish from the case
@@ -557,17 +558,16 @@ static int service_add_fd_store(Service *s, int fd_in, const char *name, bool do
                 r = sd_event_add_io(UNIT(s)->manager->event, &fs->event_source, fs->fd, 0, on_fd_store_io, fs);
                 if (r < 0 && r != -EPERM) /* EPERM indicates fds that aren't pollable, which is OK */
                         return r;
-                else if (r >= 0)
+                if (r >= 0)
                         (void) sd_event_source_set_description(fs->event_source, "service-fd-store");
         }
 
+        log_unit_debug(UNIT(s), "Added fd %i (%s) to fd store.", fs->fd, fs->fdname);
+
         fs->service = s;
-        LIST_PREPEND(fd_store, s->fd_store, fs);
+        LIST_PREPEND(fd_store, s->fd_store, TAKE_PTR(fs));
         s->n_fd_store++;
 
-        log_unit_debug(UNIT(s), "Added fd %i (%s) to fd store.", fs->fd, fs->fdname);
-
-        TAKE_PTR(fs);
         return 1; /* fd newly stored */
 }