]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: introduce UNIT_IS_LOAD_ERROR helper
authorMike Yuan <me@yhndnzj.com>
Sat, 23 Mar 2024 09:37:36 +0000 (17:37 +0800)
committerMike Yuan <me@yhndnzj.com>
Sat, 23 Mar 2024 17:08:40 +0000 (01:08 +0800)
src/core/mount.c
src/core/swap.c
src/core/unit.h

index f574e28ec474cc025ffdb2b8b6f097abc937b8ba..175af5498af37fffc62ca190ed475cae6bbdc806 100644 (file)
@@ -1778,7 +1778,7 @@ static int mount_setup_existing_unit(
 
         m->from_proc_self_mountinfo = true;
 
-        if (IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_BAD_SETTING, UNIT_ERROR)) {
+        if (UNIT_IS_LOAD_ERROR(u->load_state)) {
                 /* The unit was previously not found or otherwise not loaded. Now that the unit shows up in
                  * /proc/self/mountinfo we should reconsider it this, hence set it to UNIT_LOADED. */
                 u->load_state = UNIT_LOADED;
index 655f932f95a21af071e1ba9f268b23422ce65a02..9e200086f37817cd42cbb75eef383d520ef2d89b 100644 (file)
@@ -422,7 +422,7 @@ static int swap_setup_unit(
 
         /* The unit is definitely around now, mark it as loaded if it was previously referenced but
          * could not be loaded. After all we can load it now, from the data in /proc/swaps. */
-        if (IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_BAD_SETTING, UNIT_ERROR)) {
+        if (UNIT_IS_LOAD_ERROR(u->load_state)) {
                 u->load_state = UNIT_LOADED;
                 u->load_error = 0;
         }
index 7134d362fe11120bea2b4e0d8fbb353b5086c0a3..0cfd90b3d4c5a174a81379f92f7bae3cf617cd98 100644 (file)
@@ -67,6 +67,10 @@ static inline bool UNIT_IS_LOAD_COMPLETE(UnitLoadState t) {
         return t >= 0 && t < _UNIT_LOAD_STATE_MAX && t != UNIT_STUB && t != UNIT_MERGED;
 }
 
+static inline bool UNIT_IS_LOAD_ERROR(UnitLoadState t) {
+        return IN_SET(t, UNIT_NOT_FOUND, UNIT_BAD_SETTING, UNIT_ERROR);
+}
+
 /* Stores the 'reason' a dependency was created as a bit mask, i.e. due to which configuration source it came to be. We
  * use this so that we can selectively flush out parts of dependencies again. Note that the same dependency might be
  * created as a result of multiple "reasons", hence the bitmask. */