tools/xl: fix for dead code in list_domains_details()
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
---
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
@@ -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
Quoted 8 lines · Roger Pau Monne
Commit
d0193c6d6716introduced checking for the return value ofprintf_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 onprintf_info_one_json()having been successful, so that the further call tolibxl_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()")Signed-off-by Roger Pau Monné<[email protected]>---
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@@ -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
Quoted 11 lines · Roger Pau Monne
Commit
d0193c6d6716introduced checking for the return value ofprintf_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 onprintf_info_one_json()having been successful, so that the further call tolibxl_domain_config_dispose()is not avoided.CID: 1667251
Fixes d0193c6d6716 ("tools/xl: check return value of printf_info_one_json() in list_domains_details()")Signed-off-by Roger Pau Monné <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD