From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: xen-devel@lists.xenproject.org,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [PATCH 2/2] xl: fixes for do_daemonize
Date: Fri, 22 Nov 2013 12:00:29 +0000 [thread overview]
Message-ID: <528F475D.3080801@citrix.com> (raw)
In-Reply-To: <1385121249-10265-3-git-send-email-roger.pau@citrix.com>
On 22/11/13 11:54, Roger Pau Monne wrote:
> Fix usage of CHK_ERRNO in do_daemonize and also remove the usage of a
> bogus for(;;).
>
> Coverity-ID: 1130516 and 1130520
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
Looks plausibly like it will fix the identified issues.
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> tools/libxl/xl_cmdimpl.c | 15 +++++++--------
> 1 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 341863e..0f623a0 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -411,14 +411,14 @@ static int do_daemonize(char *name)
>
> child1 = xl_fork(child_waitdaemon);
> if (child1) {
> - for (;;) {
> - got_child = xl_waitpid(child_waitdaemon, &status, 0);
> - if (got_child == child1) break;
> + got_child = xl_waitpid(child_waitdaemon, &status, 0);
> + if (got_child != child1) {
> assert(got_child == -1);
> - perror("failed to wait for daemonizing child");
> + LOG("failed to wait for daemonizing child: %s", strerror(errno));
> ret = ERROR_FAIL;
> goto out;
> }
> +
> if (status) {
> libxl_report_child_exitstatus(ctx, XTL_ERROR,
> "daemonizing child", child1, status);
> @@ -437,16 +437,15 @@ static int do_daemonize(char *name)
> exit(-1);
> }
>
> - CHK_ERRNO(( logfile = open(fullname, O_WRONLY|O_CREAT|O_APPEND,
> - 0644) )<0);
> + CHK_ERRNO(logfile = open(fullname, O_WRONLY|O_CREAT|O_APPEND, 0644));
> free(fullname);
>
> - CHK_ERRNO(( nullfd = open("/dev/null", O_RDONLY) )<0);
> + CHK_ERRNO(nullfd = open("/dev/null", O_RDONLY));
> dup2(nullfd, 0);
> dup2(logfile, 1);
> dup2(logfile, 2);
>
> - CHK_ERRNO(daemon(0, 1) < 0);
> + CHK_ERRNO(daemon(0, 1));
>
> out:
> return ret;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-11-22 12:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 11:54 [PATCH 0/2] libxl/xl: two more coverity related fixes Roger Pau Monne
2013-11-22 11:54 ` [PATCH 1/2] libxl: fix fd check in libxl__spawn_local_dm Roger Pau Monne
2013-11-22 11:54 ` [PATCH 2/2] xl: fixes for do_daemonize Roger Pau Monne
2013-11-22 12:00 ` Andrew Cooper [this message]
2013-11-26 11:14 ` [PATCH 0/2] libxl/xl: two more coverity related fixes 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=528F475D.3080801@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=roger.pau@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 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.