sysupdate: Convert an internal bool argument to flags

This commit makes no functional changes, but the new flags will be
used and extended in the following commit. We need a flags variable to
avoid having two bool arguments, which would be confusing.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/41501
This commit is contained in:
Philip Withnall
2026-05-22 11:45:07 +01:00
parent b13cc855e2
commit f4a3acb6ed
+12 -8
View File
@@ -171,7 +171,11 @@ static int read_definitions(
return 0;
}
static int context_read_definitions(Context *c, const char* node, bool requires_enabled_transfers) {
typedef enum ReadDefinitionsFlags {
READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS = 1 << 0,
} ReadDefinitionsFlags;
static int context_read_definitions(Context *c, const char* node, ReadDefinitionsFlags flags) {
_cleanup_strv_free_ char **dirs = NULL;
int r;
@@ -244,7 +248,7 @@ static int context_read_definitions(Context *c, const char* node, bool requires_
log_warning("As of v257, transfer definitions should have the '.transfer' extension.");
}
if (c->n_transfers + (requires_enabled_transfers ? 0 : c->n_disabled_transfers) == 0) {
if (c->n_transfers + (FLAGS_SET(flags, READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS) ? 0 : c->n_disabled_transfers) == 0) {
if (arg_component)
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
"No transfer definitions for component '%s' found.",
@@ -925,7 +929,7 @@ static int context_vacuum(
return 0;
}
static int context_make_offline(Context **ret, const char *node, bool requires_enabled_transfers) {
static int context_make_offline(Context **ret, const char *node, ReadDefinitionsFlags read_definitions_flags) {
_cleanup_(context_freep) Context* context = NULL;
int r;
@@ -938,7 +942,7 @@ static int context_make_offline(Context **ret, const char *node, bool requires_e
if (!context)
return log_oom();
r = context_read_definitions(context, node, requires_enabled_transfers);
r = context_read_definitions(context, node, read_definitions_flags);
if (r < 0)
return r;
@@ -959,7 +963,7 @@ static int context_make_online(Context **ret, const char *node) {
/* Like context_make_offline(), but also communicates with the update source looking for new
* versions (as long as --offline is not specified on the command line). */
r = context_make_offline(&context, node, /* requires_enabled_transfers= */ true);
r = context_make_offline(&context, node, READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS);
if (r < 0)
return r;
@@ -1365,7 +1369,7 @@ static int verb_features(int argc, char *argv[], uintptr_t _data, void *userdata
if (r < 0)
return r;
r = context_make_offline(&context, loop_device ? loop_device->node : NULL, /* requires_enabled_transfers= */ false);
r = context_make_offline(&context, loop_device ? loop_device->node : NULL, 0);
if (r < 0)
return r;
@@ -1633,7 +1637,7 @@ static int verb_vacuum(int argc, char *argv[], uintptr_t _data, void *userdata)
if (r < 0)
return r;
r = context_make_offline(&context, loop_device ? loop_device->node : NULL, /* requires_enabled_transfers= */ false);
r = context_make_offline(&context, loop_device ? loop_device->node : NULL, 0);
if (r < 0)
return r;
@@ -1655,7 +1659,7 @@ static int verb_pending_or_reboot(int argc, char *argv[], uintptr_t _data, void
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"The --root=/--image= switches may not be combined with the '%s' operation.", argv[0]);
r = context_make_offline(&context, /* node= */ NULL, /* requires_enabled_transfers= */ true);
r = context_make_offline(&context, /* node= */ NULL, READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS);
if (r < 0)
return r;