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

Re: [libvirt] [PATCH 3/3] LXC cleanup deep indentation in lxcDomainSetAutostart



On Thu, Nov 05, 2009 at 02:19:14AM +0900, Ryota Ozaki wrote:
> ---
>  src/lxc/lxc_driver.c |   61 +++++++++++++++++++++++++++----------------------
>  1 files changed, 34 insertions(+), 27 deletions(-)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index 9f20d05..a917a46 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -1992,39 +1992,46 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
>  
>      autostart = (autostart != 0);
>  
> -    if (vm->autostart != autostart) {
> -        if ((configFile = virDomainConfigFile(dom->conn, driver->configDir, vm->def->name)) == NULL)
> -            goto cleanup;
> -        if ((autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, vm->def->name)) == NULL)
> -            goto cleanup;
> +    if (vm->autostart == autostart) {
> +        ret = 0;
> +        goto cleanup;
> +    }
>  
> -        if (autostart) {
> -            int err;
> +    configFile = virDomainConfigFile(dom->conn, driver->configDir,
> +                                     vm->def->name);
> +    if (configFile == NULL)
> +        goto cleanup;
> +    autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir,
> +                                        vm->def->name);
> +    if (autostartLink == NULL)
> +        goto cleanup;
>  
> -            if ((err = virFileMakePath(driver->autostartDir))) {
> -                virReportSystemError(dom->conn, err,
> -                                     _("Cannot create autostart directory %s"),
> -                                     driver->autostartDir);
> -                goto cleanup;
> -            }
> +    if (autostart) {
> +        int err;
>  
> -            if (symlink(configFile, autostartLink) < 0) {
> -                virReportSystemError(dom->conn, errno,
> -                                     _("Failed to create symlink '%s to '%s'"),
> -                                     autostartLink, configFile);
> -                goto cleanup;
> -            }
> -        } else {
> -            if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
> -                virReportSystemError(dom->conn, errno,
> -                                     _("Failed to delete symlink '%s'"),
> -                                     autostartLink);
> -                goto cleanup;
> -            }
> +        if ((err = virFileMakePath(driver->autostartDir))) {
> +            virReportSystemError(dom->conn, err,
> +                                 _("Cannot create autostart directory %s"),
> +                                 driver->autostartDir);
> +            goto cleanup;
>          }
>  
> -        vm->autostart = autostart;
> +        if (symlink(configFile, autostartLink) < 0) {
> +            virReportSystemError(dom->conn, errno,
> +                                 _("Failed to create symlink '%s to '%s'"),
> +                                 autostartLink, configFile);
> +            goto cleanup;
> +        }
> +    } else {
> +        if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
> +            virReportSystemError(dom->conn, errno,
> +                                 _("Failed to delete symlink '%s'"),
> +                                 autostartLink);
> +            goto cleanup;
> +        }
>      }
> +
> +    vm->autostart = autostart;
>      ret = 0;
>  
>  cleanup:

ACK

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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