Typical saving per callsite (on x86-64) is 7 bytes, so net win at 3
conversions.

function                                             old     new   delta
xopen_fd                                               -      18     +18
xargs_main                                           871     864      -7
vlock_main                                           409     402      -7
uniq_main                                            463     456      -7
ubi_tools_main                                      1298    1291      -7
split_main                                           581     574      -7
sort_main                                           1065    1058      -7
shuf_main                                            550     543      -7
reinitialize                                         206     199      -7
nc_main                                             1225    1218      -7
mkfs_minix_main                                     2865    2858      -7
mkfs_ext2_main                                      2405    2398      -7
fsck_minix_main                                     3145    3138      -7
acpid_main                                          1326    1319      -7
cpio_main                                            654     645      -9
close_dev_fd                                          28      19      -9
watchdog_main                                        335     321     -14
dd_main                                             1642    1628     -14
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/17 up/down: 18/-137)         Total: -119 bytes

Signed-off-by: Rasmus Villemoes <[email protected]>
---
 archival/cpio.c         | 6 +++---
 coreutils/dd.c          | 4 ++--
 coreutils/shuf.c        | 2 +-
 coreutils/sort.c        | 2 +-
 coreutils/split.c       | 2 +-
 coreutils/uniq.c        | 2 +-
 findutils/xargs.c       | 2 +-
 loginutils/vlock.c      | 2 +-
 miscutils/less.c        | 2 +-
 miscutils/ubi_tools.c   | 2 +-
 miscutils/watchdog.c    | 4 ++--
 networking/nc_bloaty.c  | 2 +-
 util-linux/acpid.c      | 2 +-
 util-linux/fdisk.c      | 2 +-
 util-linux/fsck_minix.c | 2 +-
 util-linux/mkfs_ext2.c  | 2 +-
 util-linux/mkfs_minix.c | 2 +-
 17 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/archival/cpio.c b/archival/cpio.c
index 94303389e..ab918f61a 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -405,11 +405,11 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
        }
 #if !ENABLE_FEATURE_CPIO_O
        if (opt & OPT_FILE) { /* -F */
-               xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
+               xopen_fd(cpio_filename, O_RDONLY, STDIN_FILENO);
        }
 #else
        if ((opt & (OPT_FILE|OPT_CREATE)) == OPT_FILE) { /* -F without -o */
-               xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
+               xopen_fd(cpio_filename, O_RDONLY, STDIN_FILENO);
        }
        if (opt & OPT_PASSTHROUGH) {
                pid_t pid;
@@ -459,7 +459,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
                if (cpio_fmt[0] != 'n') /* we _require_ "-H newc" */
                        bb_show_usage();
                if (opt & OPT_FILE) {
-                       xmove_fd(xopen(cpio_filename, O_WRONLY | O_CREAT | 
O_TRUNC), STDOUT_FILENO);
+                       xopen_fd(cpio_filename, O_WRONLY | O_CREAT | O_TRUNC, 
STDOUT_FILENO);
                }
  dump:
                return cpio_o();
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 24d7f0b84..215c61de9 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -500,7 +500,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
                if (G.flags & FLAG_IDIRECT)
                        iflag |= O_DIRECT;
 #endif
-               xmove_fd(xopen(infile, iflag), ifd);
+               xopen_fd(infile, iflag, ifd);
        } else {
                infile = bb_msg_standard_input;
        }
@@ -515,7 +515,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
                if (G.flags & FLAG_ODIRECT)
                        oflag |= O_DIRECT;
 #endif
