From: Wei Liu <wei.liu2@citrix.com>
To: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH 4/6] libxl: debug output for args and env when invoking hotplug script
Date: Tue, 14 Jun 2016 13:46:17 +0100 [thread overview]
Message-ID: <20160614124617.GK28116@citrix.com> (raw)
In-Reply-To: <22367.56304.226295.618349@mariner.uk.xensource.com>
On Tue, Jun 14, 2016 at 11:26:56AM +0100, Ian Jackson wrote:
> Wei Liu writes ("[PATCH 4/6] libxl: debug output for args and env when invoking hotplug script"):
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ...
> > + const char *arg;
> > + unsigned int x = 2;
> > +
> > + arg = args[x];
> > + while (arg) {
> > + LOG(DEBUG, "\t%s", arg);
> > + x++;
> > + arg = args[x];
> > + }
I will use
>
> What a strange way to write
>
> for (x=2; (arg = args[x]); x++) {
>
This style.
> or
>
> for (x=2; (arg = args[x++]); ) {
>
> or
>
> x = 2;
> while ((arg = args[x++])) {
>
> If you really insist on not doing assignment in the conditional (which
> IMO is a very usual C idiom) then you should avoid the repeated code
> with
>
> x = 2;
> for (;;) {
> arg = args[x++];
> if (!arg) break;
>
> or some such.
>
> > + const char *k, *v;
> > + unsigned int x = 0;
> > +
> > + k = env[x];
> > + while (k) {
> > + v = env[x+1];
> > + LOG(DEBUG, "\t%s: %s", k, v);
> > + x += 2;
> > + k = env[x];
> > + }
>
> How about one of
>
> for (x=0; (k = env[x]); x += 2) {
> v = env[x+1];
>
And this style.
---8<---
From 49714976c5fde3d08baa6f34295b3f7db6a81444 Mon Sep 17 00:00:00 2001
From: Wei Liu <wei.liu2@citrix.com>
Date: Fri, 15 Apr 2016 12:56:03 +0100
Subject: [PATCH] libxl: debug output for args and env when invoking hotplug
script
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v2: write the loops differently.
---
tools/libxl/libxl_device.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 4717027..b3213be 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -1167,6 +1167,24 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
}
LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
+ LOG(DEBUG, "extra args:");
+ {
+ const char *arg;
+ unsigned int x;
+
+ for (x = 2; (arg = args[x]); x++)
+ LOG(DEBUG, "\t%s", arg);
+ }
+ LOG(DEBUG, "env:");
+ {
+ const char *k, *v;
+ unsigned int x;
+
+ for (x = 0; (k = env[x]); x += 2) {
+ v = env[x+1];
+ LOG(DEBUG, "\t%s: %s", k, v);
+ }
+ }
nullfd = open("/dev/null", O_RDONLY);
if (nullfd < 0) {
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-14 12:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 10:52 [PATCH 0/6] xl/libxl: some cleanup / debugging aid patches Wei Liu
2016-06-06 10:52 ` [PATCH 1/6] xl: remus/colo: only initialise ha variable when necessary Wei Liu
2016-06-14 10:18 ` Ian Jackson
2016-06-14 10:23 ` Wei Liu
2016-06-14 14:15 ` Ian Jackson
2016-06-14 14:18 ` Wei Liu
2016-06-06 10:52 ` [PATCH 2/6] libxl: add emacs block to libxl_linux.c Wei Liu
2016-06-14 10:19 ` Ian Jackson
2016-06-06 10:52 ` [PATCH 3/6] libxl: linux hotplug: clean up get_hotplug_env Wei Liu
2016-06-14 10:20 ` Ian Jackson
2016-06-06 10:52 ` [PATCH 4/6] libxl: debug output for args and env when invoking hotplug script Wei Liu
2016-06-14 10:26 ` Ian Jackson
2016-06-14 12:46 ` Wei Liu [this message]
2016-07-02 10:21 ` Wei Liu
2016-07-04 17:06 ` Ian Jackson
2016-07-06 17:23 ` Wei Liu
2016-06-06 10:52 ` [PATCH 5/6] libxl: rename a field in libxl__domain_create_state Wei Liu
2016-06-14 10:27 ` Ian Jackson
2016-06-06 10:52 ` [PATCH 6/6] libxl: log file name in failure in libxl__create_qemu_logfile Wei Liu
2016-06-14 10:28 ` Ian Jackson
2016-06-14 13:10 ` [PATCH 0/6] xl/libxl: some cleanup / debugging aid patches Wei Liu
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=20160614124617.GK28116@citrix.com \
--to=wei.liu2@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).