summaryrefslogtreecommitdiffstats
path: root/src/shared/discover-image.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-02-03 23:12:30 +0100
committerLennart Poettering <lennart@poettering.net>2021-02-03 23:13:11 +0100
commit99d97afcecc54be2749e87d8d82d5ccaf5acc9f8 (patch)
tree694864f1dd30e02eac7dfb586f5a2940b7388351 /src/shared/discover-image.c
parentshared: rename machine-image.[ch] → discover-image.[ch] (diff)
downloadsystemd-99d97afcecc54be2749e87d8d82d5ccaf5acc9f8.tar.xz
systemd-99d97afcecc54be2749e87d8d82d5ccaf5acc9f8.zip
discover-image: don't mix two types of stack allocation in one line
Diffstat (limited to '')
-rw-r--r--src/shared/discover-image.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c
index 851d1edabb..1f5e4c6f86 100644
--- a/src/shared/discover-image.c
+++ b/src/shared/discover-image.c
@@ -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);
}