diff options
author | Denys Vlasenko | 2021-06-24 09:31:57 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-06-24 09:31:57 +0200 |
commit | 87c40cf4de435d1b19b7fb545a495542c6eaf820 (patch) | |
tree | 3eaaec39b88cff99d5beee4caac961d7b2b4c7f7 /e2fsprogs | |
parent | 9468ea06d2445f774dd923fdfdea04209984fbf4 (diff) | |
download | busybox-87c40cf4de435d1b19b7fb545a495542c6eaf820.zip busybox-87c40cf4de435d1b19b7fb545a495542c6eaf820.tar.gz |
e2fsprogs: code shrink
function old new delta
print_e2flags_long - 109 +109
list_attributes 248 232 -16
print_e2flags 169 47 -122
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 109/-138) Total: -29 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'e2fsprogs')
-rw-r--r-- | e2fsprogs/e2fs_lib.c | 59 | ||||
-rw-r--r-- | e2fsprogs/e2fs_lib.h | 5 | ||||
-rw-r--r-- | e2fsprogs/lsattr.c | 4 |
3 files changed, 36 insertions, 32 deletions
diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c index 0ec4eb2..e32336a 100644 --- a/e2fsprogs/e2fs_lib.c +++ b/e2fsprogs/e2fs_lib.c @@ -98,36 +98,41 @@ static const char e2attr_flags_lname[] ALIGN1 = "Verity" "\0" /* Another trailing NUL is added by compiler */; -void print_e2flags(FILE *f, unsigned flags, unsigned options) +void print_e2flags_long(unsigned flags) { const uint32_t *fv; const char *fn; + int first = 1; fv = e2attr_flags_value; - if (options & PFOPT_LONG) { - int first = 1; - fn = e2attr_flags_lname; - do { - if (flags & *fv) { - if (!first) - fputs(", ", f); - fputs(fn, f); - first = 0; - } - fv++; - fn += strlen(fn) + 1; - } while (*fn); - if (first) - fputs("---", f); - } else { - fn = e2attr_flags_sname; - do { - char c = '-'; - if (flags & *fv) - c = *fn; - fputc(c, f); - fv++; - fn++; - } while (*fn); - } + fn = e2attr_flags_lname; + do { + if (flags & *fv) { + if (!first) + fputs(", ", stdout); + fputs(fn, stdout); + first = 0; + } + fv++; + fn += strlen(fn) + 1; + } while (*fn); + if (first) + fputs("---", stdout); +} + +void print_e2flags(unsigned flags) +{ + const uint32_t *fv; + const char *fn; + + fv = e2attr_flags_value; + fn = e2attr_flags_sname; + do { + char c = '-'; + if (flags & *fv) + c = *fn; + putchar(c); + fv++; + fn++; + } while (*fn); } diff --git a/e2fsprogs/e2fs_lib.h b/e2fsprogs/e2fs_lib.h index 1a5d092..879272f 100644 --- a/e2fsprogs/e2fs_lib.h +++ b/e2fsprogs/e2fs_lib.h @@ -16,10 +16,9 @@ int iterate_on_dir(const char *dir_name, int FAST_FUNC (*func)(const char *, struct dirent *, void *), void *private); -/* Must be 1 for compatibility with 'int long_format'. */ -#define PFOPT_LONG 1 /* Print file attributes on an ext2 file system */ -void print_e2flags(FILE *f, unsigned flags, unsigned options); +void print_e2flags_long(unsigned flags); +void print_e2flags(unsigned flags); extern const uint32_t e2attr_flags_value[]; extern const char e2attr_flags_sname[]; diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c index 545afa7..c9f353c 100644 --- a/e2fsprogs/lsattr.c +++ b/e2fsprogs/lsattr.c @@ -83,10 +83,10 @@ static void list_attributes(const char *name) if (option_mask32 & OPT_PF_LONG) { printf("%-28s ", name); - print_e2flags(stdout, fsflags, PFOPT_LONG); + print_e2flags_long(fsflags); bb_putchar('\n'); } else { - print_e2flags(stdout, fsflags, 0); + print_e2flags(fsflags); printf(" %s\n", name); } |