aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-09-17 01:13:58 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-09-17 01:18:31 +0200
commit59ac467dc6429a48522ef7fbe40fcd819563e49a (patch)
tree4b6af971b0ffc516294ff35ba7b5c1e99c6eadae /coreutils
parent4958c18134eb7ad169cdaf22a9ad957ad4f4858c (diff)
downloadbusybox-w32-59ac467dc6429a48522ef7fbe40fcd819563e49a.tar.gz
busybox-w32-59ac467dc6429a48522ef7fbe40fcd819563e49a.tar.bz2
busybox-w32-59ac467dc6429a48522ef7fbe40fcd819563e49a.zip
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>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/chmod.c3
-rw-r--r--coreutils/ls.c3
-rw-r--r--coreutils/stat.c6
3 files changed, 8 insertions, 4 deletions
diff --git a/coreutils/chmod.c b/coreutils/chmod.c
index 8e3e1387e..5832cc51b 100644
--- a/coreutils/chmod.c
+++ b/coreutils/chmod.c
@@ -91,8 +91,9 @@ static int FAST_FUNC fileAction(struct recursive_state *state,
91 || (OPT_CHANGED 91 || (OPT_CHANGED
92 && (statbuf->st_mode & 07777) != (newmode & 07777)) 92 && (statbuf->st_mode & 07777) != (newmode & 07777))
93 ) { 93 ) {
94 char modestr[12];
94 printf("mode of '%s' changed to %04o (%s)\n", fileName, 95 printf("mode of '%s' changed to %04o (%s)\n", fileName,
95 newmode & 07777, bb_mode_string(newmode)+1); 96 newmode & 07777, bb_mode_string(modestr, newmode)+1);
96 } 97 }
97 return TRUE; 98 return TRUE;
98 } 99 }
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 9e8561606..9a1264e65 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -503,7 +503,8 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
503 column += printf("%6"OFF_FMT"u ", (off_t) (dn->dn_blocks >> 1)); 503 column += printf("%6"OFF_FMT"u ", (off_t) (dn->dn_blocks >> 1));
504 if (opt & OPT_l) { 504 if (opt & OPT_l) {
505 /* long listing: show mode */ 505 /* long listing: show mode */
506 column += printf("%-10s ", (char *) bb_mode_string(dn->dn_mode)); 506 char modestr[12];
507 column += printf("%-10s ", (char *) bb_mode_string(modestr, dn->dn_mode));
507 /* long listing: show number of links */ 508 /* long listing: show number of links */
508 column += printf("%4lu ", (long) dn->dn_nlink); 509 column += printf("%4lu ", (long) dn->dn_nlink);
509 /* long listing: show user/group */ 510 /* long listing: show user/group */
diff --git a/coreutils/stat.c b/coreutils/stat.c
index a8393468e..2c2909e7e 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -339,7 +339,8 @@ static void FAST_FUNC print_stat(char *pformat, const char m,
339 strcat(pformat, "lo"); 339 strcat(pformat, "lo");
340 printf(pformat, (unsigned long) (statbuf->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO))); 340 printf(pformat, (unsigned long) (statbuf->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)));
341 } else if (m == 'A') { 341 } else if (m == 'A') {
342 printfs(pformat, bb_mode_string(statbuf->st_mode)); 342 char modestr[12];
343 printfs(pformat, bb_mode_string(modestr, statbuf->st_mode));
343 } else if (m == 'f') { 344 } else if (m == 'f') {
344 strcat(pformat, "lx"); 345 strcat(pformat, "lx");
345 printf(pformat, (unsigned long) statbuf->st_mode); 346 printf(pformat, (unsigned long) statbuf->st_mode);
@@ -702,6 +703,7 @@ static bool do_stat(const char *filename, const char *format)
702 bb_putchar('\n'); 703 bb_putchar('\n');
703# endif 704# endif
704 } else { 705 } else {
706 char modestr[12];
705 char *linkname = NULL; 707 char *linkname = NULL;
706 struct passwd *pw_ent; 708 struct passwd *pw_ent;
707 struct group *gw_ent; 709 struct group *gw_ent;
@@ -736,7 +738,7 @@ static bool do_stat(const char *filename, const char *format)
736 bb_putchar('\n'); 738 bb_putchar('\n');
737 printf("Access: (%04lo/%10.10s) Uid: (%5lu/%8s) Gid: (%5lu/%8s)\n", 739 printf("Access: (%04lo/%10.10s) Uid: (%5lu/%8s) Gid: (%5lu/%8s)\n",
738 (unsigned long) (statbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)), 740 (unsigned long) (statbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)),
739 bb_mode_string(statbuf.st_mode), 741 bb_mode_string(modestr, statbuf.st_mode),
740 (unsigned long) statbuf.st_uid, 742 (unsigned long) statbuf.st_uid,
741 (pw_ent != NULL) ? pw_ent->pw_name : "UNKNOWN", 743 (pw_ent != NULL) ? pw_ent->pw_name : "UNKNOWN",
742 (unsigned long) statbuf.st_gid, 744 (unsigned long) statbuf.st_gid,