Skip to content

Commit

Permalink
tree-wide: always declare bitflag enums the same way
Browse files Browse the repository at this point in the history
let's always use the 1 << x syntax. No change of behaviour or even of
the compiled binary.

(cherry picked from commit be0b7a1)

Resolves: RHEL-2857
  • Loading branch information
poettering authored and lnykryn committed Sep 11, 2023
1 parent 0c1f962 commit fea141e
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
16 changes: 8 additions & 8 deletions src/basic/btrfs-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ typedef struct BtrfsQuotaInfo {
} BtrfsQuotaInfo;

typedef enum BtrfsSnapshotFlags {
BTRFS_SNAPSHOT_FALLBACK_COPY = 1, /* If the source isn't a subvolume, reflink everything */
BTRFS_SNAPSHOT_READ_ONLY = 2,
BTRFS_SNAPSHOT_RECURSIVE = 4,
BTRFS_SNAPSHOT_QUOTA = 8,
BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 16, /* If the destination doesn't support subvolumes, reflink/copy instead */
BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 32, /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */
BTRFS_SNAPSHOT_FALLBACK_COPY = 1 << 0, /* If the source isn't a subvolume, reflink everything */
BTRFS_SNAPSHOT_READ_ONLY = 1 << 1,
BTRFS_SNAPSHOT_RECURSIVE = 1 << 2,
BTRFS_SNAPSHOT_QUOTA = 1 << 3,
BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 1 << 4, /* If the destination doesn't support subvolumes, reflink/copy instead */
BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 1 << 5, /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */
} BtrfsSnapshotFlags;

typedef enum BtrfsRemoveFlags {
BTRFS_REMOVE_RECURSIVE = 1,
BTRFS_REMOVE_QUOTA = 2,
BTRFS_REMOVE_RECURSIVE = 1 << 0,
BTRFS_REMOVE_QUOTA = 1 << 1,
} BtrfsRemoveFlags;

int btrfs_is_filesystem(int fd);
Expand Down
6 changes: 3 additions & 3 deletions src/basic/cgroup-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d);
int cg_read_subgroup(DIR *d, char **fn);

typedef enum CGroupFlags {
CGROUP_SIGCONT = 1,
CGROUP_IGNORE_SELF = 2,
CGROUP_REMOVE = 4,
CGROUP_SIGCONT = 1 << 0,
CGROUP_IGNORE_SELF = 1 << 1,
CGROUP_REMOVE = 1 << 2,
} CGroupFlags;

typedef void (*cg_kill_log_func_t)(pid_t pid, int sig, void *userdata);
Expand Down
12 changes: 6 additions & 6 deletions src/basic/extract-word.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include "macro.h"

typedef enum ExtractFlags {
EXTRACT_RELAX = 1,
EXTRACT_CUNESCAPE = 2,
EXTRACT_CUNESCAPE_RELAX = 4,
EXTRACT_QUOTES = 8,
EXTRACT_DONT_COALESCE_SEPARATORS = 16,
EXTRACT_RETAIN_ESCAPE = 32,
EXTRACT_RELAX = 1 << 0,
EXTRACT_CUNESCAPE = 1 << 1,
EXTRACT_CUNESCAPE_RELAX = 1 << 2,
EXTRACT_QUOTES = 1 << 3,
EXTRACT_DONT_COALESCE_SEPARATORS = 1 << 4,
EXTRACT_RETAIN_ESCAPE = 1 << 5,
} ExtractFlags;

int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags);
Expand Down
10 changes: 5 additions & 5 deletions src/basic/unit-name.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#define UNIT_NAME_MAX 256

typedef enum UnitNameFlags {
UNIT_NAME_PLAIN = 1, /* Allow foo.service */
UNIT_NAME_INSTANCE = 2, /* Allow foo@bar.service */
UNIT_NAME_TEMPLATE = 4, /* Allow foo@.service */
UNIT_NAME_PLAIN = 1 << 0, /* Allow foo.service */
UNIT_NAME_INSTANCE = 1 << 1, /* Allow foo@bar.service */
UNIT_NAME_TEMPLATE = 1 << 2, /* Allow foo@.service */
UNIT_NAME_ANY = UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE,
} UnitNameFlags;

