summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-02 10:48:47 +0100
committerLennart Poettering <lennart@poettering.net>2023-04-05 20:48:25 +0200
commit93a8a85be3585c6f011853dad2888e5d0d3159d6 (patch)
tree3938eca33e7c17dc947401c5b171b2734db346b6 /src/shared
parentdissect: add dissect_image_file_and_warn() (diff)
downloadsystemd-93a8a85be3585c6f011853dad2888e5d0d3159d6.tar.xz
systemd-93a8a85be3585c6f011853dad2888e5d0d3159d6.zip
dissect: make returning of DissectedImage object optional
Sometimes, we just want to validate if an image (or image policy) works, hence let's make the returning optional.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/dissect-image.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index 76251b3a07..9cc8d43147 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -1535,7 +1535,6 @@ int dissect_image_file(
int r;
assert(path);
- assert(ret);
fd = open(path, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (fd < 0)
@@ -1557,7 +1556,8 @@ int dissect_image_file(
if (r < 0)
return r;
- *ret = TAKE_PTR(m);
+ if (ret)
+ *ret = TAKE_PTR(m);
return 0;
#else
return -EOPNOTSUPP;
@@ -3514,7 +3514,6 @@ int dissect_loop_device(
int r;
assert(loop);
- assert(ret);
r = dissected_image_new(loop->backing_file ?: loop->node, &m);
if (r < 0)
@@ -3527,7 +3526,9 @@ int dissect_loop_device(
if (r < 0)
return r;
- *ret = TAKE_PTR(m);
+ if (ret)
+ *ret = TAKE_PTR(m);
+
return 0;
#else
return -EOPNOTSUPP;