summaryrefslogtreecommitdiffstats
path: root/src/machine/image-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-04-06 18:53:57 +0200
committerLennart Poettering <lennart@poettering.net>2018-05-24 17:01:57 +0200
commit3a6ce860ac3e3c549e92f5f3254d1934dc543c24 (patch)
tree94e809ef8e5d6e72ff51a8101e3d45f207e84d95 /src/machine/image-dbus.c
parentmachine-image: use pretty names if we already have them and validated them (diff)
downloadsystemd-3a6ce860ac3e3c549e92f5f3254d1934dc543c24.tar.xz
systemd-3a6ce860ac3e3c549e92f5f3254d1934dc543c24.zip
machine-image: rework error handling
Let's rework error handling a bit in image_find() and friends: when we can't find an image, return -ENOENT rather than 0. That's better as before we violated the usual rule in our codebase that return parameters are initialized when the return value is >= 0 and otherwise not touched. This also makes enumeration and validation a bit more strict: we'll only accept ".raw" as suffix for regular files, and filter out this suffix handling on directories/subvolumes, where it makes no sense.
Diffstat (limited to 'src/machine/image-dbus.c')
-rw-r--r--src/machine/image-dbus.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/machine/image-dbus.c b/src/machine/image-dbus.c
index ae5aa30a90..d2f5dc4593 100644
--- a/src/machine/image-dbus.c
+++ b/src/machine/image-dbus.c
@@ -436,7 +436,9 @@ int image_object_find(sd_bus *bus, const char *path, const char *interface, void
return r;
r = image_find(IMAGE_MACHINE, e, &image);
- if (r <= 0)
+ if (r == -ENOENT)
+ return 0;
+ if (r < 0)
return r;
image->userdata = m;