]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
discover-image: don't mix two types of stack allocation in one line 18459/head
authorLennart Poettering <lennart@poettering.net>
Wed, 3 Feb 2021 22:12:30 +0000 (23:12 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 3 Feb 2021 22:13:11 +0000 (23:13 +0100)
src/shared/discover-image.c

index 851d1edabb7d426d63a15748709cc78283fb5475..1f5e4c6f86b345b211f9bd0600418023a33d48c2 100644 (file)
@@ -1065,7 +1065,6 @@ int image_path_lock(const char *path, int operation, LockFile *global, LockFile
                         r = asprintf(&p, "/run/systemd/nspawn/locks/inode-%lu:%lu", (unsigned long) st.st_dev, (unsigned long) st.st_ino);
                 else
                         return -ENOTTY;
-
                 if (r < 0)
                         return -ENOMEM;
         }
@@ -1220,11 +1219,16 @@ int image_read_metadata(Image *i) {
 }
 
 int image_name_lock(const char *name, int operation, LockFile *ret) {
+        const char *p;
+
         assert(name);
         assert(ret);
 
         /* Locks an image name, regardless of the precise path used. */
 
+        if (streq(name, ".host"))
+                return -EBUSY;
+
         if (!image_name_is_valid(name))
                 return -EINVAL;
 
@@ -1233,11 +1237,9 @@ int image_name_lock(const char *name, int operation, LockFile *ret) {
                 return 0;
         }
 
-        if (streq(name, ".host"))
-                return -EBUSY;
-
-        const char *p = strjoina("/run/systemd/nspawn/locks/name-", name);
         (void) mkdir_p("/run/systemd/nspawn/locks", 0700);
+
+        p = strjoina("/run/systemd/nspawn/locks/name-", name);
         return make_lock_file(p, operation, ret);
 }