tree-wide: replace FLAGS_SET(..., 1 << v) with BIT_SET(..., v)

This commit is contained in:
Mike Yuan
2024-12-28 15:08:00 +01:00
parent 382f3438d9
commit 1e4e557262
23 changed files with 77 additions and 60 deletions
+2 -1
View 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]))
+2 -1
View 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;
+2 -1
View 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;
+3 -5
View 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;