-               xmove_fd(xopen(outfile, oflag), ofd);
+               xopen_fd(outfile, oflag, ofd);
 
                if (seek && !(G.flags & FLAG_NOTRUNC)) {
                        size_t blocksz = (G.flags & FLAG_SEEK_BYTES) ? 1 : obs;
diff --git a/coreutils/shuf.c b/coreutils/shuf.c
index fdbd3e9b2..a347eb645 100644
--- a/coreutils/shuf.c
+++ b/coreutils/shuf.c
@@ -132,7 +132,7 @@ int shuf_main(int argc, char **argv)
                shuffle_lines(lines, numlines);
 
        if (opts & OPT_o)
-               xmove_fd(xopen(opt_o_str, O_WRONLY|O_CREAT|O_TRUNC), 
STDOUT_FILENO);
+               xopen_fd(opt_o_str, O_WRONLY | O_CREAT | O_TRUNC, 
STDOUT_FILENO);
 
        if (opts & OPT_n) {
                unsigned maxlines;
diff --git a/coreutils/sort.c b/coreutils/sort.c
index b194847d1..36c160c16 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -635,7 +635,7 @@ int sort_main(int argc UNUSED_PARAM, char **argv)
 #if ENABLE_FEATURE_SORT_BIG
        /* Open output file _after_ we read all input ones */
        if (option_mask32 & FLAG_o)
-               xmove_fd(xopen(str_o, O_WRONLY|O_CREAT|O_TRUNC), STDOUT_FILENO);
+               xopen_fd(str_o, O_WRONLY | O_CREAT | O_TRUNC, STDOUT_FILENO);
 #endif
        {
                int ch = (option_mask32 & FLAG_z) ? '\0' : '\n';
diff --git a/coreutils/split.c b/coreutils/split.c
index 3fcfd95f2..dd56d43f6 100644
--- a/coreutils/split.c
+++ b/coreutils/split.c
@@ -148,7 +148,7 @@ int split_main(int argc UNUSED_PARAM, char **argv)
                        if (!remaining) {
                                if (!pfx)
                                        bb_simple_error_msg_and_die("suffixes 
exhausted");
-                               xmove_fd(xopen(pfx, O_WRONLY | O_CREAT | 
O_TRUNC), 1);
+                               xopen_fd(pfx, O_WRONLY | O_CREAT | O_TRUNC, 1);
                                pfx = next_file(pfx, suffix_len);
                                remaining = cnt;
                        }
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index e1594286f..26193ff70 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -80,7 +80,7 @@ int uniq_main(int argc UNUSED_PARAM, char **argv)
                                // Won't work with "uniq - FILE" and closed 
stdin:
                                //close(STDOUT_FILENO);
                                //xopen(output, O_WRONLY | O_CREAT | O_TRUNC);
-                               xmove_fd(xopen(output, O_WRONLY | O_CREAT | 
O_TRUNC), STDOUT_FILENO);
+                               xopen_fd(output, O_WRONLY | O_CREAT | O_TRUNC, 
STDOUT_FILENO);
                        }
                }
        }
diff --git a/findutils/xargs.c b/findutils/xargs.c
index e2b3527f3..b13e009de 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -633,7 +633,7 @@ int xargs_main(int argc UNUSED_PARAM, char **argv)
 
 #if ENABLE_FEATURE_XARGS_SUPPORT_ARGS_FILE
        if (opt_a)
-               xmove_fd(xopen(opt_a, O_RDONLY), 0);
+               xopen_fd(opt_a, O_RDONLY, 0);
 #endif
 
        /* -E ""? You may wonder why not just omit -E?
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 334b7d2ad..4aa42993e 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -91,7 +91,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
 
        /* Revert stdin/out to our controlling tty
         * (or die if we have none) */
-       xmove_fd(xopen(CURRENT_TTY, O_RDWR), STDIN_FILENO);
+       xopen_fd(CURRENT_TTY, O_RDWR, STDIN_FILENO);
        xdup2(STDIN_FILENO, STDOUT_FILENO);
 
 #ifdef __linux__
diff --git a/miscutils/less.c b/miscutils/less.c
index 223c2558d..3a1ece1d6 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -1048,7 +1048,7 @@ static void buffer_lineno(int lineno)
 static void open_file_and_read_lines(void)
 {
        if (filename) {
-               xmove_fd(xopen(filename, O_RDONLY), STDIN_FILENO);
+               xopen_fd(filename, O_RDONLY, STDIN_FILENO);
 #if ENABLE_FEATURE_LESS_FLAGS
                num_lines = REOPEN_AND_COUNT;
 #endif
diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c
index 69ead7a13..4ebd31f75 100644
--- a/miscutils/ubi_tools.c
+++ b/miscutils/ubi_tools.c
@@ -323,7 +323,7 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv)
                        if (!*argv)
                                bb_show_usage();
                        if (NOT_LONE_DASH(*argv)) /* mtd-utils supports "-" as 
stdin */
-                               xmove_fd(xopen(*argv, O_RDONLY), STDIN_FILENO);
+                               xopen_fd(*argv, O_RDONLY, STDIN_FILENO);
 
                        if (!(opts & OPTION_s)) {
                                struct stat st;
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c
index 0ed10bcf1..706b7b7cb 100644
--- a/miscutils/watchdog.c
+++ b/miscutils/watchdog.c
@@ -71,7 +71,7 @@ static void shutdown_on_signal(int sig UNUSED_PARAM)
 static void watchdog_open(const char* device)
 {
        /* Use known fd # - avoid needing global 'int fd' */
-       xmove_fd(xopen(device, O_WRONLY), 3);
+       xopen_fd(device, O_WRONLY, 3);
 
        /* If the watchdog driver can do something other than cause a reboot
         * on a timeout, then it's possible this program may be starting from
@@ -81,7 +81,7 @@ static void watchdog_open(const char* device)
         */
        shutdown_watchdog();
 
-       xmove_fd(xopen(device, O_WRONLY), 3);
+       xopen_fd(device, O_WRONLY, 3);
 }
 
 int watchdog_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c
index 25b95246f..1b2d0e65b 100644
--- a/networking/nc_bloaty.c
+++ b/networking/nc_bloaty.c
@@ -885,7 +885,7 @@ int nc_main(int argc UNUSED_PARAM, char **argv)
        }
 #if ENABLE_NC_EXTRA
        if (o_ofile)
-               xmove_fd(xopen(str_o, O_WRONLY|O_CREAT|O_TRUNC), ofd);
+               xopen_fd(str_o, O_WRONLY | O_CREAT | O_TRUNC, ofd);
 #endif
 
        if (cnt_l != 0) {
diff --git a/util-linux/acpid.c b/util-linux/acpid.c
index 00613f8e3..8515cb89e 100644
--- a/util-linux/acpid.c
+++ b/util-linux/acpid.c
@@ -285,7 +285,7 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
                /* No -d "Debug", we log to log file.
                 * This includes any output from children.
                 */
-               xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_APPEND), 
STDOUT_FILENO);
+               xopen_fd(opt_logfile, O_WRONLY | O_CREAT | O_APPEND, 
STDOUT_FILENO);
                xdup2(STDOUT_FILENO, STDERR_FILENO);
                /* Also, acpid's messages (but not children) will go to syslog 
too */
                openlog(applet_name, LOG_PID, LOG_DAEMON);
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index c50ceead1..6f4c585ca 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -549,7 +549,7 @@ static void
 close_dev_fd(void)
 {
        /* Not really closing, but making sure it is open, and to harmless 
place */
-       xmove_fd(xopen(bb_dev_null, O_RDONLY), dev_fd);
+       xopen_fd(bb_dev_null, O_RDONLY, dev_fd);
 }
 
 /* Return partition name */
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index 40b86d01b..fc6922681 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -1244,7 +1244,7 @@ int fsck_minix_main(int argc UNUSED_PARAM, char **argv)
                if (!isatty(0) || !isatty(1))
                        die("need terminal for interactive repairs");
        }
-       xmove_fd(xopen(device_name, OPT_repair ? O_RDWR : O_RDONLY), dev_fd);
+       xopen_fd(device_name, OPT_repair ? O_RDWR : O_RDONLY, dev_fd);
 
        /*sync(); paranoia? */
        read_superblock();
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index fcf374b2d..e736039c4 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -255,7 +255,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
        argv += optind; // argv[0] -- device
 
        // open the device, check the device is a block device
-       xmove_fd(xopen(argv[0], O_WRONLY), fd);
+       xopen_fd(argv[0], O_WRONLY, fd);
        xfstat(fd, &st, argv[0]);
        if (!S_ISBLK(st.st_mode) && !(option_mask32 & OPT_F))
                bb_error_msg_and_die("%s: not a block device", argv[0]);
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 3c72e5419..03714ac92 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -655,7 +655,7 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
        if (find_mount_point(G.device_name, 0))
                bb_simple_error_msg_and_die("can't format mounted filesystem");
 
-       xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
+       xopen_fd(G.device_name, O_RDWR, dev_fd);
 
        G.total_blocks = get_volume_size_in_bytes(dev_fd, argv[1], 1024, 
/*extend:*/ 1) / 1024;
 
-- 
2.29.2

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to