From: Andrew Cooper <andrew.cooper3@citrix.com>
To: xen-devel@lists.xen.org, p.d@gmx.de,
Ian Campbell <ian.campbell@citrix.com>
Subject: Re: Errors in compilation // xl_cmdimpl.c:2733:11 ...
Date: Fri, 24 Aug 2012 19:42:25 +0100 [thread overview]
Message-ID: <5037CB11.9000308@citrix.com> (raw)
In-Reply-To: <20120824164301.46800@gmx.net>
[-- Attachment #1: Type: text/plain, Size: 2163 bytes --]
On 24/08/12 17:43, p.d@gmx.de wrote:
> nice time,
>
> Ian, I'm not sure, but I think after Your patch:
> http://xenbits.xen.org/hg/xen-unstable.hg/rev/4ca40e0559c3
>
> xen-tools (+qemu+seabios) will not be maked :)
>
> Here are last lines of "make -j7":
> ==============================================================
> gcc -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -D__XEN_TOOLS__ -MMD -MF ._libxl_save_msgs_callout.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -Werror -Wno-format-zero-length -Wmissing-declarations -Wno-declaration-after-statement -Wformat-nonliteral -I. -fPIC -pthread -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/libxc -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/include -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/libxc -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/include -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/xenstore -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/include -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/blktap2/control -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/blktap2/include -I/usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/include -include /usr/src/xen_2012_08_24_rev_25779/tools/libxl/../../tools/config.h -c -o _libxl_save_msgs_callout.o _libxl_save_msgs_callout.c
> xl_cmdimpl.c: In function ‘main_list’:
> xl_cmdimpl.c:2733:11: error: ‘hand’ may be used uninitialized in this function [-Werror=uninitialized]
> xl_cmdimpl.c:2689:14: note: ‘hand’ was declared here
> <snip>
Please try the attached patch. I have fixed the error, and also
future-proofed the logic.
@Ian: the patch can be slimed down if default_output_format can be
guaranteed not to change across the duration of this function call, but
my cursory glance at this otherwise-unfamilar codebase cant say for certain.
--
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com
[-- Attachment #2: fix-cmdimpl.patch --]
[-- Type: text/x-patch, Size: 2533 bytes --]
# HG changeset patch
# Parent 4ca40e0559c33205fb5163b10249a0fd5fda39b9
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>
diff -r 4ca40e0559c3 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2686,12 +2686,13 @@ static void list_domains_details(const l
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;
-
- if (default_output_format == OUTPUT_FORMAT_JSON) {
+ const enum output_format format = default_output_format;
+
+ if (format == OUTPUT_FORMAT_JSON) {
hand = libxl_yajl_gen_alloc(NULL);
if (!hand) {
fprintf(stderr, "unable to allocate JSON generator\n");
@@ -2714,10 +2715,10 @@ static void list_domains_details(const l
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)
+ if (format == OUTPUT_FORMAT_JSON)
+ s = printf_info_one_json(hand, info[i].domid, &d_config);
+ else
printf_info_sexp(domid, &d_config);
- else
- s = printf_info_one_json(hand, info[i].domid, &d_config);
libxl_domain_config_dispose(&d_config);
free(data);
free(config_source);
@@ -2725,7 +2726,7 @@ static void list_domains_details(const l
goto out;
}
- if (default_output_format == OUTPUT_FORMAT_JSON) {
+ if (format == OUTPUT_FORMAT_JSON) {
s = yajl_gen_array_close(hand);
if (s != yajl_gen_status_ok)
goto out;
@@ -2738,7 +2739,7 @@ static void list_domains_details(const l
}
out:
- if (default_output_format == OUTPUT_FORMAT_JSON) {
+ if (format == OUTPUT_FORMAT_JSON) {
yajl_gen_free(hand);
if (s != yajl_gen_status_ok)
fprintf(stderr,
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2012-08-24 18:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 16:43 Errors in compilation // xl_cmdimpl.c:2733:11 p.d
2012-08-24 18:42 ` Andrew Cooper [this message]
2012-08-24 19:12 ` Ian Campbell
2012-08-24 19:23 ` Andrew Cooper
2012-08-24 21:46 ` p.d
2012-08-28 14:00 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5037CB11.9000308@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=p.d@gmx.de \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.