ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
Blob Blame History Raw
From 758503b1c24a43de5e0ad40c3e0299a4c5df0238 Mon Sep 17 00:00:00 2001
From: Jan Synacek <jsynacek@redhat.com>
Date: Tue, 14 Feb 2017 10:21:53 +0100
Subject: [PATCH] machinectl: make sure that inability to get OS version isn't
 consider fatal for machine list (#4972)

Fixes: #4918

(cherry picked from commit 4b2419165ce409ee55ce96a926302f89685f2293)

Resolves: https://bugzilla.redhat.com/1419501
---
 src/machine/machinectl.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index f84226f58f..2aab754406 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -242,24 +242,20 @@ static int list_machines(int argc, char *argv[], void *userdata) {
                 if (name[0] == '.' && !arg_all)
                         continue;
 
-                if (!GREEDY_REALLOC(machines, n_allocated, n_machines + 1)) {
+                if (!GREEDY_REALLOC0(machines, n_allocated, n_machines + 1)) {
                         r = log_oom();
                         goto out;
                 }
 
-                machines[n_machines].os = NULL;
-                machines[n_machines].version_id = NULL;
-                r = get_os_release_property(bus, name,
-                                "ID\0" "VERSION_ID\0",
-                                &machines[n_machines].os,
-                                &machines[n_machines].version_id);
-                if (r < 0)
-                        goto out;
-
                 machines[n_machines].name = name;
                 machines[n_machines].class = class;
                 machines[n_machines].service = service;
 
+                (void) get_os_release_property(bus, name,
+                                "ID\0" "VERSION_ID\0",
+                                &machines[n_machines].os,
+                                &machines[n_machines].version_id);
+
                 l = strlen(name);
                 if (l > max_name)
                         max_name = l;