From: Lennart Poettering Date: Fri, 2 Dec 2022 09:48:47 +0000 (+0100) Subject: dissect: make returning of DissectedImage object optional X-Git-Tag: v254-rc1~748^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93a8a85be3585c6f011853dad2888e5d0d3159d6;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 76251b3a079..9cc8d431476 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;