]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fd-util: rename CLOSE_AND_REPLACE() -> close_and_replace()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 16 Sep 2022 16:57:04 +0000 (01:57 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 17 Sep 2022 07:54:41 +0000 (09:54 +0200)
We have free_and_replace() and friends, they are all named with lower
letters, even they are macros, not functions.
For consistency, let's rename CLOSE_AND_REPLACE() with lower letters.

This also mekes the macro used more places.

src/basic/chase-symlinks.c
src/basic/fd-util.c
src/basic/fd-util.h
src/core/execute.c
src/home/homed-home.c
src/import/import-raw.c
src/import/pull-raw.c
src/libsystemd-network/sd-ipv4acd.c
src/login/logind-session-device.c
src/shared/data-fd-util.c
src/tmpfiles/tmpfiles.c

index ce50ff972619d883508ae9a971a389adcb3501d3..e889b22f47207554cf94fdea291a4378e2ab69e6 100644 (file)
@@ -265,8 +265,7 @@ int chase_symlinks(
                                 previous_stat = st;
                         }
 
-                        safe_close(fd);
-                        fd = TAKE_FD(fd_parent);
+                        close_and_replace(fd, fd_parent);
 
                         continue;
                 }
@@ -362,8 +361,7 @@ int chase_symlinks(
                         return -ENOMEM;
 
                 /* And iterate again, but go one directory further down. */
-                safe_close(fd);
-                fd = TAKE_FD(child);
+                close_and_replace(fd, child);
         }
 
         if (ret_path)
index 00591d6c2d31fe67805f6c6970100d6698273009..6c85a34896c97173a6739f0e6f67c35e33321c7d 100644 (file)
@@ -654,7 +654,7 @@ int rearrange_stdio(int original_input_fd, int original_output_fd, int original_
                                 goto finish;
                         }
 
-                        CLOSE_AND_REPLACE(null_fd, copy);
+                        close_and_replace(null_fd, copy);
                 }
         }
 
index 808cac4d5d4a10a9733de2ecb1cbec7e45a7bd38..8543d0d5eaa4d13f17160a5f4a2a8501f7e18b81 100644 (file)
@@ -98,7 +98,7 @@ static inline int make_null_stdio(void) {
         })
 
 /* Like free_and_replace(), but for file descriptors */
-#define CLOSE_AND_REPLACE(a, b)                 \
+#define close_and_replace(a, b)                 \
         ({                                      \
                 int *_fdp_ = &(a);              \
                 safe_close(*_fdp_);             \
index e9443500acf51208e4b51d629975a565eff7c561..6a4e1e09547444ff9d743324c6b766bb76e75f3b 100644 (file)
@@ -4073,7 +4073,7 @@ static int add_shifted_fd(int *fds, size_t fds_size, size_t *n_fds, int fd, int
                 if (r < 0)
                         return -errno;
 
-                CLOSE_AND_REPLACE(fd, r);
+                close_and_replace(fd, r);
         }
 
         *ret_fd = fds[*n_fds] = fd;
index 47dc16d83f9d23a2fcd29ef89cf6956274fbc5f2..19be186400dc1ef60819a6bedae28f6adff6528d 100644 (file)
@@ -2041,8 +2041,7 @@ void home_process_notify(Home *h, char **l, int fd) {
                         if (taken_fd < 0)
                                 return (void) log_debug("Got notify message with SYSTEMD_LUKS_LOCK_FD=1 but no fd passed, ignoring: %m");
 
-                        safe_close(h->luks_lock_fd);
-                        h->luks_lock_fd = TAKE_FD(taken_fd);
+                        close_and_replace(h->luks_lock_fd, taken_fd);
 
                         log_debug("Successfully acquired LUKS lock fd from worker.");
 
index 0faa58acf5bad78380cc78474de2f7f80ee33ef8..30f5b9050ba5803eb24b30a490d0747c0049a714 100644 (file)
@@ -195,7 +195,7 @@ static int raw_import_maybe_convert_qcow2(RawImport *i) {
 
         unlink_and_free(i->temp_path);
         i->temp_path = TAKE_PTR(t);
-        CLOSE_AND_REPLACE(i->output_fd, converted_fd);
+        close_and_replace(i->output_fd, converted_fd);
 
         return 1;
 }
index 0623afcc84bb5fac374373d0f62591efd11a7d23..f4f869d38e926f8af49d97744354dd6ee8ba8770 100644 (file)
@@ -280,7 +280,7 @@ static int raw_pull_maybe_convert_qcow2(RawPull *i) {
 
         unlink_and_free(i->temp_path);
         i->temp_path = TAKE_PTR(t);
-        CLOSE_AND_REPLACE(i->raw_job->disk_fd, converted_fd);
+        close_and_replace(i->raw_job->disk_fd, converted_fd);
 
         return 1;
 }
index 673783b2b3721a3d607890ce7e512150543ba115..9b11b2f160663f68a49e0ed6c78339284bad31a1 100644 (file)
@@ -583,7 +583,7 @@ int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts) {
         if (r < 0)
                 return r;
 
-        CLOSE_AND_REPLACE(acd->fd, r);
+        close_and_replace(acd->fd, r);
 
         if (reset_conflicts)
                 acd->n_conflict = 0;
index dc6a0d5407567248acb08e36841d27f369e73820..acf0f20d8590e921fb6e4ea31ff680b93f4a7ecd 100644 (file)
@@ -188,7 +188,7 @@ static int session_device_start(SessionDevice *sd) {
 
                 /* For evdev devices, the file descriptor might be left uninitialized. This might happen while resuming
                  * into a session and logind has been restarted right before. */
-                CLOSE_AND_REPLACE(sd->fd, r);
+                close_and_replace(sd->fd, r);
                 break;
 
         case DEVICE_TYPE_UNKNOWN:
index 6ae3f115350f9754048fe7e593ce24bd0a269241..b6eb3d9f4185017d4a44dc50733879a9af84e025 100644 (file)
@@ -298,7 +298,7 @@ int copy_data_fd(int fd) {
                 if (f != 0)
                         return -errno;
 
-                CLOSE_AND_REPLACE(copy_fd, tmp_fd);
+                close_and_replace(copy_fd, tmp_fd);
 
                 remains = mfree(remains);
                 remains_size = 0;
index ac6c5993e3cb885fa1f5ae931afbe9cce398c10e..d27dc39a1cb69e4ca23aea054f307d30fadb89cb 100644 (file)
@@ -2184,7 +2184,7 @@ static int mkdir_parents_rm_if_wrong_type(mode_t child_mode, const char *path) {
                         return log_error_errno(r, "Failed to stat \"%s\" at \"%s\": %m", t, strnull(parent_name));
                 }
 
-                CLOSE_AND_REPLACE(parent_fd, next_fd);
+                close_and_replace(parent_fd, next_fd);
         }
 }