[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 2/2] xl: fixes for do_daemonize



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@xxxxxxxxxx>
> Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>

Looks plausibly like it will fix the identified issues.

Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

> ---
>  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@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.