[git commit] libbb: code shrink bb_parse_mode
Denys Vlasenko
vda.linux at googlemail.com
Thu Sep 16 22:47:23 UTC 2021
commit: https://git.busybox.net/busybox/commit/?id=4958c18134eb7ad169cdaf22a9ad957ad4f4858c
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
bb_parse_mode 393 398 +5
static.who_mask 16 8 -8
static.perm_mask 24 12 -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 5/-20) Total: -15 bytes
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
include/libbb.h | 2 +-
libbb/parse_mode.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/libbb.h b/include/libbb.h
index 1ec8d2d3b..6727c22b2 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1607,7 +1607,7 @@ char *bb_ask_noecho_stdin(const char *prompt) FAST_FUNC;
int bb_ask_y_confirmation_FILE(FILE *fp) FAST_FUNC;
int bb_ask_y_confirmation(void) FAST_FUNC;
-/* Returns -1 if input is invalid. current_mode is a base for e.g. "u+rw" */
+/* Returns -1 if input is invalid. cur_mode is a base for e.g. "u+rw" */
int bb_parse_mode(const char* s, unsigned cur_mode) FAST_FUNC;
/*
diff --git a/libbb/parse_mode.c b/libbb/parse_mode.c
index dc65860f6..1d238e1e0 100644
--- a/libbb/parse_mode.c
+++ b/libbb/parse_mode.c
@@ -16,13 +16,14 @@
int FAST_FUNC bb_parse_mode(const char *s, unsigned current_mode)
{
- static const mode_t who_mask[] = {
+/* should be mode_t really, but in all Unixes these constants fit into uint16 */
+ static const uint16_t who_mask[] ALIGN2 = {
S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO, /* a */
S_ISUID | S_IRWXU, /* u */
S_ISGID | S_IRWXG, /* g */
S_IRWXO /* o */
};
- static const mode_t perm_mask[] = {
+ static const uint16_t perm_mask[] ALIGN2 = {
S_IRUSR | S_IRGRP | S_IROTH, /* r */
S_IWUSR | S_IWGRP | S_IWOTH, /* w */
S_IXUSR | S_IXGRP | S_IXOTH, /* x */
More information about the busybox-cvs
mailing list