tree-wide: replace FLAGS_SET(..., 1 << v) with BIT_SET(..., v)
This commit is contained in:
@@ -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;
|
||||
|
||||
+7
-10
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-1
@@ -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])
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user