Re: [libvirt] [PATCH] Fix uses of virFileMakePath.

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

 



On Wed, Jan 20, 2010 at 02:32:36AM -0500, Laine Stump wrote:
> When I modified the use of virFileMakePath in my own code, I noticed
> that it was checking for a return < 0 to indicate error, but I had
> seen in virFileMakePath that it returns 0 for success, or the value of
> errno on failure, and errno is usually (always?) >=0. Seeing incorrect
> usage in one place, I investigated and found several others.
> ---
>  src/lxc/lxc_container.c     |   10 +++++-----
>  src/lxc/lxc_controller.c    |    2 +-
>  src/lxc/lxc_driver.c        |    2 +-
>  src/network/bridge_driver.c |    4 ++--
>  src/qemu/qemu_driver.c      |    8 ++++----
>  src/uml/uml_driver.c        |    4 ++--
>  6 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 023d553..539a1f4 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -317,7 +317,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
>          goto err;
>      }
>  
> -    if ((rc = virFileMakePath(oldroot)) < 0) {
> +    if ((rc = virFileMakePath(oldroot)) != 0) {
>          virReportSystemError(NULL, rc,
>                               _("Failed to create %s"),
>                               oldroot);
> @@ -339,7 +339,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
>          goto err;
>      }
>  
> -    if ((rc = virFileMakePath(newroot)) < 0) {
> +    if ((rc = virFileMakePath(newroot)) != 0) {
>          virReportSystemError(NULL, rc,
>                               _("Failed to create %s"),
>                               newroot);
> @@ -407,7 +407,7 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root)
>      }
>  
>      for (i = 0 ; i < ARRAY_CARDINALITY(mnts) ; i++) {
> -        if (virFileMakePath(mnts[i].dst) < 0) {
> +        if (virFileMakePath(mnts[i].dst) != 0) {
>              virReportSystemError(NULL, errno,
>                                   _("Failed to mkdir %s"),
>                                   mnts[i].src);
> @@ -421,7 +421,7 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root)
>          }
>      }
>  
> -    if ((rc = virFileMakePath("/dev/pts") < 0)) {
> +    if ((rc = virFileMakePath("/dev/pts") != 0)) {
>          virReportSystemError(NULL, rc, "%s",
>                               _("Cannot create /dev/pts"));
>          goto cleanup;
> @@ -510,7 +510,7 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef)
>              return -1;
>          }
>  
> -        if (virFileMakePath(vmDef->fss[i]->dst) < 0) {
> +        if (virFileMakePath(vmDef->fss[i]->dst) != 0) {
>              virReportSystemError(NULL, errno,
>                                   _("Failed to create %s"),
>                                   vmDef->fss[i]->dst);
> diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> index 3cecdce..6304815 100644
> --- a/src/lxc/lxc_controller.c
> +++ b/src/lxc/lxc_controller.c
> @@ -556,7 +556,7 @@ lxcControllerRun(virDomainDefPtr def,
>              goto cleanup;
>          }
>  
> -        if (virFileMakePath(devpts) < 0) {
> +        if (virFileMakePath(devpts) != 0) {
>              virReportSystemError(NULL, errno,
>                                   _("Failed to make path %s"),
>                                   devpts);
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index ec5ee6b..d78f7f7 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -1193,7 +1193,7 @@ static int lxcVmStart(virConnectPtr conn,
>      char **veths = NULL;
>      lxcDomainObjPrivatePtr priv = vm->privateData;
>  
> -    if ((r = virFileMakePath(driver->logDir)) < 0) {
> +    if ((r = virFileMakePath(driver->logDir)) != 0) {
>          virReportSystemError(conn, r,
>                               _("Cannot create log directory '%s'"),
>                               driver->logDir);
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 4385215..08e5ee6 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -539,13 +539,13 @@ dhcpStartDhcpDaemon(virConnectPtr conn,
>          return -1;
>      }
>  
> -    if ((err = virFileMakePath(NETWORK_PID_DIR)) < 0) {
> +    if ((err = virFileMakePath(NETWORK_PID_DIR)) != 0) {
>          virReportSystemError(conn, err,
>                               _("cannot create directory %s"),
>                               NETWORK_PID_DIR);
>          return -1;
>      }
> -    if ((err = virFileMakePath(NETWORK_STATE_DIR)) < 0) {
> +    if ((err = virFileMakePath(NETWORK_STATE_DIR)) != 0) {
>          virReportSystemError(conn, err,
>                               _("cannot create directory %s"),
>                               NETWORK_STATE_DIR);
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 951e033..fa2e5d3 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -1033,19 +1033,19 @@ qemudStartup(int privileged) {
>              goto out_of_memory;
>      }
>  
> -    if (virFileMakePath(qemu_driver->stateDir) < 0) {
> +    if (virFileMakePath(qemu_driver->stateDir) != 0) {
>          char ebuf[1024];
>          VIR_ERROR(_("Failed to create state dir '%s': %s"),
>                    qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
>          goto error;
>      }
> -    if (virFileMakePath(qemu_driver->libDir) < 0) {
> +    if (virFileMakePath(qemu_driver->libDir) != 0) {
>          char ebuf[1024];
>          VIR_ERROR(_("Failed to create lib dir '%s': %s"),
>                    qemu_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
>          goto error;
>      }
> -    if (virFileMakePath(qemu_driver->cacheDir) < 0) {
> +    if (virFileMakePath(qemu_driver->cacheDir) != 0) {
>          char ebuf[1024];
>          VIR_ERROR(_("Failed to create cache dir '%s': %s"),
>                    qemu_driver->cacheDir, virStrerror(errno, ebuf, sizeof ebuf));
> @@ -2782,7 +2782,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
>          vm->def->graphics[0]->data.vnc.port = port;
>      }
>  
> -    if (virFileMakePath(driver->logDir) < 0) {
> +    if (virFileMakePath(driver->logDir) != 0) {
>          virReportSystemError(conn, errno,
>                               _("cannot create log directory %s"),
>                               driver->logDir);
> diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
> index b808090..31cea5c 100644
> --- a/src/uml/uml_driver.c
> +++ b/src/uml/uml_driver.c
> @@ -419,7 +419,7 @@ umlStartup(int privileged) {
>          goto error;
>      }
>  
> -    if (virFileMakePath(uml_driver->monitorDir) < 0) {
> +    if (virFileMakePath(uml_driver->monitorDir) != 0) {
>          char ebuf[1024];
>          VIR_ERROR(_("Failed to create monitor directory %s: %s"),
>                 uml_driver->monitorDir, virStrerror(errno, ebuf, sizeof ebuf));
> @@ -840,7 +840,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
>          return -1;
>      }
>  
> -    if (virFileMakePath(driver->logDir) < 0) {
> +    if (virFileMakePath(driver->logDir) != 0) {
>          virReportSystemError(conn, errno,
>                               _("cannot create log directory %s"),
>                               driver->logDir);

  Ah, right !!!

   ACK

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]