diff options
author | Andrew Cooper <andrew.cooper3@citrix.com> | 2012-08-28 14:46:30 +0100 |
---|---|---|
committer | Andrew Cooper <andrew.cooper3@citrix.com> | 2012-08-28 14:46:30 +0100 |
commit | efbb5c54110baf958e2ae5681e08eb25aa26c62d (patch) | |
tree | 7ae76b9addd0c0df0e50f1c081494150a438c254 /tools/libxl | |
parent | 37d7ccdc2f50d659f1eb8ec11ee4bf8a8376926d (diff) | |
download | xen-efbb5c54110baf958e2ae5681e08eb25aa26c62d.tar.gz xen-efbb5c54110baf958e2ae5681e08eb25aa26c62d.tar.bz2 xen-efbb5c54110baf958e2ae5681e08eb25aa26c62d.zip |
tools/xl: Fix uninitialized variable error.
c/s 25779:4ca40e0559c3 introduced a compilation error for any build
system using -Werror=uninitialized, such as the default CentOS 5.7
version of gcc.
And with good reason, because if the global libxl
default_output_format is neither OUTPUT_FORMAT_SXP nor
OUTPUT_FORMAT_JSON, the variable hand will be used before being
initialised.
The attached patch fixes the warning, and futher fixes the logic to
work correctly when a new OUTPUT_FORMAT is added to xl.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl')
-rw-r--r-- | tools/libxl/xl_cmdimpl.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index e825897b43..dfdb5ffc82 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2686,7 +2686,7 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain) uint8_t *data; int i, len, rc; - yajl_gen hand; + yajl_gen hand = NULL; yajl_gen_status s; const char *buf; libxl_yajl_length yajl_len = 0; @@ -2714,10 +2714,10 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain) CHK_ERRNO(asprintf(&config_source, "<domid %d data>", info[i].domid)); libxl_domain_config_init(&d_config); parse_config_data(config_source, (char *)data, len, &d_config, NULL); - if (default_output_format == OUTPUT_FORMAT_SXP) - printf_info_sexp(domid, &d_config); - else + if (default_output_format == OUTPUT_FORMAT_JSON) s = printf_info_one_json(hand, info[i].domid, &d_config); + else + printf_info_sexp(domid, &d_config); libxl_domain_config_dispose(&d_config); free(data); free(config_source); |