]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
unit-def: ensure UnitType enum fits any errno value
authorLennart Poettering <lennart@poettering.net>
Mon, 10 May 2021 16:43:07 +0000 (18:43 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 11 May 2021 05:33:11 +0000 (14:33 +0900)
This is a follow-up for #19514 which changed unit_name_to_instance() to
return ENOMEM as a UnitType enum, even though the enum didn't
necessarily have range for that.

Let's extend the range explicitly, so that we can cover the full errno
range in it.

src/basic/unit-def.h

index 508b4c504da25e58bdf96323e56e84f7f51cf2d8..c30135f4d6c73c5a467ddd98d834bedbc7c8c285 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <stdbool.h>
 
+#include "errno-list.h"
 #include "locale-util.h"
 #include "macro.h"
 
@@ -23,6 +24,7 @@ typedef enum UnitType {
         UNIT_SCOPE,
         _UNIT_TYPE_MAX,
         _UNIT_TYPE_INVALID = -EINVAL,
+        _UNIT_TYPE_ERRNO_MAX = -ERRNO_MAX, /* Ensure the whole errno range fits into this enum */
 } UnitType;
 
 typedef enum UnitLoadState {