aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2026-02-06 13:16:36 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2026-02-06 13:16:36 +0100
commitc8cbd3516d85e029b17d17c27d249ea727df3db9 (patch)
treee3696dc8a0449ee736bbebfbb518c672f6e9dc72
parent9b2a50efe227048e3d5029148619d5cc5ad089be (diff)
downloadbusybox-w32-c8cbd3516d85e029b17d17c27d249ea727df3db9.tar.gz
busybox-w32-c8cbd3516d85e029b17d17c27d249ea727df3db9.tar.bz2
busybox-w32-c8cbd3516d85e029b17d17c27d249ea727df3db9.zip
*: use xasprintf_inplace() and concat_path_file() where appropriate
function old new delta acpid_main 1059 1063 +4 resume_main 561 560 -1 unpack_package 642 640 -2 adduser_main 861 859 -2 getty_main 1517 1512 -5 ftpd_main 2149 2142 -7 .rodata 107018 107010 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/6 up/down: 4/-25) Total: -21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/dpkg.c2
-rw-r--r--klibc-utils/resume.c2
-rw-r--r--loginutils/adduser.c2
-rw-r--r--loginutils/getty.c2
-rw-r--r--modutils/modprobe-small.c6
-rw-r--r--networking/ftpd.c13
-rw-r--r--util-linux/acpid.c2
7 files changed, 13 insertions, 16 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 8031956e9..eda5ec7eb 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1689,7 +1689,7 @@ static void unpack_package(deb_file_t *deb_file)
1689 accept_list = NULL; 1689 accept_list = NULL;
1690 i = 0; 1690 i = 0;
1691 while (i < ARRAY_SIZE(all_control_files)) { 1691 while (i < ARRAY_SIZE(all_control_files)) {
1692 char *c = xasprintf("./%s", all_control_files[i]); 1692 char *c = concat_path_file(".", all_control_files[i]);
1693 llist_add_to(&accept_list, c); 1693 llist_add_to(&accept_list, c);
1694 i++; 1694 i++;
1695 } 1695 }
diff --git a/klibc-utils/resume.c b/klibc-utils/resume.c
index 7b9d18b5d..fde5587e2 100644
--- a/klibc-utils/resume.c
+++ b/klibc-utils/resume.c
@@ -59,7 +59,7 @@ static dev_t name_to_dev_t(const char *devname)
59 return res; 59 return res;
60 } 60 }
61 61
62 devname = xasprintf("/dev/%s", devname); 62 devname = concat_path_file("/dev", devname);
63 } 63 }
64 /* Now devname is always "/dev/FOO" */ 64 /* Now devname is always "/dev/FOO" */
65 65
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index bfab05203..ac43feb48 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -227,7 +227,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
227 die_if_bad_username(pw.pw_name); 227 die_if_bad_username(pw.pw_name);
228 if (!pw.pw_dir) { 228 if (!pw.pw_dir) {
229 /* create string for $HOME if not specified already */ 229 /* create string for $HOME if not specified already */
230 pw.pw_dir = xasprintf("/home/%s", argv[0]); 230 pw.pw_dir = concat_path_file("/home", argv[0]);
231 } 231 }
232 pw.pw_passwd = (char *)"x"; 232 pw.pw_passwd = (char *)"x";
233 if (opts & OPT_SYSTEM_ACCOUNT) { 233 if (opts & OPT_SYSTEM_ACCOUNT) {
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 4581cc9f7..67a08f487 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -213,7 +213,7 @@ static void open_tty(void)
213 /* Set up new standard input, unless we are given an already opened port */ 213 /* Set up new standard input, unless we are given an already opened port */
214 if (NOT_LONE_DASH(G.tty_name)) { 214 if (NOT_LONE_DASH(G.tty_name)) {
215 if (G.tty_name[0] != '/') 215 if (G.tty_name[0] != '/')
216 G.tty_name = xasprintf("/dev/%s", G.tty_name); /* will leak it */ 216 G.tty_name = concat_path_file("/dev", G.tty_name); /* will leak it */
217 217
218 /* Open the tty as standard input */ 218 /* Open the tty as standard input */
219 debug("open(2)\n"); 219 debug("open(2)\n");
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index b3c0768ee..7f584102d 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -723,7 +723,7 @@ static int process_module(char *name, const char *cmdline_options)
723 723
724 options = NULL; 724 options = NULL;
725 if (!is_remove) { 725 if (!is_remove) {
726 char *opt_filename = xasprintf("/etc/modules/%s", name); 726 char *opt_filename = concat_path_file("/etc/modules", name);
727 options = xmalloc_open_read_close(opt_filename, NULL); 727 options = xmalloc_open_read_close(opt_filename, NULL);
728 if (options) 728 if (options)
729 replace_char(options, '\n', ' '); 729 replace_char(options, '\n', ' ');
@@ -731,10 +731,8 @@ static int process_module(char *name, const char *cmdline_options)
731 if (cmdline_options) { 731 if (cmdline_options) {
732 /* NB: cmdline_options always have one leading ' ' 732 /* NB: cmdline_options always have one leading ' '
733 * (see main()), we remove it here */ 733 * (see main()), we remove it here */
734 char *op = xasprintf(options ? "%s %s" : "%s %s" + 3, 734 xasprintf_inplace(options, options ? "%s %s" : "%s %s" + 3,
735 cmdline_options + 1, options); 735 cmdline_options + 1, options);
736 free(options);
737 options = op;
738 } 736 }
739#endif 737#endif
740 free(opt_filename); 738 free(opt_filename);
diff --git a/networking/ftpd.c b/networking/ftpd.c
index c3125410e..96db5d9fd 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -491,19 +491,18 @@ static void
491handle_pasv(void) 491handle_pasv(void)
492{ 492{
493 unsigned port; 493 unsigned port;
494 char *addr, *response; 494 char *response;
495 495
496 port = bind_for_passive_mode(); 496 port = bind_for_passive_mode();
497 497
498 if (G.local_addr->u.sa.sa_family == AF_INET) 498 if (G.local_addr->u.sa.sa_family == AF_INET)
499 addr = xmalloc_sockaddr2dotted_noport(&G.local_addr->u.sa); 499 response = xmalloc_sockaddr2dotted_noport(&G.local_addr->u.sa);
500 else /* seen this in the wild done by other ftp servers: */ 500 else /* seen this in the wild done by other ftp servers: */
501 addr = xstrdup("0.0.0.0"); 501 response = xstrdup("0.0.0.0");
502 replace_char(addr, '.', ','); 502 replace_char(response, '.', ',');
503 503
504 response = xasprintf(STR(FTP_PASVOK)" PASV ok (%s,%u,%u)\r\n", 504 xasprintf_inplace(response, STR(FTP_PASVOK)" PASV ok (%s,%u,%u)\r\n",
505 addr, (int)(port >> 8), (int)(port & 255)); 505 response, (int)(port >> 8), (int)(port & 255));
506 free(addr);
507 cmdio_write_raw(response); 506 cmdio_write_raw(response);
508 free(response); 507 free(response);
509} 508}
diff --git a/util-linux/acpid.c b/util-linux/acpid.c
index 5c0bb1768..386b988d2 100644
--- a/util-linux/acpid.c
+++ b/util-linux/acpid.c
@@ -145,7 +145,7 @@ struct globals {
145static void process_event(const char *event) 145static void process_event(const char *event)
146{ 146{
147 struct stat st; 147 struct stat st;
148 char *handler = xasprintf("./%s", event); 148 char *handler = concat_path_file(".", event);
149 const char *args[] = { "run-parts", handler, NULL }; 149 const char *args[] = { "run-parts", handler, NULL };
150 150
151 // log the event 151 // log the event