Expand Down Expand Up @@ -53,8 +53,8 @@ int unit_name_from_path_instance(const char *prefix, const char *path, const cha
int unit_name_to_path(const char *name, char **ret);

typedef enum UnitNameMangle {
UNIT_NAME_MANGLE_GLOB = 1,
UNIT_NAME_MANGLE_WARN = 2,
UNIT_NAME_MANGLE_GLOB = 1 << 0,
UNIT_NAME_MANGLE_WARN = 1 << 1,
} UnitNameMangle;

int unit_name_mangle_with_suffix(const char *name, UnitNameMangle flags, const char *suffix, char **ret);
Expand Down
4 changes: 2 additions & 2 deletions src/libsystemd/sd-bus/bus-dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "sd-bus.h"

enum {
BUS_MESSAGE_DUMP_WITH_HEADER = 1,
BUS_MESSAGE_DUMP_SUBTREE_ONLY = 2,
BUS_MESSAGE_DUMP_WITH_HEADER = 1 << 0,
BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1 << 1,
};

int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags);
Expand Down
12 changes: 6 additions & 6 deletions src/libsystemd/sd-bus/bus-protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ enum {
/* Flags */

enum {
BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
BUS_MESSAGE_NO_AUTO_START = 2,
BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 4,
BUS_MESSAGE_NO_REPLY_EXPECTED = 1 << 0,
BUS_MESSAGE_NO_AUTO_START = 1 << 1,
BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 1 << 2,
};

/* Header fields */
Expand All @@ -81,9 +81,9 @@ enum {
/* RequestName parameters */

enum {
BUS_NAME_ALLOW_REPLACEMENT = 1,
BUS_NAME_REPLACE_EXISTING = 2,
BUS_NAME_DO_NOT_QUEUE = 4
BUS_NAME_ALLOW_REPLACEMENT = 1 << 0,
BUS_NAME_REPLACE_EXISTING = 1 << 1,
BUS_NAME_DO_NOT_QUEUE = 1 << 2,
};

/* RequestName returns */
Expand Down
18 changes: 9 additions & 9 deletions src/login/logind-inhibit.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
typedef struct Inhibitor Inhibitor;

typedef enum InhibitWhat {
INHIBIT_SHUTDOWN = 1,
INHIBIT_SLEEP = 2,
INHIBIT_IDLE = 4,
INHIBIT_HANDLE_POWER_KEY = 8,
INHIBIT_HANDLE_SUSPEND_KEY = 16,
INHIBIT_HANDLE_HIBERNATE_KEY = 32,
INHIBIT_HANDLE_LID_SWITCH = 64,
_INHIBIT_WHAT_MAX = 128,
_INHIBIT_WHAT_INVALID = -1
INHIBIT_SHUTDOWN = 1 << 0,
INHIBIT_SLEEP = 1 << 1,
INHIBIT_IDLE = 1 << 2,
INHIBIT_HANDLE_POWER_KEY = 1 << 3,
INHIBIT_HANDLE_SUSPEND_KEY = 1 << 4,
INHIBIT_HANDLE_HIBERNATE_KEY = 1 << 5,
INHIBIT_HANDLE_LID_SWITCH = 1 << 6,
_INHIBIT_WHAT_MAX = 1 << 7,
_INHIBIT_WHAT_INVALID = -1
} InhibitWhat;

typedef enum InhibitMode {
Expand Down
10 changes: 5 additions & 5 deletions src/resolve/resolved-dns-answer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ typedef struct DnsAnswerItem DnsAnswerItem;
* Note that we usually encode the empty DnsAnswer object as a simple NULL. */

typedef enum DnsAnswerFlags {
DNS_ANSWER_AUTHENTICATED = 1, /* Item has been authenticated */
DNS_ANSWER_CACHEABLE = 2, /* Item is subject to caching */
DNS_ANSWER_SHARED_OWNER = 4, /* For mDNS: RRset may be owner by multiple peers */
DNS_ANSWER_CACHE_FLUSH = 8, /* For mDNS: sets cache-flush bit in the rrclass of response records */
DNS_ANSWER_GOODBYE = 16, /* For mDNS: item is subject to disappear */
DNS_ANSWER_AUTHENTICATED = 1 << 0, /* Item has been authenticated */
DNS_ANSWER_CACHEABLE = 1 << 1, /* Item is subject to caching */
DNS_ANSWER_SHARED_OWNER = 1 << 2, /* For mDNS: RRset may be owner by multiple peers */
DNS_ANSWER_CACHE_FLUSH = 1 << 3, /* For mDNS: sets cache-flush bit in the rrclass of response records */
DNS_ANSWER_GOODBYE = 1 << 4, /* For mDNS: item is subject to disappear */
} DnsAnswerFlags;

struct DnsAnswerItem {
Expand Down

0 comments on commit fea141e

Please sign in to comment.