diff options
author | vodz <vodz@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-09-29 16:18:57 +0000 |
---|---|---|
committer | vodz <vodz@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-09-29 16:18:57 +0000 |
commit | f18b720f9a960d701f8d32a199e8b2a3975f9d6c (patch) | |
tree | 5b3a1d569d1e952d8c43899050dca4d6c47bf176 | |
parent | 7c8bf4a0ff3205a5ee8d9a6292036d905db3c479 (diff) | |
download | busybox-w32-f18b720f9a960d701f8d32a199e8b2a3975f9d6c.tar.gz busybox-w32-f18b720f9a960d701f8d32a199e8b2a3975f9d6c.tar.bz2 busybox-w32-f18b720f9a960d701f8d32a199e8b2a3975f9d6c.zip |
change interface to bb_xasprintf() - more perfect for me.
ln.c: error_msg(str)->error_msg(%s, str) - remove standart "feature" for hackers
reduce 100 bytes don't care in sum
git-svn-id: svn://busybox.net/trunk/busybox@11694 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | archival/tar.c | 8 | ||||
-rw-r--r-- | coreutils/expr.c | 2 | ||||
-rw-r--r-- | coreutils/ln.c | 8 | ||||
-rw-r--r-- | e2fsprogs/fsck.c | 13 | ||||
-rw-r--r-- | e2fsprogs/mke2fs.c | 5 | ||||
-rw-r--r-- | include/libbb.h | 3 | ||||
-rw-r--r-- | libbb/bb_asprintf.c | 8 | ||||
-rw-r--r-- | libbb/concat_path_file.c | 5 | ||||
-rw-r--r-- | libbb/run_shell.c | 7 | ||||
-rw-r--r-- | loginutils/adduser.c | 2 | ||||
-rw-r--r-- | miscutils/less.c | 7 | ||||
-rw-r--r-- | miscutils/mountpoint.c | 4 | ||||
-rw-r--r-- | modutils/insmod.c | 4 | ||||
-rw-r--r-- | networking/ifupdown.c | 2 | ||||
-rw-r--r-- | procps/sysctl.c | 2 | ||||
-rw-r--r-- | shell/cmdedit.c | 2 |
16 files changed, 33 insertions, 49 deletions
diff --git a/archival/tar.c b/archival/tar.c index 7a82b441b..f6750ae33 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -695,12 +695,8 @@ int tar_main(int argc, char **argv) | |||
695 | } | 695 | } |
696 | 696 | ||
697 | /* Prepend '-' to the first argument if required */ | 697 | /* Prepend '-' to the first argument if required */ |
698 | if (argv[1][0] != '-') { | 698 | if (argv[1][0] != '-') |
699 | char *tmp; | 699 | argv[1] = bb_xasprintf("-%s", argv[1]); |
700 | |||
701 | bb_xasprintf(&tmp, "-%s", argv[1]); | ||
702 | argv[1] = tmp; | ||
703 | } | ||
704 | 700 | ||
705 | /* Initialise default values */ | 701 | /* Initialise default values */ |
706 | tar_handle = init_handle(); | 702 | tar_handle = init_handle(); |
diff --git a/coreutils/expr.c b/coreutils/expr.c index 3f052d92a..969d9fff5 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
@@ -147,7 +147,7 @@ static int null (VALUE *v) | |||
147 | static void tostring (VALUE *v) | 147 | static void tostring (VALUE *v) |
148 | { | 148 | { |
149 | if (v->type == integer) { | 149 | if (v->type == integer) { |
150 | bb_xasprintf (&(v->u.s), "%d", v->u.i); | 150 | v->u.s = bb_xasprintf ("%d", v->u.i); |
151 | v->type = string; | 151 | v->type = string; |
152 | } | 152 | } |
153 | } | 153 | } |
diff --git a/coreutils/ln.c b/coreutils/ln.c index 274e0d06c..6751e9093 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c | |||
@@ -74,17 +74,17 @@ extern int ln_main(int argc, char **argv) | |||
74 | src_name = src; | 74 | src_name = src; |
75 | } | 75 | } |
76 | if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) { | 76 | if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) { |
77 | bb_perror_msg(*argv); | 77 | bb_perror_msg("%s", *argv); |
78 | status = EXIT_FAILURE; | 78 | status = EXIT_FAILURE; |
79 | free(src_name); | 79 | free(src_name); |
80 | continue; | 80 | continue; |
81 | } | 81 | } |
82 | 82 | ||
83 | if (flag & LN_BACKUP) { | 83 | if (flag & LN_BACKUP) { |
84 | char *backup = NULL; | 84 | char *backup; |
85 | bb_xasprintf(&backup, "%s%s", src, suffix); | 85 | backup = bb_xasprintf("%s%s", src, suffix); |
86 | if (rename(src, backup) < 0 && errno != ENOENT) { | 86 | if (rename(src, backup) < 0 && errno != ENOENT) { |
87 | bb_perror_msg(src); | 87 | bb_perror_msg("%s", src); |
88 | status = EXIT_FAILURE; | 88 | status = EXIT_FAILURE; |
89 | free(backup); | 89 | free(backup); |
90 | continue; | 90 | continue; |
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c index bb334e3dd..93514a391 100644 --- a/e2fsprogs/fsck.c +++ b/e2fsprogs/fsck.c | |||
@@ -363,7 +363,6 @@ static char *find_fsck(char *type) | |||
363 | { | 363 | { |
364 | char *s; | 364 | char *s; |
365 | const char *tpl; | 365 | const char *tpl; |
366 | char *prog; | ||
367 | char *p = string_copy(fsck_path); | 366 | char *p = string_copy(fsck_path); |
368 | struct stat st; | 367 | struct stat st; |
369 | 368 | ||
@@ -371,12 +370,12 @@ static char *find_fsck(char *type) | |||
371 | tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s"); | 370 | tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s"); |
372 | 371 | ||
373 | for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) { | 372 | for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) { |
374 | bb_xasprintf(&prog, tpl, s, type); | 373 | s = bb_xasprintf(tpl, s, type); |
375 | if (stat(prog, &st) == 0) break; | 374 | if (stat(s, &st) == 0) break; |
376 | free(prog); | 375 | free(s); |
377 | } | 376 | } |
378 | free(p); | 377 | free(p); |
379 | return(s ? prog : NULL); | 378 | return(s); |
380 | } | 379 | } |
381 | 380 | ||
382 | static int progress_active(void) | 381 | static int progress_active(void) |
@@ -410,7 +409,7 @@ static int execute(const char *type, const char *device, const char *mntpt, | |||
410 | return ENOMEM; | 409 | return ENOMEM; |
411 | memset(inst, 0, sizeof(struct fsck_instance)); | 410 | memset(inst, 0, sizeof(struct fsck_instance)); |
412 | 411 | ||
413 | bb_xasprintf(&prog, "fsck.%s", type); | 412 | prog = bb_xasprintf("fsck.%s", type); |
414 | argv[0] = prog; | 413 | argv[0] = prog; |
415 | argc = 1; | 414 | argc = 1; |
416 | 415 | ||
@@ -1189,7 +1188,7 @@ int fsck_main(int argc, char *argv[]) | |||
1189 | 1188 | ||
1190 | /* Update our search path to include uncommon directories. */ | 1189 | /* Update our search path to include uncommon directories. */ |
1191 | if (oldpath) { | 1190 | if (oldpath) { |
1192 | bb_xasprintf(&fsck_path, "%s:%s", fsck_prefix_path, oldpath); | 1191 | fsck_path = bb_xasprintf("%s:%s", fsck_prefix_path, oldpath); |
1193 | } else { | 1192 | } else { |
1194 | fsck_path = string_copy(fsck_prefix_path); | 1193 | fsck_path = string_copy(fsck_prefix_path); |
1195 | } | 1194 | } |
diff --git a/e2fsprogs/mke2fs.c b/e2fsprogs/mke2fs.c index 017fb53c5..6cd5bd420 100644 --- a/e2fsprogs/mke2fs.c +++ b/e2fsprogs/mke2fs.c | |||
@@ -794,10 +794,7 @@ static int PRS(int argc, char *argv[]) | |||
794 | 794 | ||
795 | /* Update our PATH to include /sbin */ | 795 | /* Update our PATH to include /sbin */ |
796 | if (oldpath) { | 796 | if (oldpath) { |
797 | char *newpath; | 797 | putenv (bb_xasprintf("%s:%s", PATH_SET, oldpath)); |
798 | |||
799 | bb_xasprintf(&newpath, "%s:%s", PATH_SET, oldpath); | ||
800 | putenv(newpath); | ||
801 | } else | 798 | } else |
802 | putenv (PATH_SET); | 799 | putenv (PATH_SET); |
803 | 800 | ||
diff --git a/include/libbb.h b/include/libbb.h index c92d97240..02bdb5861 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -408,8 +408,7 @@ void reset_ino_dev_hashtable(void); | |||
408 | extern size_t bb_strlen(const char *string); | 408 | extern size_t bb_strlen(const char *string); |
409 | #define strlen(x) bb_strlen(x) | 409 | #define strlen(x) bb_strlen(x) |
410 | 410 | ||
411 | void bb_xasprintf(char **string_ptr, const char *format, ...) __attribute__ ((format (printf, 2, 3))); | 411 | char *bb_xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); |
412 | |||
413 | 412 | ||
414 | #define FAIL_DELAY 3 | 413 | #define FAIL_DELAY 3 |
415 | extern void change_identity ( const struct passwd *pw ); | 414 | extern void change_identity ( const struct passwd *pw ); |
diff --git a/libbb/bb_asprintf.c b/libbb/bb_asprintf.c index a3ba42454..8658a5408 100644 --- a/libbb/bb_asprintf.c +++ b/libbb/bb_asprintf.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Vladimir Oleynik <dzo@simtreas.ru> | 2 | Copyright (C) 2002,2005 Vladimir Oleynik <dzo@simtreas.ru> |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
@@ -7,16 +7,18 @@ | |||
7 | #include <stdarg.h> | 7 | #include <stdarg.h> |
8 | #include "libbb.h" | 8 | #include "libbb.h" |
9 | 9 | ||
10 | void bb_xasprintf(char **string_ptr, const char *format, ...) | 10 | char *bb_xasprintf(const char *format, ...) |
11 | { | 11 | { |
12 | va_list p; | 12 | va_list p; |
13 | int r; | 13 | int r; |
14 | char *string_ptr; | ||
14 | 15 | ||
15 | va_start(p, format); | 16 | va_start(p, format); |
16 | r = vasprintf(string_ptr, format, p); | 17 | r = vasprintf(&string_ptr, format, p); |
17 | va_end(p); | 18 | va_end(p); |
18 | 19 | ||
19 | if (r < 0) { | 20 | if (r < 0) { |
20 | bb_perror_msg_and_die("bb_xasprintf"); | 21 | bb_perror_msg_and_die("bb_xasprintf"); |
21 | } | 22 | } |
23 | return string_ptr; | ||
22 | } | 24 | } |
diff --git a/libbb/concat_path_file.c b/libbb/concat_path_file.c index 00233ad9a..029c23272 100644 --- a/libbb/concat_path_file.c +++ b/libbb/concat_path_file.c | |||
@@ -30,7 +30,6 @@ | |||
30 | 30 | ||
31 | extern char *concat_path_file(const char *path, const char *filename) | 31 | extern char *concat_path_file(const char *path, const char *filename) |
32 | { | 32 | { |
33 | char *outbuf; | ||
34 | char *lc; | 33 | char *lc; |
35 | 34 | ||
36 | if (!path) | 35 | if (!path) |
@@ -38,7 +37,5 @@ extern char *concat_path_file(const char *path, const char *filename) | |||
38 | lc = last_char_is(path, '/'); | 37 | lc = last_char_is(path, '/'); |
39 | while (*filename == '/') | 38 | while (*filename == '/') |
40 | filename++; | 39 | filename++; |
41 | bb_xasprintf(&outbuf, "%s%s%s", path, (lc==NULL ? "/" : ""), filename); | 40 | return bb_xasprintf("%s%s%s", path, (lc==NULL ? "/" : ""), filename); |
42 | |||
43 | return outbuf; | ||
44 | } | 41 | } |
diff --git a/libbb/run_shell.c b/libbb/run_shell.c index 67ff2a5f8..6d084eead 100644 --- a/libbb/run_shell.c +++ b/libbb/run_shell.c | |||
@@ -84,11 +84,8 @@ void run_shell ( const char *shell, int loginshell, const char *command, const c | |||
84 | 84 | ||
85 | args [0] = bb_get_last_path_component ( bb_xstrdup ( shell )); | 85 | args [0] = bb_get_last_path_component ( bb_xstrdup ( shell )); |
86 | 86 | ||
87 | if ( loginshell ) { | 87 | if ( loginshell ) |
88 | char *args0; | 88 | args [0] = bb_xasprintf ("-%s", args [0]); |
89 | bb_xasprintf ( &args0, "-%s", args [0] ); | ||
90 | args [0] = args0; | ||
91 | } | ||
92 | 89 | ||
93 | if ( command ) { | 90 | if ( command ) { |
94 | args [argno++] = "-c"; | 91 | args [argno++] = "-c"; |
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index eb9890168..1630c72ba 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -117,7 +117,7 @@ static void addgroup_wrapper(const char *login, gid_t gid) | |||
117 | { | 117 | { |
118 | char *cmd; | 118 | char *cmd; |
119 | 119 | ||
120 | bb_xasprintf(&cmd, "addgroup -g %d %s", gid, login); | 120 | cmd = bb_xasprintf("addgroup -g %d %s", gid, login); |
121 | system(cmd); | 121 | system(cmd); |
122 | free(cmd); | 122 | free(cmd); |
123 | } | 123 | } |
diff --git a/miscutils/less.c b/miscutils/less.c index 7b1b96c6d..189b886f7 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
@@ -208,7 +208,7 @@ static void add_linenumbers(void) { | |||
208 | 208 | ||
209 | for (i = 0; i <= num_flines; i++) { | 209 | for (i = 0; i <= num_flines; i++) { |
210 | safe_strncpy(current_line, flines[i], 256); | 210 | safe_strncpy(current_line, flines[i], 256); |
211 | bb_xasprintf(&flines[i],"%5d %s", i + 1, current_line); | 211 | flines[i] = bb_xasprintf("%5d %s", i + 1, current_line); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
@@ -618,11 +618,8 @@ static void colon_process(void) { | |||
618 | 618 | ||
619 | static char *insert_highlights (char *line, int start, int end) { | 619 | static char *insert_highlights (char *line, int start, int end) { |
620 | 620 | ||
621 | char *new_line; | 621 | return bb_xasprintf("%.*s%s%.*s%s%s", start, line, HIGHLIGHT, |
622 | |||
623 | bb_xasprintf(&new_line, "%.*s%s%.*s%s%s", start, line, HIGHLIGHT, | ||
624 | end - start, line + start, NORMAL, line + end); | 622 | end - start, line + start, NORMAL, line + end); |
625 | return new_line; | ||
626 | } | 623 | } |
627 | 624 | ||
628 | static char *process_regex_on_line(char *line, regex_t *pattern) { | 625 | static char *process_regex_on_line(char *line, regex_t *pattern) { |
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c index 46b2d4e26..771df5588 100644 --- a/miscutils/mountpoint.c +++ b/miscutils/mountpoint.c | |||
@@ -46,8 +46,8 @@ int mountpoint_main(int argc, char **argv) | |||
46 | if (S_ISDIR(st.st_mode)) { | 46 | if (S_ISDIR(st.st_mode)) { |
47 | dev_t st_dev = st.st_dev; | 47 | dev_t st_dev = st.st_dev; |
48 | ino_t st_ino = st.st_ino; | 48 | ino_t st_ino = st.st_ino; |
49 | char *p; | 49 | char *p = bb_xasprintf("%s/..", arg); |
50 | bb_xasprintf(&p, "%s/..", arg); | 50 | |
51 | if (stat(p, &st) == 0) { | 51 | if (stat(p, &st) == 0) { |
52 | short ret = (st_dev != st.st_dev) || | 52 | short ret = (st_dev != st.st_dev) || |
53 | (st_dev == st.st_dev && st_ino == st.st_ino); | 53 | (st_dev == st.st_dev && st_ino == st.st_ino); |
diff --git a/modutils/insmod.c b/modutils/insmod.c index 232a6e691..94e66f48c 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -3756,10 +3756,10 @@ extern int insmod_main( int argc, char **argv) | |||
3756 | 3756 | ||
3757 | #if defined(CONFIG_FEATURE_2_6_MODULES) | 3757 | #if defined(CONFIG_FEATURE_2_6_MODULES) |
3758 | if (k_version > 4) | 3758 | if (k_version > 4) |
3759 | bb_xasprintf(&m_fullName, "%s.ko", tmp); | 3759 | m_fullName = bb_xasprintf("%s.ko", tmp); |
3760 | else | 3760 | else |
3761 | #endif | 3761 | #endif |
3762 | bb_xasprintf(&m_fullName, "%s.o", tmp); | 3762 | m_fullName = bb_xasprintf("%s.o", tmp); |
3763 | 3763 | ||
3764 | if (!m_name) { | 3764 | if (!m_name) { |
3765 | m_name = tmp; | 3765 | m_name = tmp; |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index c73529463..d23c9f70a 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1010,7 +1010,7 @@ static int execute_all(struct interface_defn_t *ifd, execfn *exec, const char *o | |||
1010 | } | 1010 | } |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | bb_xasprintf(&buf, "run-parts /etc/network/if-%s.d", opt); | 1013 | buf = bb_xasprintf("run-parts /etc/network/if-%s.d", opt); |
1014 | if ((*exec)(buf) != 1) { | 1014 | if ((*exec)(buf) != 1) { |
1015 | return 0; | 1015 | return 0; |
1016 | } | 1016 | } |
diff --git a/procps/sysctl.c b/procps/sysctl.c index 359dcc041..dbb82e69c 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c | |||
@@ -209,7 +209,7 @@ int sysctl_write_setting(const char *setting, int output) | |||
209 | return -2; | 209 | return -2; |
210 | } | 210 | } |
211 | 211 | ||
212 | bb_xasprintf(&tmpname, "%s%.*s", PROC_PATH, (equals - name), name); | 212 | tmpname = bb_xasprintf("%s%.*s", PROC_PATH, (equals - name), name); |
213 | outname = bb_xstrdup(tmpname + strlen(PROC_PATH)); | 213 | outname = bb_xstrdup(tmpname + strlen(PROC_PATH)); |
214 | 214 | ||
215 | while ((cptr = strchr(tmpname, '.')) != NULL) | 215 | while ((cptr = strchr(tmpname, '.')) != NULL) |
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index c4cb9d9c4..edfa01613 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -621,7 +621,7 @@ static char **username_tab_completion(char *ud, int *num_matches) | |||
621 | /* Null usernames should result in all users as possible completions. */ | 621 | /* Null usernames should result in all users as possible completions. */ |
622 | if ( /*!userlen || */ !strncmp(ud, entry->pw_name, userlen)) { | 622 | if ( /*!userlen || */ !strncmp(ud, entry->pw_name, userlen)) { |
623 | 623 | ||
624 | bb_xasprintf(&temp, "~%s/", entry->pw_name); | 624 | temp = bb_xasprintf("~%s/", entry->pw_name); |
625 | matches = xrealloc(matches, (nm + 1) * sizeof(char *)); | 625 | matches = xrealloc(matches, (nm + 1) * sizeof(char *)); |
626 | 626 | ||
627 | matches[nm++] = temp; | 627 | matches[nm++] = temp; |