]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/specifier: make sure we set the output variable even for void answers
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 11 Apr 2022 11:44:41 +0000 (13:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 11 Apr 2022 11:51:28 +0000 (13:51 +0200)
This doesn't change anything for real uses, because we'd initialize the
variable to NULL for _cleanup_ anyway, but let's follow our general pattern
of always setting the output on "success". (Even if that success is an empty
answer here.)

src/shared/specifier.c

index 16eb8830dc4865a34ba04015dab8ded2af993ec1..87b99d38bc64aefcd0bf21b779cbd83e092b04a7 100644 (file)
@@ -276,12 +276,18 @@ int specifier_architecture(char specifier, const void *data, const char *root, c
  * installation. */
 
 static int parse_os_release_specifier(const char *root, const char *id, char **ret) {
+        char *v = NULL;
         int r;
 
         assert(ret);
 
+        r = parse_os_release(root, id, &v);
+        if (r >= 0)
+                /* parse_os_release() calls parse_env_file() which only sets the return value for
+                 * entries found. Let's make sure we set the return value in all cases. */
+                *ret = v;
+
         /* Translate error for missing os-release file to EUNATCH. */
-        r = parse_os_release(root, id, ret);
         return r == -ENOENT ? -EUNATCH : r;
 }