1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

Merge pull request #18641 from benjarobin/fix-enum-invalid-val

Various follow-up: Fix build and EINVAL for _INVALID enum value
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-02-17 08:46:09 +01:00 committed by GitHub
commit 4c1ff29052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 19 additions and 17 deletions

View File

@ -297,7 +297,7 @@ typedef enum ManagedOOMPreference {
MANAGED_OOM_PREFERENCE_AVOID = 1,
MANAGED_OOM_PREFERENCE_OMIT = 2,
_MANAGED_OOM_PREFERENCE_MAX,
_MANAGED_OOM_PREFERENCE_INVALID = -1
_MANAGED_OOM_PREFERENCE_INVALID = -EINVAL,
} ManagedOOMPreference;
const char* managed_oom_preference_to_string(ManagedOOMPreference a) _const_;

View File

@ -62,7 +62,7 @@ typedef enum UnitMarker {
UNIT_MARKER_NEEDS_RELOAD,
UNIT_MARKER_NEEDS_RESTART,
_UNIT_MARKER_MAX,
_UNIT_MARKER_INVALID = -1
_UNIT_MARKER_INVALID = -EINVAL,
} UnitMarker;
typedef enum AutomountState {

View File

@ -1732,7 +1732,7 @@ int bus_cgroup_set_property(
p = managed_oom_preference_from_string(pref);
if (p < 0)
return -EINVAL;
return p;
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
c->moom_preference = p;

View File

@ -16,7 +16,7 @@ typedef enum DUIDType {
DUID_TYPE_LL = 3,
DUID_TYPE_UUID = 4,
_DUID_TYPE_MAX,
_DUID_TYPE_INVALID = -1,
_DUID_TYPE_INVALID = -EINVAL,
} DUIDType;
/* RFC 3315 section 9.1:

View File

@ -31,7 +31,7 @@ typedef enum PortableChangeType {
PORTABLE_WRITE,
PORTABLE_MKDIR,
_PORTABLE_CHANGE_TYPE_MAX,
_PORTABLE_CHANGE_TYPE_INVALID = INT_MIN,
_PORTABLE_CHANGE_TYPE_INVALID = -EINVAL,
} PortableChangeType;
typedef enum PortableState {

View File

@ -13,8 +13,8 @@
#include "resolved-dnstls.h"
#include "resolved-manager.h"
DEFINE_TRIVIAL_CLEANUP_FUNC(SSL*, SSL_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(BIO*, BIO_free);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(SSL*, SSL_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(BIO*, BIO_free, NULL);
static int dnstls_flush_write_buffer(DnsStream *stream) {
ssize_t ss;

View File

@ -13,7 +13,7 @@ typedef enum BridgeState {
NETDEV_BRIDGE_STATE_FORWARDING = BR_STATE_FORWARDING,
NETDEV_BRIDGE_STATE_BLOCKING = BR_STATE_BLOCKING,
_NETDEV_BRIDGE_STATE_MAX,
_NETDEV_BRIDGE_STATE_INVALID = -1,
_NETDEV_BRIDGE_STATE_INVALID = -EINVAL,
} BridgeState;
const char *bridge_state_to_string(BridgeState d) _const_;

View File

@ -2389,9 +2389,9 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un
/* We expect only "success" changes to be sent over the bus.
Hence, reject anything negative. */
UnitFileChangeType ch = unit_file_change_type_from_string(type);
if (ch < 0) {
log_notice("Manager reported unknown change type \"%s\" for path \"%s\", ignoring.", type, path);
log_notice_errno(ch, "Manager reported unknown change type \"%s\" for path \"%s\", ignoring.",
type, path);
continue;
}

View File

@ -375,10 +375,9 @@ int exec_command_flags_from_strv(char **ex_opts, ExecCommandFlags *flags) {
STRV_FOREACH(opt, ex_opts) {
ex_flag = exec_command_flags_from_string(*opt);
if (ex_flag >= 0)
if (ex_flag < 0)
return ex_flag;
ret_flags |= ex_flag;
else
return -EINVAL;
}
*flags = ret_flags;
@ -394,6 +393,9 @@ int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ex_opts) {
assert(ex_opts);
if (flags < 0)
return flags;
for (i = 0; it != 0; it &= ~(1 << i), i++) {
if (FLAGS_SET(flags, (1 << i))) {
str = exec_command_flags_to_string(1 << i);

View File

@ -27,7 +27,7 @@ typedef enum ExecCommandFlags {
EXEC_COMMAND_NO_SETUID = 1 << 2,
EXEC_COMMAND_AMBIENT_MAGIC = 1 << 3,
EXEC_COMMAND_NO_ENV_EXPAND = 1 << 4,
_EXEC_COMMAND_FLAGS_INVALID = -1,
_EXEC_COMMAND_FLAGS_INVALID = -EINVAL,
} ExecCommandFlags;
int execute_directories(

View File

@ -31,7 +31,7 @@ enum UnitFileChangeType {
UNIT_FILE_IS_MASKED,
UNIT_FILE_IS_DANGLING,
_UNIT_FILE_CHANGE_TYPE_MAX,
_UNIT_FILE_CHANGE_TYPE_INVALID = INT_MIN
_UNIT_FILE_CHANGE_TYPE_INVALID = -EINVAL,
};
enum UnitFileFlags {

View File

@ -15,7 +15,7 @@ enum DnsCacheMode {
DNS_CACHE_MODE_YES,
DNS_CACHE_MODE_NO_NEGATIVE,
_DNS_CACHE_MODE_MAX,
_DNS_CACHE_MODE_INVALID = 1
_DNS_CACHE_MODE_INVALID = -EINVAL,
};
typedef enum ResolveSupport ResolveSupport;