]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: replace FLAGS_SET(..., 1 << v) with BIT_SET(..., v) 35760/head
authorMike Yuan <me@yhndnzj.com>
Thu, 26 Dec 2024 19:30:12 +0000 (20:30 +0100)
committerMike Yuan <me@yhndnzj.com>
Sat, 28 Dec 2024 14:08:00 +0000 (15:08 +0100)
23 files changed:
src/basic/cap-list.c
src/basic/compress.c
src/core/dbus-manager.c
src/core/dbus-unit.c
src/core/exec-invoke.c
src/core/execute.c
src/core/unit-serialize.c
src/hostname/hostnamed.c
src/libsystemd/sd-journal/mmap-cache.c
src/login/logind-action.c
src/network/networkd-address.c
src/network/networkd-link.c
src/network/networkd-route-util.c
src/network/networkd-util.c
src/pcrlock/pcrlock.c
src/shared/fdisk-util.c
src/shared/group-record.c
src/shared/tpm2-util.c
src/shared/user-record.c
src/shared/vpick.c
src/tmpfiles/tmpfiles.c
src/udev/udev-builtin.c
src/userdb/userdbctl.c

index b4fe75a37e8de68ee581291746921f85c9ee76e8..2df2887446fdf63bc10a5ff801132e499c613fca 100644 (file)
@@ -4,6 +4,7 @@
 #include <string.h>
 
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "capability-util.h"
 #include "cap-list.h"
 #include "extract-word.h"
