*: use xasprintf_inplace() and concat_path_file() where appropriate
No binary (build failed)
gcc -Wp,-MD,applets/.usage.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -Iinclude -Iinclude -o applets/usage applets/usage.c
(log yok)
| @@ -1689,7 +1689,7 @@ static void unpack_package(deb_file_t *deb_file) | |
| accept_list = NULL; | |
| i = 0; | |
| while (i < ARRAY_SIZE(all_control_files)) { | |
| - | char *c = xasprintf("./%s", all_control_files[i]); |
| + | char *c = concat_path_file(".", all_control_files[i]); |
| llist_add_to(&accept_list, c); | |
| i++; | |
| } | |
| @@ -59,7 +59,7 @@ static dev_t name_to_dev_t(const char *devname) | |
| return res; | |
| } | |
| - | devname = xasprintf("/dev/%s", devname); |
| + | devname = concat_path_file("/dev", devname); |
| } | |
| /* Now devname is always "/dev/FOO" */ | |
| @@ -227,7 +227,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |
| die_if_bad_username(pw.pw_name); | |
| if (!pw.pw_dir) { | |
| /* create string for $HOME if not specified already */ | |
| - | pw.pw_dir = xasprintf("/home/%s", argv[0]); |
| + | pw.pw_dir = concat_path_file("/home", argv[0]); |
| } | |
| pw.pw_passwd = (char *)"x"; | |
| if (opts & OPT_SYSTEM_ACCOUNT) { | |
| @@ -213,7 +213,7 @@ static void open_tty(void) | |
| /* Set up new standard input, unless we are given an already opened port */ | |
| if (NOT_LONE_DASH(G.tty_name)) { | |
| if (G.tty_name[0] != '/') | |
| - | G.tty_name = xasprintf("/dev/%s", G.tty_name); /* will leak it */ |
| + | G.tty_name = concat_path_file("/dev", G.tty_name); /* will leak it */ |
| /* Open the tty as standard input */ | |
| debug("open(2)\n"); | |
| @@ -723,7 +723,7 @@ static int process_module(char *name, const char *cmdline_options) | |
| options = NULL; | |
| if (!is_remove) { | |
| - | char *opt_filename = xasprintf("/etc/modules/%s", name); |
| + | char *opt_filename = concat_path_file("/etc/modules", name); |
| options = xmalloc_open_read_close(opt_filename, NULL); | |
| if (options) | |
| replace_char(options, '\n', ' '); | |
| @@ -731,10 +731,8 @@ static int process_module(char *name, const char *cmdline_options) | |
| if (cmdline_options) { | |
| /* NB: cmdline_options always have one leading ' ' | |
| * (see main()), we remove it here */ | |
| - | char *op = xasprintf(options ? "%s %s" : "%s %s" + 3, |
| + | xasprintf_inplace(options, options ? "%s %s" : "%s %s" + 3, |
| cmdline_options + 1, options); | |
| - | free(options); |
| - | options = op; |
| } | |
| #endif | |
| free(opt_filename); | |
| @@ -491,19 +491,18 @@ static void | |
| handle_pasv(void) | |
| { | |
| unsigned port; | |
| - | char *addr, *response; |
| + | char *response; |
| port = bind_for_passive_mode(); | |
| if (G.local_addr->u.sa.sa_family == AF_INET) | |
| - | addr = xmalloc_sockaddr2dotted_noport(&G.local_addr->u.sa); |
| + | response = xmalloc_sockaddr2dotted_noport(&G.local_addr->u.sa); |
| else /* seen this in the wild done by other ftp servers: */ | |
| - | addr = xstrdup("0.0.0.0"); |
| - | replace_char(addr, '.', ','); |
| + | response = xstrdup("0.0.0.0"); |
| + | replace_char(response, '.', ','); |
| - | response = xasprintf(STR(FTP_PASVOK)" PASV ok (%s,%u,%u)\r\n", |
| - | addr, (int)(port >> 8), (int)(port & 255)); |
| - | free(addr); |
| + | xasprintf_inplace(response, STR(FTP_PASVOK)" PASV ok (%s,%u,%u)\r\n", |
| + | response, (int)(port >> 8), (int)(port & 255)); |
| cmdio_write_raw(response); | |
| free(response); | |
| } | |
| @@ -145,7 +145,7 @@ struct globals { | |
| static void process_event(const char *event) | |
| { | |
| struct stat st; | |
| - | char *handler = xasprintf("./%s", event); |
| + | char *handler = concat_path_file(".", event); |
| const char *args[] = { "run-parts", handler, NULL }; | |
| // log the event | |