diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index 420ddb59c0..30b4819eb3 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -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_; diff --git a/src/basic/unit-def.h b/src/basic/unit-def.h index 7742c5c078..508b4c504d 100644 --- a/src/basic/unit-def.h +++ b/src/basic/unit-def.h @@ -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 { diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 2b8b833fe3..6652c212f1 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -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; diff --git a/src/libsystemd-network/dhcp-identifier.h b/src/libsystemd-network/dhcp-identifier.h index e9f2ea7e95..1d9a9c55ba 100644 --- a/src/libsystemd-network/dhcp-identifier.h +++ b/src/libsystemd-network/dhcp-identifier.h @@ -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: diff --git a/src/portable/portable.h b/src/portable/portable.h index 724634feb8..291d9377ef 100644 --- a/src/portable/portable.h +++ b/src/portable/portable.h @@ -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 { diff --git a/src/resolve/resolved-dnstls-openssl.c b/src/resolve/resolved-dnstls-openssl.c index defddb5237..17af90d4cc 100644 --- a/src/resolve/resolved-dnstls-openssl.c +++ b/src/resolve/resolved-dnstls-openssl.c @@ -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; diff --git a/src/shared/bridge-util.h b/src/shared/bridge-util.h index c9b02d822f..a60891c8f0 100644 --- a/src/shared/bridge-util.h +++ b/src/shared/bridge-util.h @@ -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_; diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 2ce507aa1c..61d264b953 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -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; } diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index 1557086079..031ca4cb4c 100644 --- a/src/shared/exec-util.c +++ b/src/shared/exec-util.c @@ -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) - ret_flags |= ex_flag; - else - return -EINVAL; + if (ex_flag < 0) + return ex_flag; + ret_flags |= ex_flag; } *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); diff --git a/src/shared/exec-util.h b/src/shared/exec-util.h index 5bd4a3785f..9ce5324de9 100644 --- a/src/shared/exec-util.h +++ b/src/shared/exec-util.h @@ -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( diff --git a/src/shared/install.h b/src/shared/install.h index 7d7a2c9f27..232184de33 100644 --- a/src/shared/install.h +++ b/src/shared/install.h @@ -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 { diff --git a/src/shared/resolve-util.h b/src/shared/resolve-util.h index 0f6e88e095..c4d9275368 100644 --- a/src/shared/resolve-util.h +++ b/src/shared/resolve-util.h @@ -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;