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
This commit is contained in:
parent
6a60c821a8
commit
39a841cecf
@ -695,12 +695,8 @@ int tar_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Prepend '-' to the first argument if required */
|
/* Prepend '-' to the first argument if required */
|
||||||
if (argv[1][0] != '-') {
|
if (argv[1][0] != '-')
|
||||||
char *tmp;
|
argv[1] = bb_xasprintf("-%s", argv[1]);
|
||||||
|
|
||||||
bb_xasprintf(&tmp, "-%s", argv[1]);
|
|
||||||
argv[1] = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialise default values */
|
/* Initialise default values */
|
||||||
tar_handle = init_handle();
|
tar_handle = init_handle();
|
||||||
|
@ -147,7 +147,7 @@ static int null (VALUE *v)
|
|||||||
static void tostring (VALUE *v)
|
static void tostring (VALUE *v)
|
||||||
{
|
{
|
||||||
if (v->type == integer) {
|
if (v->type == integer) {
|
||||||
bb_xasprintf (&(v->u.s), "%d", v->u.i);
|
v->u.s = bb_xasprintf ("%d", v->u.i);
|
||||||
v->type = string;
|
v->type = string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,17 +74,17 @@ extern int ln_main(int argc, char **argv)
|
|||||||
src_name = src;
|
src_name = src;
|
||||||
}
|
}
|
||||||
if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) {
|
if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) {
|
||||||
bb_perror_msg(*argv);
|
bb_perror_msg("%s", *argv);
|
||||||
status = EXIT_FAILURE;
|
status = EXIT_FAILURE;
|
||||||
free(src_name);
|
free(src_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag & LN_BACKUP) {
|
if (flag & LN_BACKUP) {
|
||||||
char *backup = NULL;
|
char *backup;
|
||||||
bb_xasprintf(&backup, "%s%s", src, suffix);
|
backup = bb_xasprintf("%s%s", src, suffix);
|
||||||
if (rename(src, backup) < 0 && errno != ENOENT) {
|
if (rename(src, backup) < 0 && errno != ENOENT) {
|
||||||
bb_perror_msg(src);
|
bb_perror_msg("%s", src);
|
||||||
status = EXIT_FAILURE;
|
status = EXIT_FAILURE;
|
||||||
free(backup);
|
free(backup);
|
||||||
continue;
|
continue;
|
||||||
|
@ -363,7 +363,6 @@ static char *find_fsck(char *type)
|
|||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
const char *tpl;
|
const char *tpl;
|
||||||
char *prog;
|
|
||||||
char *p = string_copy(fsck_path);
|
char *p = string_copy(fsck_path);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -371,12 +370,12 @@ static char *find_fsck(char *type)
|
|||||||
tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
|
tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
|
||||||
|
|
||||||
for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
|
for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
|
||||||
bb_xasprintf(&prog, tpl, s, type);
|
s = bb_xasprintf(tpl, s, type);
|
||||||
if (stat(prog, &st) == 0) break;
|
if (stat(s, &st) == 0) break;
|
||||||
free(prog);
|
free(s);
|
||||||
}
|
}
|
||||||
free(p);
|
free(p);
|
||||||
return(s ? prog : NULL);
|
return(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int progress_active(void)
|
static int progress_active(void)
|
||||||
@ -410,7 +409,7 @@ static int execute(const char *type, const char *device, const char *mntpt,
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
memset(inst, 0, sizeof(struct fsck_instance));
|
memset(inst, 0, sizeof(struct fsck_instance));
|
||||||
|
|
||||||
bb_xasprintf(&prog, "fsck.%s", type);
|
prog = bb_xasprintf("fsck.%s", type);
|
||||||
argv[0] = prog;
|
argv[0] = prog;
|
||||||
argc = 1;
|
argc = 1;
|
||||||
|
|
||||||
@ -1189,7 +1188,7 @@ int fsck_main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Update our search path to include uncommon directories. */
|
/* Update our search path to include uncommon directories. */
|
||||||
if (oldpath) {
|
if (oldpath) {
|
||||||
bb_xasprintf(&fsck_path, "%s:%s", fsck_prefix_path, oldpath);
|
fsck_path = bb_xasprintf("%s:%s", fsck_prefix_path, oldpath);
|
||||||
} else {
|
} else {
|
||||||
fsck_path = string_copy(fsck_prefix_path);
|
fsck_path = string_copy(fsck_prefix_path);
|
||||||
}
|
}
|
||||||
|
@ -794,10 +794,7 @@ static int PRS(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Update our PATH to include /sbin */
|
/* Update our PATH to include /sbin */
|
||||||
if (oldpath) {
|
if (oldpath) {
|
||||||
char *newpath;
|
putenv (bb_xasprintf("%s:%s", PATH_SET, oldpath));
|
||||||
|
|
||||||
bb_xasprintf(&newpath, "%s:%s", PATH_SET, oldpath);
|
|
||||||
putenv(newpath);
|
|
||||||
} else
|
} else
|
||||||
putenv (PATH_SET);
|
putenv (PATH_SET);
|
||||||
|
|
||||||
|
@ -408,8 +408,7 @@ void reset_ino_dev_hashtable(void);
|
|||||||
extern size_t bb_strlen(const char *string);
|
extern size_t bb_strlen(const char *string);
|
||||||
#define strlen(x) bb_strlen(x)
|
#define strlen(x) bb_strlen(x)
|
||||||
|
|
||||||
void bb_xasprintf(char **string_ptr, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
char *bb_xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
|
|
||||||
#define FAIL_DELAY 3
|
#define FAIL_DELAY 3
|
||||||
extern void change_identity ( const struct passwd *pw );
|
extern void change_identity ( const struct passwd *pw );
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2002 Vladimir Oleynik <dzo@simtreas.ru>
|
Copyright (C) 2002,2005 Vladimir Oleynik <dzo@simtreas.ru>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -7,16 +7,18 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
void bb_xasprintf(char **string_ptr, const char *format, ...)
|
char *bb_xasprintf(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list p;
|
va_list p;
|
||||||
int r;
|
int r;
|
||||||
|
char *string_ptr;
|
||||||
|
|
||||||
va_start(p, format);
|
va_start(p, format);
|
||||||
r = vasprintf(string_ptr, format, p);
|
r = vasprintf(&string_ptr, format, p);
|
||||||
va_end(p);
|
va_end(p);
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
bb_perror_msg_and_die("bb_xasprintf");
|
bb_perror_msg_and_die("bb_xasprintf");
|
||||||
}
|
}
|
||||||
|
return string_ptr;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
extern char *concat_path_file(const char *path, const char *filename)
|
extern char *concat_path_file(const char *path, const char *filename)
|
||||||
{
|
{
|
||||||
char *outbuf;
|
|
||||||
char *lc;
|
char *lc;
|
||||||
|
|
||||||
if (!path)
|
if (!path)
|
||||||
@ -38,7 +37,5 @@ extern char *concat_path_file(const char *path, const char *filename)
|
|||||||
lc = last_char_is(path, '/');
|
lc = last_char_is(path, '/');
|
||||||
while (*filename == '/')
|
while (*filename == '/')
|
||||||
filename++;
|
filename++;
|
||||||
bb_xasprintf(&outbuf, "%s%s%s", path, (lc==NULL ? "/" : ""), filename);
|
return bb_xasprintf("%s%s%s", path, (lc==NULL ? "/" : ""), filename);
|
||||||
|
|
||||||
return outbuf;
|
|
||||||
}
|
}
|
||||||
|
@ -84,11 +84,8 @@ void run_shell ( const char *shell, int loginshell, const char *command, const c
|
|||||||
|
|
||||||
args [0] = bb_get_last_path_component ( bb_xstrdup ( shell ));
|
args [0] = bb_get_last_path_component ( bb_xstrdup ( shell ));
|
||||||
|
|
||||||
if ( loginshell ) {
|
if ( loginshell )
|
||||||
char *args0;
|
args [0] = bb_xasprintf ("-%s", args [0]);
|
||||||
bb_xasprintf ( &args0, "-%s", args [0] );
|
|
||||||
args [0] = args0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( command ) {
|
if ( command ) {
|
||||||
args [argno++] = "-c";
|
args [argno++] = "-c";
|
||||||
|
@ -117,7 +117,7 @@ static void addgroup_wrapper(const char *login, gid_t gid)
|
|||||||
{
|
{
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
|
||||||
bb_xasprintf(&cmd, "addgroup -g %d %s", gid, login);
|
cmd = bb_xasprintf("addgroup -g %d %s", gid, login);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ static void add_linenumbers(void) {
|
|||||||
|
|
||||||
for (i = 0; i <= num_flines; i++) {
|
for (i = 0; i <= num_flines; i++) {
|
||||||
safe_strncpy(current_line, flines[i], 256);
|
safe_strncpy(current_line, flines[i], 256);
|
||||||
bb_xasprintf(&flines[i],"%5d %s", i + 1, current_line);
|
flines[i] = bb_xasprintf("%5d %s", i + 1, current_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,11 +618,8 @@ static void colon_process(void) {
|
|||||||
|
|
||||||
static char *insert_highlights (char *line, int start, int end) {
|
static char *insert_highlights (char *line, int start, int end) {
|
||||||
|
|
||||||
char *new_line;
|
return bb_xasprintf("%.*s%s%.*s%s%s", start, line, HIGHLIGHT,
|
||||||
|
|
||||||
bb_xasprintf(&new_line, "%.*s%s%.*s%s%s", start, line, HIGHLIGHT,
|
|
||||||
end - start, line + start, NORMAL, line + end);
|
end - start, line + start, NORMAL, line + end);
|
||||||
return new_line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *process_regex_on_line(char *line, regex_t *pattern) {
|
static char *process_regex_on_line(char *line, regex_t *pattern) {
|
||||||
|
@ -46,8 +46,8 @@ int mountpoint_main(int argc, char **argv)
|
|||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
dev_t st_dev = st.st_dev;
|
dev_t st_dev = st.st_dev;
|
||||||
ino_t st_ino = st.st_ino;
|
ino_t st_ino = st.st_ino;
|
||||||
char *p;
|
char *p = bb_xasprintf("%s/..", arg);
|
||||||
bb_xasprintf(&p, "%s/..", arg);
|
|
||||||
if (stat(p, &st) == 0) {
|
if (stat(p, &st) == 0) {
|
||||||
short ret = (st_dev != st.st_dev) ||
|
short ret = (st_dev != st.st_dev) ||
|
||||||
(st_dev == st.st_dev && st_ino == st.st_ino);
|
(st_dev == st.st_dev && st_ino == st.st_ino);
|
||||||
|
@ -3756,10 +3756,10 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
|
|
||||||
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
if (k_version > 4)
|
if (k_version > 4)
|
||||||
bb_xasprintf(&m_fullName, "%s.ko", tmp);
|
m_fullName = bb_xasprintf("%s.ko", tmp);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
bb_xasprintf(&m_fullName, "%s.o", tmp);
|
m_fullName = bb_xasprintf("%s.o", tmp);
|
||||||
|
|
||||||
if (!m_name) {
|
if (!m_name) {
|
||||||
m_name = tmp;
|
m_name = tmp;
|
||||||
|
@ -1010,7 +1010,7 @@ static int execute_all(struct interface_defn_t *ifd, execfn *exec, const char *o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_xasprintf(&buf, "run-parts /etc/network/if-%s.d", opt);
|
buf = bb_xasprintf("run-parts /etc/network/if-%s.d", opt);
|
||||||
if ((*exec)(buf) != 1) {
|
if ((*exec)(buf) != 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ int sysctl_write_setting(const char *setting, int output)
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_xasprintf(&tmpname, "%s%.*s", PROC_PATH, (equals - name), name);
|
tmpname = bb_xasprintf("%s%.*s", PROC_PATH, (equals - name), name);
|
||||||
outname = bb_xstrdup(tmpname + strlen(PROC_PATH));
|
outname = bb_xstrdup(tmpname + strlen(PROC_PATH));
|
||||||
|
|
||||||
while ((cptr = strchr(tmpname, '.')) != NULL)
|
while ((cptr = strchr(tmpname, '.')) != NULL)
|
||||||
|
@ -621,7 +621,7 @@ static char **username_tab_completion(char *ud, int *num_matches)
|
|||||||
/* Null usernames should result in all users as possible completions. */
|
/* Null usernames should result in all users as possible completions. */
|
||||||
if ( /*!userlen || */ !strncmp(ud, entry->pw_name, userlen)) {
|
if ( /*!userlen || */ !strncmp(ud, entry->pw_name, userlen)) {
|
||||||
|
|
||||||
bb_xasprintf(&temp, "~%s/", entry->pw_name);
|
temp = bb_xasprintf("~%s/", entry->pw_name);
|
||||||
matches = xrealloc(matches, (nm + 1) * sizeof(char *));
|
matches = xrealloc(matches, (nm + 1) * sizeof(char *));
|
||||||
|
|
||||||
matches[nm++] = temp;
|
matches[nm++] = temp;
|
||||||
|
Loading…
Reference in New Issue
Block a user