@@ -83,7 +84,7 @@ int capability_set_to_string(uint64_t set, char **ret) {
         for (unsigned i = 0; i <= cap_last_cap(); i++) {
                 const char *p;
 
-                if (!FLAGS_SET(set, UINT64_C(1) << i))
+                if (!BIT_SET(set, i))
                         continue;
 
                 p = CAPABILITY_TO_STRING(i);
@@ -143,7 +144,7 @@ int capability_set_to_strv(uint64_t set, char ***ret) {
         for (unsigned i = 0; i <= cap_last_cap(); i++) {
                 const char *p;
 
-                if (!FLAGS_SET(set, UINT64_C(1) << i))
+                if (!BIT_SET(set, i))
                         continue;
 
                 p = CAPABILITY_TO_STRING(i);
index 06db2eed7d7e81471929c71b666bf19fb7a766c7..61e87adddee6874fdc514c53e962bdc0691863da 100644 (file)
@@ -18,6 +18,7 @@
 #endif
 
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "compress.h"
 #include "fd-util.h"
 #include "fileio.h"
@@ -124,7 +125,10 @@ bool compression_supported(Compression c) {
                 (1U << COMPRESSION_LZ4) * HAVE_LZ4 |
                 (1U << COMPRESSION_ZSTD) * HAVE_ZSTD;
 
-        return c >= 0 && c < _COMPRESSION_MAX && FLAGS_SET(supported, 1U << c);
+        assert(c >= 0);
+        assert(c < _COMPRESSION_MAX);
+
+        return BIT_SET(supported, c);
 }
 
 #if HAVE_XZ
index 3c66d698932a23b4b9d5dff48a19c5181209360f..47d919a014dd88ba3af154d2ee50a29456f746e0 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "alloc-util.h"
 #include "architecture.h"
+#include "bitfield.h"
 #include "build.h"
 #include "bus-common-errors.h"
 #include "bus-get-properties.h"
@@ -2085,9 +2086,9 @@ static int method_enqueue_marked_jobs(sd_bus_message *message, void *userdata, s
                         continue;
 
                 BusUnitQueueFlags flags;
-                if (FLAGS_SET(u->markers, 1u << UNIT_MARKER_NEEDS_RESTART))
+                if (BIT_SET(u->markers, UNIT_MARKER_NEEDS_RESTART))
                         flags = 0;
-                else if (FLAGS_SET(u->markers, 1u << UNIT_MARKER_NEEDS_RELOAD))
+                else if (BIT_SET(u->markers, UNIT_MARKER_NEEDS_RELOAD))
                         flags = BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE;
                 else
                         continue;
index 03f25402a289a54d402e82f26a68f506920de94e..6dca2d93bdb8774eb7224af879e31b33a123a1e1 100644 (file)
@@ -3,6 +3,7 @@
 #include "sd-bus.h"
 
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "bpf-firewall.h"
 #include "bus-common-errors.h"
 #include "bus-get-properties.h"
@@ -72,7 +73,7 @@ static int property_get_can_clean(
                 return r;
 
         for (ExecDirectoryType t = 0; t < _EXEC_DIRECTORY_TYPE_MAX; t++) {
-                if (!FLAGS_SET(mask, 1U << t))
+                if (!BIT_SET(mask, t))
                         continue;
 
                 r = sd_bus_message_append(reply, "s", exec_resource_type_to_string(t));
@@ -353,15 +354,11 @@ static int property_get_markers(
         if (r < 0)
                 return r;
 
-        /* Make sure out values fit in the bitfield. */
-        assert_cc(_UNIT_MARKER_MAX <= sizeof(((Unit){}).markers) * 8);
-
-        for (UnitMarker m = 0; m < _UNIT_MARKER_MAX; m++)
-                if (FLAGS_SET(*markers, 1u << m)) {
-                        r = sd_bus_message_append(reply, "s", unit_marker_to_string(m));
-                        if (r < 0)
-                                return r;
-                }
+        BIT_FOREACH(m, *markers) {
+                r = sd_bus_message_append(reply, "s", unit_marker_to_string(m));
+                if (r < 0)
+                        return r;
+        }
 
         return sd_bus_message_close_container(reply);
 }
index ff616813f61d238a3812d36787d90bdd2aeee171..c58698e564957eee322ce4e4e0edb46fe4328c5c 100644 (file)
@@ -22,6 +22,7 @@
 #endif
 #include "argv-util.h"
 #include "barrier.h"
+#include "bitfield.h"
 #include "bpf-dlopen.h"
 #include "bpf-restrict-fs.h"
 #include "btrfs-util.h"
@@ -5359,7 +5360,7 @@ int exec_invoke(
                         }
 
                         if (keep_seccomp_privileges) {
-                                if (!FLAGS_SET(capability_ambient_set, (UINT64_C(1) << CAP_SETUID))) {
+                                if (!BIT_SET(capability_ambient_set, CAP_SETUID)) {
                                         r = drop_capability(CAP_SETUID);
                                         if (r < 0) {
                                                 *exit_status = EXIT_USER;
@@ -5585,7 +5586,7 @@ int exec_invoke(
 
                         /* Only drop CAP_SYS_ADMIN if it's not in the bounding set, otherwise we'll break
                          * applications that use it. */
-                        if (!FLAGS_SET(saved_bset, (UINT64_C(1) << CAP_SYS_ADMIN))) {
+                        if (!BIT_SET(saved_bset, CAP_SYS_ADMIN)) {
                                 r = drop_capability(CAP_SYS_ADMIN);
                                 if (r < 0) {
                                         *exit_status = EXIT_USER;
@@ -5595,7 +5596,7 @@ int exec_invoke(
 
                         /* Only drop CAP_SETPCAP if it's not in the bounding set, otherwise we'll break
                          * applications that use it. */
-                        if (!FLAGS_SET(saved_bset, (UINT64_C(1) << CAP_SETPCAP))) {
+                        if (!BIT_SET(saved_bset, CAP_SETPCAP)) {
                                 r = drop_capability(CAP_SETPCAP);
                                 if (r < 0) {
                                         *exit_status = EXIT_USER;
index f12667f17549c2cf00352a738216dd1f44c4fc53..2ce67f9dbdd5a5b67352f2a9ef7f4283e8eaef3f 100644 (file)
@@ -20,6 +20,7 @@
 #include "af-list.h"
 #include "alloc-util.h"
 #include "async.h"
+#include "bitfield.h"
 #include "cap-list.h"
 #include "capability-util.h"
 #include "cgroup-setup.h"
@@ -1666,7 +1667,7 @@ int exec_context_get_clean_directories(
         assert(ret);
 
         for (ExecDirectoryType t = 0; t < _EXEC_DIRECTORY_TYPE_MAX; t++) {
-                if (!FLAGS_SET(mask, 1U << t))
+                if (!BIT_SET(mask, t))
                         continue;
 
                 if (!prefix[t])
index 82102c0c327a39b354f1a588c97cb6ec742ed418..82789fdbf44f799fa9bcdc01935401579992494e 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "bitfield.h"
 #include "bpf-restrict-ifaces.h"
 #include "bpf-socket-bind.h"
 #include "bus-util.h"
@@ -24,9 +25,8 @@ static int serialize_markers(FILE *f, unsigned markers) {
         bool space = false;
 
         fputs("markers=", f);
-        for (UnitMarker m = 0; m < _UNIT_MARKER_MAX; m++)
-                if (FLAGS_SET(markers, 1u << m))
-                        fputs_with_separator(f, unit_marker_to_string(m), /* separator = */ NULL, &space);
+        BIT_FOREACH(m, markers)
+                fputs_with_separator(f, unit_marker_to_string(m), /* separator = */ NULL, &space);
         fputc('\n', f);
         return 0;
 }
@@ -496,9 +496,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
         if (u->markers != 0) {
                 fprintf(f, "%s\tMarkers:", prefix);
 
-                for (UnitMarker marker = 0; marker < _UNIT_MARKER_MAX; marker++)
-                        if (FLAGS_SET(u->markers, 1u << marker))
-                                fprintf(f, " %s", unit_marker_to_string(marker));
+                BIT_FOREACH(marker, u->markers)
+                        fprintf(f, " %s", unit_marker_to_string(marker));
                 fputs("\n", f);
         }
 
index ba50b59f92218fe4f34dbc5e841704d7848944de..2c2fcb3fdebf662097cd8955cde5c55a410d4170 100644 (file)
@@ -10,6 +10,7 @@
 #include "sd-json.h"
 
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "bus-common-errors.h"
 #include "bus-get-properties.h"
 #include "bus-log-control-api.h"
@@ -88,7 +89,7 @@ static void context_reset(Context *c, uint64_t mask) {
         assert(c);
 
         for (int p = 0; p < _PROP_MAX; p++) {
-                if (!FLAGS_SET(mask, UINT64_C(1) << p))
+                if (!BIT_SET(mask, p))
                         continue;
 
                 c->data[p] = mfree(c->data[p]);
index ce8aff3c5c1003d887fc463ac37e9bee6354d8f3..49e1e5fc81415205d123340e23474a8bbca359f5 100644 (file)
@@ -5,6 +5,7 @@
 #include <sys/mman.h>
 
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "errno-util.h"
 #include "fd-util.h"
 #include "hashmap.h"
@@ -109,7 +110,7 @@ static Window* window_unlink(Window *w) {
         }
 
         for (unsigned i = 0; i < _MMAP_CACHE_CATEGORY_MAX; i++)
-                if (FLAGS_SET(w->flags, 1u << i))
+                if (BIT_SET(w->flags, i))
                         assert_se(TAKE_PTR(m->windows_by_category[i]) == w);
 
         return LIST_REMOVE(windows, w->fd->windows, w);
@@ -193,7 +194,7 @@ static void category_detach_window(MMapCache *m, MMapCacheCategory c) {
         if (!w)
                 return; /* Nothing attached. */
 
-        assert(FLAGS_SET(w->flags, 1u << c));
+        assert(BIT_SET(w->flags, c));
         w->flags &= ~(1u << c);
 
         if (WINDOW_IS_UNUSED(w)) {
index 712438f4b1e7bd2ae1cf61dd80e426d8dc3c9baa..2ce8f628a381cb608da61ec48b2b971097977dfb 100644 (file)
@@ -5,6 +5,7 @@
 #include "sd-messages.h"
 
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "bus-error.h"
 #include "bus-unit-util.h"
 #include "bus-util.h"
@@ -158,7 +159,7 @@ int handle_action_get_enabled_sleep_actions(HandleActionSleepMask mask, char ***
         assert(ret);
 
         FOREACH_ELEMENT(i, sleep_actions)
-                if (FLAGS_SET(mask, 1U << *i)) {
+                if (BIT_SET(mask, *i)) {
                         r = strv_extend(&actions, handle_action_to_string(*i));
                         if (r < 0)
                                 return r;
index bc5bfb8e8347820e18332b849c5fbee828c37224..d0f0282075c597464e065b15dc1c2a0327117e91 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "af-list.h"
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "firewall-util.h"
 #include "in-addr-prefix-util.h"
 #include "logarithm.h"
@@ -84,7 +85,7 @@ int address_flags_to_string_alloc(uint32_t flags, int family, char **ret) {
         assert(ret);
 
         for (size_t i = 0; i < ELEMENTSOF(map); i++)
-                if (FLAGS_SET(flags, 1 << i) && map[i])
+                if (BIT_SET(flags, i) && map[i])
                         if (!strextend_with_separator(
                                             &str, ",",
                                             family == AF_INET6 && (1 << i) == IFA_F_SECONDARY ? "temporary" : map[i]))
index 22756fc8fbfcfa319b3130e5094ce2856040ceb3..3f816d7fa25c451419dface2e004e6be86d0d047 100644 (file)
@@ -13,6 +13,7 @@
 #include "alloc-util.h"
 #include "arphrd-util.h"
 #include "batadv.h"
+#include "bitfield.h"
 #include "bond.h"
 #include "bridge.h"
 #include "bus-util.h"
@@ -2988,7 +2989,7 @@ int link_flags_to_string_alloc(uint32_t flags, char **ret) {
         assert(ret);
 
         for (size_t i = 0; i < ELEMENTSOF(map); i++)
-                if (FLAGS_SET(flags, 1 << i) && map[i])
+                if (BIT_SET(flags, i) && map[i])
                         if (!strextend_with_separator(&str, ",", map[i]))
                                 return -ENOMEM;
 
index dc9663e24b6a03f4d52b636e37c5a8f498d0a11c..6b9810f934d98d460ddd7ed6b01005d07fb595b9 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/rtnetlink.h>
 
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "logarithm.h"
 #include "missing_threads.h"
 #include "networkd-address.h"
@@ -405,7 +406,7 @@ int route_flags_to_string_alloc(uint32_t flags, char **ret) {
         assert(ret);
 
         for (size_t i = 0; i < ELEMENTSOF(map); i++)
-                if (FLAGS_SET(flags, 1 << i) && map[i])
+                if (BIT_SET(flags, i) && map[i])
                         if (!strextend_with_separator(&str, ",", map[i]))
                                 return -ENOMEM;
 
index 0a40d81edd6f159da15e05dc868d1a9a3da1fd67..5db89c604722124fee93f18b7a8a0f54c44251af 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "bitfield.h"
 #include "condition.h"
 #include "conf-parser.h"
 #include "escape.h"
@@ -38,12 +39,9 @@ int network_config_state_to_string_alloc(NetworkConfigState s, char **ret) {
         assert(ret);
 
         for (size_t i = 0; i < ELEMENTSOF(states); i++)
-                if (FLAGS_SET(s, 1 << i)) {
-                        assert(states[i]);
-
-                        if (!strextend_with_separator(&buf, ",", states[i]))
+                if (BIT_SET(s, i))
+                        if (!strextend_with_separator(&buf, ",", ASSERT_PTR(states[i])))
                                 return -ENOMEM;
-                }
 
         *ret = TAKE_PTR(buf);
         return 0;
index 03611d507c4f021e5586a17834431ce0333df80d..9562bf2a892be8c9c2fcf9dcf4063e4272088e69 100644 (file)
@@ -10,6 +10,7 @@
 #include "sd-varlink.h"
 
 #include "ask-password-api.h"
+#include "bitfield.h"
 #include "blockdev-util.h"
 #include "boot-entry.h"
 #include "build.h"
@@ -2260,7 +2261,7 @@ static int show_pcr_table(EventLog *el, sd_json_variant **ret_variant) {
                 bool fully_recognized = el->registers[pcr].fully_recognized;
 
                 /* Whether any unmatched components touch this PCR */
-                bool missing_components = FLAGS_SET(el->missing_component_pcrs, UINT32_C(1) << pcr);
+                bool missing_components = BIT_SET(el->missing_component_pcrs, pcr);
 
                 const char *emoji = special_glyph(
                                 !hash_match ? SPECIAL_GLYPH_DEPRESSED_SMILEY :
@@ -2675,7 +2676,7 @@ static int event_log_pcr_mask_checks_out(EventLog *el, uint32_t mask) {
 
         for (uint32_t pcr = 0; pcr < TPM2_PCRS_MAX; pcr++) {
 
-                if (!FLAGS_SET(mask, UINT32_C(1) << pcr))
+                if (!BIT_SET(mask, pcr))
                         continue;
 
                 if (!event_log_pcr_checks_out(el, el->registers + pcr))
@@ -2815,7 +2816,7 @@ static int make_pcrlock_record_from_stream(
         for (uint32_t i = 0; i < TPM2_PCRS_MAX; i++) {
                 _cleanup_(sd_json_variant_unrefp) sd_json_variant *record = NULL;
 
-                if (!FLAGS_SET(pcr_mask, UINT32_C(1) << i))
+                if (!BIT_SET(pcr_mask, i))
                         continue;
 
                 r = sd_json_buildo(
@@ -3669,7 +3670,7 @@ static int verb_lock_pe(int argc, char *argv[], void *userdata) {
         for (uint32_t i = 0; i < TPM2_PCRS_MAX; i++) {
                 _cleanup_(sd_json_variant_unrefp) sd_json_variant *digests = NULL;
 
-                if (!FLAGS_SET(arg_pcr_mask, UINT32_C(1) << i))
+                if (!BIT_SET(arg_pcr_mask, i))
                         continue;
 
                 FOREACH_ARRAY(pa, tpm2_hash_algorithms, TPM2_N_HASH_ALGORITHMS) {
@@ -3894,7 +3895,7 @@ static int event_log_reduce_to_safe_pcrs(EventLog *el, uint32_t *pcrs) {
 
         for (uint32_t pcr = 0; pcr < TPM2_PCRS_MAX; pcr++) {
 
-                if (!FLAGS_SET(*pcrs, UINT32_C(1) << pcr))
+                if (!BIT_SET(*pcrs, pcr))
                         continue;
 
                 if (!event_log_pcr_checks_out(el, el->registers + pcr)) {
@@ -3907,7 +3908,7 @@ static int event_log_reduce_to_safe_pcrs(EventLog *el, uint32_t *pcrs) {
                         goto drop;
                 }
 
-                if (FLAGS_SET(el->missing_component_pcrs, UINT32_C(1) << pcr)) {
+                if (BIT_SET(el->missing_component_pcrs, pcr)) {
                         log_notice("PCR %" PRIu32 " (%s) is touched by component we can't find in event log. Removing from set of PCRs.", pcr, strna(tpm2_pcr_index_to_string(pcr)));
                         goto drop;
                 }
@@ -4191,7 +4192,7 @@ static int event_log_show_predictions(Tpm2PCRPrediction *context, uint16_t alg)
 
         for (uint32_t pcr = 0; pcr < TPM2_PCRS_MAX; pcr++) {
                 Tpm2PCRPredictionResult *result;
-                if (!FLAGS_SET(context->pcrs, UINT32_C(1) << pcr))
+                if (!BIT_SET(context->pcrs, pcr))
                         continue;
 
                 if (ordered_set_isempty(context->results[pcr])) {
@@ -4240,7 +4241,7 @@ static int tpm2_pcr_prediction_run(
         for (uint32_t pcr = 0; pcr < TPM2_PCRS_MAX; pcr++) {
                 _cleanup_free_ Tpm2PCRPredictionResult *result = NULL;
 
-                if (!FLAGS_SET(context->pcrs, UINT32_C(1) << pcr))
+                if (!BIT_SET(context->pcrs, pcr))
                         continue;
 
                 result = new0(Tpm2PCRPredictionResult, 1);
index 20f32d19affe439ef6b59489524963108af62162..368bec2b8b86a6aff34cdf44ba2659d69b492dca 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "bitfield.h"
 #include "dissect-image.h"
 #include "extract-word.h"
 #include "fd-util.h"
@@ -149,7 +150,7 @@ int fdisk_partition_set_attrs_as_uint64(struct fdisk_partition *pa, uint64_t fla
         assert(pa);
 
         for (unsigned i = 0; i < sizeof(flags) * 8; i++) {
-                if (!FLAGS_SET(flags, UINT64_C(1) << i))
+                if (!BIT_SET(flags, i))
                         continue;
 
                 r = strextendf_with_separator(&attrs, ",", "%u", i);
index 7b401bf06449e0d34b16a00dd2332fa840b251a6..4898616252c4956f05df14f6db50ad57752caeec 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "bitfield.h"
 #include "group-record.h"
 #include "json-util.h"
 #include "strv.h"
@@ -334,7 +335,7 @@ int group_record_match(GroupRecord *h, const UserDBMatch *match) {
         if (h->gid < match->gid_min || h->gid > match->gid_max)
                 return false;
 
-        if (!FLAGS_SET(match->disposition_mask, UINT64_C(1) << group_record_disposition(h)))
+        if (!BIT_SET(match->disposition_mask, group_record_disposition(h)))
                 return false;
 
         if (!strv_isempty(match->fuzzy_names)) {
index 4bd9fc65dd2394d29257ae9050441209a1a619ef..890d77dcc27568e26a5c50ed918d2aeda685239b 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "alloc-util.h"
 #include "ansi-color.h"
+#include "bitfield.h"
 #include "constants.h"
 #include "creds-util.h"
 #include "cryptsetup-util.h"
@@ -6687,7 +6688,7 @@ int tpm2_pcr_prediction_to_json(
                 _cleanup_(sd_json_variant_unrefp) sd_json_variant *vj = NULL;
                 Tpm2PCRPredictionResult *banks;
 
-                if (!FLAGS_SET(prediction->pcrs, UINT32_C(1) << pcr))
+                if (!BIT_SET(prediction->pcrs, pcr))
                         continue;
 
                 ORDERED_SET_FOREACH(banks, prediction->results[pcr]) {
@@ -6812,7 +6813,7 @@ int tpm2_calculate_policy_super_pcr(
         _cleanup_free_ Tpm2PCRValue *single_values = NULL;
         size_t n_single_values = 0;
         for (uint32_t pcr = 0; pcr < TPM2_PCRS_MAX; pcr++) {
-                if (!FLAGS_SET(prediction->pcrs, UINT32_C(1) << pcr))
+                if (!BIT_SET(prediction->pcrs, pcr))
                         continue;
 
                 if (ordered_set_size(prediction->results[pcr]) != 1)
@@ -6848,7 +6849,7 @@ int tpm2_calculate_policy_super_pcr(
                 size_t n_pcr_policy_digest_variants = 0;
                 Tpm2PCRPredictionResult *banks;
 
-                if (!FLAGS_SET(prediction->pcrs, UINT32_C(1) << pcr))
+                if (!BIT_SET(prediction->pcrs, pcr))
                         continue;
 
                 if (ordered_set_size(prediction->results[pcr]) <= 1) /* We only care for PCRs with 2 or more variants in this loop */
@@ -6921,7 +6922,7 @@ int tpm2_policy_super_pcr(
 
         /* Look for all PCRs that have only a singled allowed hash value, and synthesize a single PolicyPCR policy item for them */
         for (uint32_t pcr = 0; pcr < TPM2_PCRS_MAX; pcr++) {
-                if (!FLAGS_SET(prediction->pcrs, UINT32_C(1) << pcr))
+                if (!BIT_SET(prediction->pcrs, pcr))
                         continue;
 
                 if (ordered_set_size(prediction->results[pcr]) != 1)
@@ -6951,7 +6952,7 @@ int tpm2_policy_super_pcr(
         for (uint32_t pcr = 0; pcr < TPM2_PCRS_MAX; pcr++) {
                 size_t n_branches;
 
-                if (!FLAGS_SET(prediction->pcrs, UINT32_C(1) << pcr))
+                if (!BIT_SET(prediction->pcrs, pcr))
                         continue;
 
                 n_branches = ordered_set_size(prediction->results[pcr]);
index 4557718023619ffff40c0acb0ce821a701691e6f..131949a4e4fefd273c1c61dfb7499a7456be7239 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <sys/mount.h>
 
+#include "bitfield.h"
 #include "cap-list.h"
 #include "cgroup-util.h"
 #include "dns-domain.h"
@@ -2671,7 +2672,7 @@ int user_record_match(UserRecord *u, const UserDBMatch *match) {
         if (u->uid < match->uid_min || u->uid > match->uid_max)
                 return false;
 
-        if (!FLAGS_SET(match->disposition_mask, UINT64_C(1) << user_record_disposition(u)))
+        if (!BIT_SET(match->disposition_mask, user_record_disposition(u)))
                 return false;
 
         if (!strv_isempty(match->fuzzy_names)) {
index 4720e7448d8acfedd4492a8a022c1ecbe801ecfb..c2ca800af5b4c3c0a4de629b001f55b97c29fa8d 100644 (file)
@@ -3,6 +3,7 @@
 #include <sys/stat.h>
 
 #include "architecture.h"
+#include "bitfield.h"
 #include "chase.h"
 #include "fd-util.h"
 #include "fs-util.h"
@@ -108,7 +109,7 @@ static int errno_from_mode(uint32_t type_mask, mode_t found) {
         if (type_mask == 0) /* type doesn't matter */
                 return 0;
 
-        if (FLAGS_SET(type_mask, UINT32_C(1) << IFTODT(found)))
+        if (BIT_SET(type_mask, IFTODT(found)))
                 return 0;
 
         if (type_mask == (UINT32_C(1) << DT_BLK))
@@ -164,7 +165,7 @@ static int pin_choice(
                 return log_debug_errno(errno, "Failed to stat discovered inode '%s': %m", prefix_roota(toplevel_path, inode_path));
 
         if (filter->type_mask != 0 &&
-            !FLAGS_SET(filter->type_mask, UINT32_C(1) << IFTODT(st.st_mode)))
+            !BIT_SET(filter->type_mask, IFTODT(st.st_mode)))
                 return log_debug_errno(
                                 SYNTHETIC_ERRNO(errno_from_mode(filter->type_mask, st.st_mode)),
                                 "Inode '%s' has wrong type, found '%s'.",
@@ -596,7 +597,7 @@ int path_pick(
                 filter_type_mask = filter->type_mask;
                 if (slash_suffix) {
                         /* If the pattern is suffixed by a / then we are looking for directories apparently. */
-                        if (filter_type_mask != 0 && !FLAGS_SET(filter_type_mask, UINT32_C(1) << DT_DIR))
+                        if (filter_type_mask != 0 && !BIT_SET(filter_type_mask, DT_DIR))
                                 return log_debug_errno(SYNTHETIC_ERRNO(errno_from_mode(filter_type_mask, S_IFDIR)),
                                                        "Specified pattern ends in '/', but not looking for directories, refusing.");
                         filter_type_mask = UINT32_C(1) << DT_DIR;
index bff05cda6f05f8b98b820958529a960d8f83dc72..4c14031b0bc1d9311b7c0af4a860c3f2c116f6ae 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "acl-util.h"
 #include "alloc-util.h"
+#include "bitfield.h"
 #include "btrfs-util.h"
 #include "build.h"
 #include "capability-util.h"
@@ -3120,7 +3121,7 @@ static char *age_by_to_string(AgeBy ab, bool is_dir) {
                 return NULL;
 
         for (size_t i = 0; i < ELEMENTSOF(ab_map); i++)
-                if (FLAGS_SET(ab, 1U << i))
+                if (BIT_SET(ab, i))
                         ret[j++] = is_dir ? ascii_toupper(ab_map[i]) : ab_map[i];
 
         ret[j] = 0;
index b47ca37d55bb78b97d7deaeb65c3315aa1b2d75d..b190504a831319d13a60fff74dac8ac7dfd9fede 100644 (file)
@@ -3,6 +3,7 @@
 #include <getopt.h>
 #include <stdio.h>
 
+#include "bitfield.h"
 #include "device-private.h"
 #include "device-util.h"
 #include "string-util.h"
@@ -57,7 +58,7 @@ UdevReloadFlags udev_builtin_should_reload(void) {
 
 void udev_builtin_reload(UdevReloadFlags flags) {
         for (UdevBuiltinCommand i = 0; i < _UDEV_BUILTIN_MAX; i++) {
-                if (!FLAGS_SET(flags, 1u << i) || !builtins[i])
+                if (!BIT_SET(flags, i) || !builtins[i])
                         continue;
                 if (builtins[i]->exit)
                         builtins[i]->exit();
index 1ddd05789f9ec0e40fc08c5c2602d082f71a1aaf..a803df8b0b5bba6d3ff5accc147b96297e352e94 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <getopt.h>
 
+#include "bitfield.h"
 #include "build.h"
 #include "dirent-util.h"
 #include "errno-list.h"
@@ -194,7 +195,7 @@ static int table_add_uid_boundaries(Table *table, const UIDRange *p) {
         FOREACH_ELEMENT(i, uid_range_table) {
                 _cleanup_free_ char *name = NULL, *comment = NULL;
 
-                if (!FLAGS_SET(arg_disposition_mask, UINT64_C(1) << i->disposition))
+                if (!BIT_SET(arg_disposition_mask, i->disposition))
                         continue;
 
                 if (!uid_range_covers(p, i->first, i->last - i->first + 1))
@@ -585,7 +586,7 @@ static int table_add_gid_boundaries(Table *table, const UIDRange *p) {
         FOREACH_ELEMENT(i, uid_range_table) {
                 _cleanup_free_ char *name = NULL, *comment = NULL;
 
-                if (!FLAGS_SET(arg_disposition_mask, UINT64_C(1) << i->disposition))
+                if (!BIT_SET(arg_disposition_mask, i->disposition))
                         continue;
 
                 if (!uid_range_covers(p, i->first, i->last - i->first + 1))