← Commit list

4958c1813

Denys Vlasenko
Denys Vlasenko
2021-09-17
SUCCESS Duration: 152s

Subject

libbb: code shrink bb_parse_mode

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

include/libbb.h+1 -1
@@ -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;
/*
libbb/parse_mode.c+3 -2
@@ -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 */