Skip to contentSkip to conversation

tools/xl: fix for dead code in list_domains_details()

PATCH In review Roger Pau Monne 3 participants 3 messages Oct 20, 2025 – Oct 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/xl: fix for dead code in list_domains_details()

Commit d0193c6d6716 introduced checking for the return value of printf_info_one_json(), but failed to remove a further check down, which now Coverity complains is dead code.

The correct fix is to make the call to json_object_array_add() conditional on printf_info_one_json() having been successful, so that the further call to libxl_domain_config_dispose() is not avoided.

CID: 1667251

Fixes d0193c6d6716 ("tools/xl: check return value of printf_info_one_json() in list_domains_details()")

---
As with previous fixes, needs to be considered for 4.21.

---
 tools/xl/xl_info.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/xl/xl_info.c +2 -3
index dbb682cc52a6..98fc879e636c 100644
@@ -584,9 +584,8 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain)
 #ifdef HAVE_LIBJSONC
             json_object *jso_value;
             rc = printf_info_one_json(&jso_value, info[i].domid, &d_config);
-            if (rc)
-                goto out;
-            json_object_array_add(jso, jso_value);
+            if (!rc)
+                json_object_array_add(jso, jso_value);
 #elif defined(HAVE_LIBYAJL)
             s = printf_info_one_json(hand, info[i].domid, &d_config);
 #endif
Signature · 1 line
2.51.0
#1 lore raw
Quoted 8 lines · Roger Pau Monne

Commit d0193c6d6716 introduced checking for the return value of printf_info_one_json(), but failed to remove a further check down, which now Coverity complains is dead code.

The correct fix is to make the call to json_object_array_add() conditional on printf_info_one_json() having been successful, so that the further call to libxl_domain_config_dispose() is not avoided.

Quoted 5 lines

CID: 1667251

Fixes d0193c6d6716 ("tools/xl: check return value of printf_info_one_json() in list_domains_details()")

---
As with previous fixes, needs to be considered for 4.21.

Thanks.

~ Oleksii

Quoted 20 lines
---
  tools/xl/xl_info.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
tools/xl/xl_info.c +2 -3
index dbb682cc52a6..98fc879e636c 100644
@@ -584,9 +584,8 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain)
  #ifdef HAVE_LIBJSONC
              json_object *jso_value;
              rc = printf_info_one_json(&jso_value, info[i].domid, &d_config);
-            if (rc)
-                goto out;
-            json_object_array_add(jso, jso_value);
+            if (!rc)
+                json_object_array_add(jso, jso_value);
  #elif defined(HAVE_LIBYAJL)
              s = printf_info_one_json(hand, info[i].domid, &d_config);
  #endif
Reviewed-by on v1 1/1
#2 lore raw
In reply to Roger Pau Monne
Quoted 11 lines · Roger Pau Monne

Commit d0193c6d6716 introduced checking for the return value of printf_info_one_json(), but failed to remove a further check down, which now Coverity complains is dead code.

The correct fix is to make the call to json_object_array_add() conditional on printf_info_one_json() having been successful, so that the further call to libxl_domain_config_dispose() is not avoided.

CID: 1667251

Fixes d0193c6d6716 ("tools/xl: check return value of printf_info_one_json() in list_domains_details()")

Thanks,

Signature · 1 line
Anthony PERARD