From 8ed3fb11d6a5198537bd6cc2f145051635441101 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 7 Jun 2018 16:03:43 +0200 Subject: [PATCH] tree-wide: unify how we define bit mak enums Let's always write "1 << 0", "1 << 1" and so on, except where we need more than 31 flag bits, where we write "UINT64(1) << 0", and so on to force 64bit values. --- src/basic/conf-files.h | 10 +++++----- src/basic/copy.h | 8 ++++---- src/basic/fileio.h | 12 ++++++------ src/basic/fs-util.h | 14 +++++++------- src/basic/label.h | 4 ++-- src/basic/process-util.h | 22 +++++++++++----------- src/basic/terminal-util.h | 10 +++++----- src/core/mount-setup.c | 8 ++++---- src/libelogind/sd-bus/bus-objects.c | 4 ++-- src/shared/bus-util.h | 4 ++-- src/shared/conf-parser.h | 8 ++++---- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/basic/conf-files.h b/src/basic/conf-files.h index 78d03e6e0..a3adc0828 100644 --- a/src/basic/conf-files.h +++ b/src/basic/conf-files.h @@ -9,11 +9,11 @@ ***/ enum { - CONF_FILES_EXECUTABLE = 1U << 0, - CONF_FILES_REGULAR = 1U << 1, - CONF_FILES_DIRECTORY = 1U << 2, - CONF_FILES_BASENAME = 1U << 3, - CONF_FILES_FILTER_MASKED = 1U << 4, + CONF_FILES_EXECUTABLE = 1 << 0, + CONF_FILES_REGULAR = 1 << 1, + CONF_FILES_DIRECTORY = 1 << 2, + CONF_FILES_BASENAME = 1 << 3, + CONF_FILES_FILTER_MASKED = 1 << 4, }; int conf_files_list(char ***ret, const char *suffix, const char *root, unsigned flags, const char *dir, ...); diff --git a/src/basic/copy.h b/src/basic/copy.h index 7c1d86fe3..d54010560 100644 --- a/src/basic/copy.h +++ b/src/basic/copy.h @@ -13,10 +13,10 @@ #include typedef enum CopyFlags { - COPY_REFLINK = 1U << 0, /* Try to reflink */ - COPY_MERGE = 1U << 1, /* Merge existing trees with our new one to copy */ - COPY_REPLACE = 1U << 2, /* Replace an existing file if there's one */ - COPY_SAME_MOUNT = 1U << 3, /* Don't descend recursively into other file systems, across mount point boundaries */ + COPY_REFLINK = 1 << 0, /* Try to reflink */ + COPY_MERGE = 1 << 1, /* Merge existing trees with our new one to copy */ + COPY_REPLACE = 1 << 2, /* Replace an existing file if there's one */ + COPY_SAME_MOUNT = 1 << 3, /* Don't descend recursively into other file systems, across mount point boundaries */ } CopyFlags; #if 0 /// UNNEEDED by elogind diff --git a/src/basic/fileio.h b/src/basic/fileio.h index 7a413d626..0a23c9fae 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -17,12 +17,12 @@ #include "time-util.h" typedef enum { - WRITE_STRING_FILE_CREATE = 1<<0, - WRITE_STRING_FILE_ATOMIC = 1<<1, - WRITE_STRING_FILE_AVOID_NEWLINE = 1<<2, - WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1<<3, - WRITE_STRING_FILE_SYNC = 1<<4, - WRITE_STRING_FILE_DISABLE_BUFFER = 1<<5, + WRITE_STRING_FILE_CREATE = 1 << 0, + WRITE_STRING_FILE_ATOMIC = 1 << 1, + WRITE_STRING_FILE_AVOID_NEWLINE = 1 << 2, + WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1 << 3, + WRITE_STRING_FILE_SYNC = 1 << 4, + WRITE_STRING_FILE_DISABLE_BUFFER = 1 << 5, /* And before you wonder, why write_string_file_atomic_label_ts() is a separate function instead of just one more flag here: it's about linking: we don't want to pull -lselinux into all users of write_string_file() diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h index a337b5f5c..4b490078d 100644 --- a/src/basic/fs-util.h +++ b/src/basic/fs-util.h @@ -86,13 +86,13 @@ int inotify_add_watch_fd(int fd, int what, uint32_t mask); #endif // 0 enum { - CHASE_PREFIX_ROOT = 1U << 0, /* If set, the specified path will be prefixed by the specified root before beginning the iteration */ - CHASE_NONEXISTENT = 1U << 1, /* If set, it's OK if the path doesn't actually exist. */ - CHASE_NO_AUTOFS = 1U << 2, /* If set, return -EREMOTE if autofs mount point found */ - CHASE_SAFE = 1U << 3, /* If set, return EPERM if we ever traverse from unprivileged to privileged files or directories */ - CHASE_OPEN = 1U << 4, /* If set, return an O_PATH object to the final component */ - CHASE_TRAIL_SLASH = 1U << 5, /* If set, any trailing slash will be preserved */ - CHASE_STEP = 1U << 6, /* If set, just execute a single step of the normalization */ + CHASE_PREFIX_ROOT = 1 << 0, /* If set, the specified path will be prefixed by the specified root before beginning the iteration */ + CHASE_NONEXISTENT = 1 << 1, /* If set, it's OK if the path doesn't actually exist. */ + CHASE_NO_AUTOFS = 1 << 2, /* If set, return -EREMOTE if autofs mount point found */ + CHASE_SAFE = 1 << 3, /* If set, return EPERM if we ever traverse from unprivileged to privileged files or directories */ + CHASE_OPEN = 1 << 4, /* If set, return an O_PATH object to the final component */ + CHASE_TRAIL_SLASH = 1 << 5, /* If set, any trailing slash will be preserved */ + CHASE_STEP = 1 << 6, /* If set, just execute a single step of the normalization */ }; /* How many iterations to execute before returning -ELOOP */ diff --git a/src/basic/label.h b/src/basic/label.h index 43cc21477..1f3eb54d3 100644 --- a/src/basic/label.h +++ b/src/basic/label.h @@ -11,8 +11,8 @@ #include typedef enum LabelFixFlags { - LABEL_IGNORE_ENOENT = 1U << 0, - LABEL_IGNORE_EROFS = 1U << 1, + LABEL_IGNORE_ENOENT = 1 << 0, + LABEL_IGNORE_EROFS = 1 << 1, } LabelFixFlags; int label_fix(const char *path, LabelFixFlags flags); diff --git a/src/basic/process-util.h b/src/basic/process-util.h index 042f24933..c5655e995 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -53,8 +53,8 @@ int get_process_ppid(pid_t pid, pid_t *ppid); int wait_for_terminate(pid_t pid, siginfo_t *status); typedef enum WaitFlags { - WAIT_LOG_ABNORMAL = 1U << 0, - WAIT_LOG_NON_ZERO_EXIT_STATUS = 1U << 1, + WAIT_LOG_ABNORMAL = 1 << 0, + WAIT_LOG_NON_ZERO_EXIT_STATUS = 1 << 1, /* A shortcut for requesting the most complete logging */ WAIT_LOG = WAIT_LOG_ABNORMAL|WAIT_LOG_NON_ZERO_EXIT_STATUS, @@ -173,15 +173,15 @@ void reset_cached_pid(void); int must_be_root(void); typedef enum ForkFlags { - FORK_RESET_SIGNALS = 1U << 0, - FORK_CLOSE_ALL_FDS = 1U << 1, - FORK_DEATHSIG = 1U << 2, - FORK_NULL_STDIO = 1U << 3, - FORK_REOPEN_LOG = 1U << 4, - FORK_LOG = 1U << 5, - FORK_WAIT = 1U << 6, - FORK_NEW_MOUNTNS = 1U << 7, - FORK_MOUNTNS_SLAVE = 1U << 8, + FORK_RESET_SIGNALS = 1 << 0, + FORK_CLOSE_ALL_FDS = 1 << 1, + FORK_DEATHSIG = 1 << 2, + FORK_NULL_STDIO = 1 << 3, + FORK_REOPEN_LOG = 1 << 4, + FORK_LOG = 1 << 5, + FORK_WAIT = 1 << 6, + FORK_NEW_MOUNTNS = 1 << 7, + FORK_MOUNTNS_SLAVE = 1 << 8, } ForkFlags; int safe_fork_full(const char *name, const int except_fds[], size_t n_except_fds, ForkFlags flags, pid_t *ret_pid); diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index 561e6f117..c56b19d07 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -70,16 +70,16 @@ int open_terminal(const char *name, int mode); /* Flags for tweaking the way we become the controlling process of a terminal. */ typedef enum AcquireTerminalFlags { /* Try to become the controlling process of the TTY. If we can't return -EPERM. */ - ACQUIRE_TERMINAL_TRY = 0, + ACQUIRE_TERMINAL_TRY = 0, /* Tell the kernel to forcibly make us the controlling process of the TTY. Returns -EPERM if the kernel doesn't allow that. */ - ACQUIRE_TERMINAL_FORCE = 1, + ACQUIRE_TERMINAL_FORCE = 1, /* If we can't become the controlling process of the TTY right-away, then wait until we can. */ - ACQUIRE_TERMINAL_WAIT = 2, + ACQUIRE_TERMINAL_WAIT = 2, /* Pick one of the above, and then OR this flag in, in order to request permissive behaviour, if we can't become controlling process then don't mind */ - ACQUIRE_TERMINAL_PERMISSIVE = 4, + ACQUIRE_TERMINAL_PERMISSIVE = 1 << 2, } AcquireTerminalFlags; int acquire_terminal(const char *name, AcquireTerminalFlags flags, usec_t timeout); @@ -180,7 +180,7 @@ int terminal_urlify(const char *url, const char *text, char **ret); int terminal_urlify_path(const char *path, const char *text, char **ret); typedef enum CatFlags { - CAT_FLAGS_MAIN_FILE_OPTIONAL = 1 << 1, + CAT_FLAGS_MAIN_FILE_OPTIONAL = 1 << 0, } CatFlags; int cat_files(const char *file, char **dropins, CatFlags flags); diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c index b115de3bc..f56fce19c 100644 --- a/src/core/mount-setup.c +++ b/src/core/mount-setup.c @@ -38,10 +38,10 @@ #include "string-util.h" typedef enum MountMode { - MNT_NONE = 0, - MNT_FATAL = 1 << 0, - MNT_IN_CONTAINER = 1 << 1, - MNT_CHECK_WRITABLE = 1 << 2, + MNT_NONE = 0, + MNT_FATAL = 1 << 0, + MNT_IN_CONTAINER = 1 << 1, + MNT_CHECK_WRITABLE = 1 << 2, } MountMode; typedef struct MountPoint { diff --git a/src/libelogind/sd-bus/bus-objects.c b/src/libelogind/sd-bus/bus-objects.c index 154801425..49c312371 100644 --- a/src/libelogind/sd-bus/bus-objects.c +++ b/src/libelogind/sd-bus/bus-objects.c @@ -160,9 +160,9 @@ static int add_enumerated_to_set( enum { /* if set, add_subtree() works recursively */ - CHILDREN_RECURSIVE = (1U << 1), + CHILDREN_RECURSIVE = 1 << 0, /* if set, add_subtree() scans object-manager hierarchies recursively */ - CHILDREN_SUBHIERARCHIES = (1U << 0), + CHILDREN_SUBHIERARCHIES = 1 << 1, }; static int add_subtree_to_set( diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h index 40e7e27c7..49038f5e0 100644 --- a/src/shared/bus-util.h +++ b/src/shared/bus-util.h @@ -37,8 +37,8 @@ struct bus_properties_map { }; enum { - BUS_MAP_STRDUP = 1U << 0, /* If set, each "s" message is duplicated. Thus, each pointer needs to be freed. */ - BUS_MAP_BOOLEAN_AS_BOOL = 1U << 1, /* If set, each "b" message is written to a bool pointer. If not set, "b" is written to a int pointer. */ + BUS_MAP_STRDUP = 1 << 0, /* If set, each "s" message is duplicated. Thus, each pointer needs to be freed. */ + BUS_MAP_BOOLEAN_AS_BOOL = 1 << 1, /* If set, each "b" message is written to a bool pointer. If not set, "b" is written to a int pointer. */ }; int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata); diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index e0d9f268f..64e7f8aab 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -20,10 +20,10 @@ /* An abstract parser for simple, line based, shallow configuration files consisting of variable assignments only. */ typedef enum ConfigParseFlags { - CONFIG_PARSE_RELAXED = 1U << 0, - CONFIG_PARSE_ALLOW_INCLUDE = 1U << 1, - CONFIG_PARSE_WARN = 1U << 2, - CONFIG_PARSE_REFUSE_BOM = 1U << 3, + CONFIG_PARSE_RELAXED = 1 << 0, + CONFIG_PARSE_ALLOW_INCLUDE = 1 << 1, + CONFIG_PARSE_WARN = 1 << 2, + CONFIG_PARSE_REFUSE_BOM = 1 << 3, } ConfigParseFlags; /* Argument list for parsers of specific configuration settings. */ -- 2.30.2