libbb: eliminate a static data array in bb_mode_string()
function old new delta print_stat 861 869 +8 header_verbose_list_ar 73 77 +4 display_single 975 979 +4 header_verbose_list 237 239 +2 bb_mode_string 124 115 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 18/-9) Total: 9 bytes text data bss dec hex filename 1043136 559 5052 1048747 1000ab busybox_old 1043153 559 5020 1048732 10009c busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4958c18134
commit
59ac467dc6
@ -196,9 +196,10 @@ static int write_ar_archive(archive_handle_t *handle)
|
|||||||
|
|
||||||
static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header)
|
static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header)
|
||||||
{
|
{
|
||||||
const char *mode = bb_mode_string(file_header->mode);
|
char mode[12];
|
||||||
char *mtime;
|
char *mtime;
|
||||||
|
|
||||||
|
bb_mode_string(mode, file_header->mode);
|
||||||
mtime = ctime(&file_header->mtime);
|
mtime = ctime(&file_header->mtime);
|
||||||
mtime[16] = ' ';
|
mtime[16] = ' ';
|
||||||
memmove(&mtime[17], &mtime[20], 4);
|
memmove(&mtime[17], &mtime[20], 4);
|
||||||
|
@ -9,6 +9,7 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
|
|||||||
{
|
{
|
||||||
struct tm tm_time;
|
struct tm tm_time;
|
||||||
struct tm *ptm = &tm_time; //localtime(&file_header->mtime);
|
struct tm *ptm = &tm_time; //localtime(&file_header->mtime);
|
||||||
|
char modestr[12];
|
||||||
|
|
||||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||||
char uid[sizeof(int)*3 + 2];
|
char uid[sizeof(int)*3 + 2];
|
||||||
@ -29,7 +30,7 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
|
|||||||
group = utoa(file_header->gid);
|
group = utoa(file_header->gid);
|
||||||
}
|
}
|
||||||
printf("%s %s/%s %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
|
printf("%s %s/%s %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||||
bb_mode_string(file_header->mode),
|
bb_mode_string(modestr, file_header->mode),
|
||||||
user,
|
user,
|
||||||
group,
|
group,
|
||||||
file_header->size,
|
file_header->size,
|
||||||
@ -46,7 +47,7 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
|
|||||||
localtime_r(&file_header->mtime, ptm);
|
localtime_r(&file_header->mtime, ptm);
|
||||||
|
|
||||||
printf("%s %u/%u %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
|
printf("%s %u/%u %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||||
bb_mode_string(file_header->mode),
|
bb_mode_string(modestr, file_header->mode),
|
||||||
(unsigned)file_header->uid,
|
(unsigned)file_header->uid,
|
||||||
(unsigned)file_header->gid,
|
(unsigned)file_header->gid,
|
||||||
file_header->size,
|
file_header->size,
|
||||||
|
@ -91,8 +91,9 @@ static int FAST_FUNC fileAction(struct recursive_state *state,
|
|||||||
|| (OPT_CHANGED
|
|| (OPT_CHANGED
|
||||||
&& (statbuf->st_mode & 07777) != (newmode & 07777))
|
&& (statbuf->st_mode & 07777) != (newmode & 07777))
|
||||||
) {
|
) {
|
||||||
|
char modestr[12];
|
||||||
printf("mode of '%s' changed to %04o (%s)\n", fileName,
|
printf("mode of '%s' changed to %04o (%s)\n", fileName,
|
||||||
newmode & 07777, bb_mode_string(newmode)+1);
|
newmode & 07777, bb_mode_string(modestr, newmode)+1);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -503,7 +503,8 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
|
|||||||
column += printf("%6"OFF_FMT"u ", (off_t) (dn->dn_blocks >> 1));
|
column += printf("%6"OFF_FMT"u ", (off_t) (dn->dn_blocks >> 1));
|
||||||
if (opt & OPT_l) {
|
if (opt & OPT_l) {
|
||||||
/* long listing: show mode */
|
/* long listing: show mode */
|
||||||
column += printf("%-10s ", (char *) bb_mode_string(dn->dn_mode));
|
char modestr[12];
|
||||||
|
column += printf("%-10s ", (char *) bb_mode_string(modestr, dn->dn_mode));
|
||||||
/* long listing: show number of links */
|
/* long listing: show number of links */
|
||||||
column += printf("%4lu ", (long) dn->dn_nlink);
|
column += printf("%4lu ", (long) dn->dn_nlink);
|
||||||
/* long listing: show user/group */
|
/* long listing: show user/group */
|
||||||
|
@ -339,7 +339,8 @@ static void FAST_FUNC print_stat(char *pformat, const char m,
|
|||||||
strcat(pformat, "lo");
|
strcat(pformat, "lo");
|
||||||
printf(pformat, (unsigned long) (statbuf->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)));
|
printf(pformat, (unsigned long) (statbuf->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)));
|
||||||
} else if (m == 'A') {
|
} else if (m == 'A') {
|
||||||
printfs(pformat, bb_mode_string(statbuf->st_mode));
|
char modestr[12];
|
||||||
|
printfs(pformat, bb_mode_string(modestr, statbuf->st_mode));
|
||||||
} else if (m == 'f') {
|
} else if (m == 'f') {
|
||||||
strcat(pformat, "lx");
|
strcat(pformat, "lx");
|
||||||
printf(pformat, (unsigned long) statbuf->st_mode);
|
printf(pformat, (unsigned long) statbuf->st_mode);
|
||||||
@ -702,6 +703,7 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
# endif
|
# endif
|
||||||
} else {
|
} else {
|
||||||
|
char modestr[12];
|
||||||
char *linkname = NULL;
|
char *linkname = NULL;
|
||||||
struct passwd *pw_ent;
|
struct passwd *pw_ent;
|
||||||
struct group *gw_ent;
|
struct group *gw_ent;
|
||||||
@ -736,7 +738,7 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
printf("Access: (%04lo/%10.10s) Uid: (%5lu/%8s) Gid: (%5lu/%8s)\n",
|
printf("Access: (%04lo/%10.10s) Uid: (%5lu/%8s) Gid: (%5lu/%8s)\n",
|
||||||
(unsigned long) (statbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)),
|
(unsigned long) (statbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)),
|
||||||
bb_mode_string(statbuf.st_mode),
|
bb_mode_string(modestr, statbuf.st_mode),
|
||||||
(unsigned long) statbuf.st_uid,
|
(unsigned long) statbuf.st_uid,
|
||||||
(pw_ent != NULL) ? pw_ent->pw_name : "UNKNOWN",
|
(pw_ent != NULL) ? pw_ent->pw_name : "UNKNOWN",
|
||||||
(unsigned long) statbuf.st_gid,
|
(unsigned long) statbuf.st_gid,
|
||||||
|
@ -442,7 +442,7 @@ void *xmmap_anon(size_t size) FAST_FUNC;
|
|||||||
|
|
||||||
|
|
||||||
//TODO: supply a pointer to char[11] buffer (avoid statics)?
|
//TODO: supply a pointer to char[11] buffer (avoid statics)?
|
||||||
extern const char *bb_mode_string(mode_t mode) FAST_FUNC;
|
extern char *bb_mode_string(char buf[12], mode_t mode) FAST_FUNC;
|
||||||
extern int is_directory(const char *name, int followLinks) FAST_FUNC;
|
extern int is_directory(const char *name, int followLinks) FAST_FUNC;
|
||||||
enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing them! */
|
enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing them! */
|
||||||
FILEUTILS_PRESERVE_STATUS = 1 << 0, /* -p */
|
FILEUTILS_PRESERVE_STATUS = 1 << 0, /* -p */
|
||||||
|
@ -43,9 +43,8 @@ static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???";
|
|||||||
/***************************************** 0123456789abcdef */
|
/***************************************** 0123456789abcdef */
|
||||||
static const char mode_chars[7] ALIGN1 = "rwxSTst";
|
static const char mode_chars[7] ALIGN1 = "rwxSTst";
|
||||||
|
|
||||||
const char* FAST_FUNC bb_mode_string(mode_t mode)
|
char* FAST_FUNC bb_mode_string(char buf[12], mode_t mode)
|
||||||
{
|
{
|
||||||
static char buf[12];
|
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
|
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
@ -83,9 +82,8 @@ static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???";
|
|||||||
/********************************** 0123456789abcdef */
|
/********************************** 0123456789abcdef */
|
||||||
static const char mode_chars[7] ALIGN1 = "rwxSTst";
|
static const char mode_chars[7] ALIGN1 = "rwxSTst";
|
||||||
|
|
||||||
const char* FAST_FUNC bb_mode_string(mode_t mode)
|
char* FAST_FUNC bb_mode_string(char buf[12], mode_t mode)
|
||||||
{
|
{
|
||||||
static char buf[12];
|
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
|
|
||||||
int i, j, k, m;
|
int i, j, k, m;
|
||||||
|
Loading…
Reference in New Issue
Block a user