]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: make returning of DissectedImage object optional
authorLennart Poettering <lennart@poettering.net>
Fri, 2 Dec 2022 09:48:47 +0000 (10:48 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 5 Apr 2023 18:48:25 +0000 (20:48 +0200)
Sometimes, we just want to validate if an image (or image policy) works,
hence let's make the returning optional.

src/shared/dissect-image.c

index 76251b3a07971cce984de9f151c3f6ff00cb274f..9cc8d4314768a75e491eabd95cc72018fb462b04 100644 (file)
@@ -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;