[libvirt] [PATCHv2] Remove redundant virFileIsExecutable check

Radostin Stoyanov posted 1 patch 6 years ago
Failed in applying to current master (apply log)
src/bhyve/bhyve_capabilities.c | 4 ----
src/qemu/qemu_capabilities.c   | 2 +-
2 files changed, 1 insertion(+), 5 deletions(-)
[libvirt] [PATCHv2] Remove redundant virFileIsExecutable check
Posted by Radostin Stoyanov 6 years ago
Remove unnecessary virFileIsExecutable check after virFindFileInPath.
Since commit 9ae992f, virFindFileInPath will reject non-executables.

9ae992f24353d6506f570fc9dd58355b165e4472
virFindFileInPath: only find executable non-directory

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 src/bhyve/bhyve_capabilities.c | 4 ----
 src/qemu/qemu_capabilities.c   | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 381cc0de3..e13085b1d 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -179,8 +179,6 @@ virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
     binary = virFindFileInPath("grub-bhyve");
     if (binary == NULL)
         goto out;
-    if (!virFileIsExecutable(binary))
-        goto out;
 
     cmd = virCommandNew(binary);
     virCommandAddArg(cmd, "--help");
@@ -315,8 +313,6 @@ virBhyveProbeCaps(unsigned int *caps)
     binary = virFindFileInPath("bhyve");
     if (binary == NULL)
         goto out;
-    if (!virFileIsExecutable(binary))
-        goto out;
 
     if ((ret = bhyveProbeCapsRTC_UTC(caps, binary)))
         goto out;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 27180e850..13c6c85d8 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -653,7 +653,7 @@ virQEMUCapsFindBinary(const char *format,
 
     ret = virFindFileInPath(binary);
     VIR_FREE(binary);
-    if (ret && virFileIsExecutable(ret))
+    if (ret)
         goto out;
 
     VIR_FREE(ret);
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2] Remove redundant virFileIsExecutable check
Posted by Michal Privoznik 6 years ago
On 04/13/2018 09:34 AM, Radostin Stoyanov wrote:
> Remove unnecessary virFileIsExecutable check after virFindFileInPath.
> Since commit 9ae992f, virFindFileInPath will reject non-executables.
> 
> 9ae992f24353d6506f570fc9dd58355b165e4472
> virFindFileInPath: only find executable non-directory
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  src/bhyve/bhyve_capabilities.c | 4 ----
>  src/qemu/qemu_capabilities.c   | 2 +-
>  2 files changed, 1 insertion(+), 5 deletions(-)

I've already pushed your previous patch.

> 
> diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
> index 381cc0de3..e13085b1d 100644
> --- a/src/bhyve/bhyve_capabilities.c
> +++ b/src/bhyve/bhyve_capabilities.c
> @@ -179,8 +179,6 @@ virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
>      binary = virFindFileInPath("grub-bhyve");
>      if (binary == NULL)
>          goto out;
> -    if (!virFileIsExecutable(binary))
> -        goto out;
>  
>      cmd = virCommandNew(binary);
>      virCommandAddArg(cmd, "--help");
> @@ -315,8 +313,6 @@ virBhyveProbeCaps(unsigned int *caps)
>      binary = virFindFileInPath("bhyve");
>      if (binary == NULL)
>          goto out;
> -    if (!virFileIsExecutable(binary))
> -        goto out;
>  
>      if ((ret = bhyveProbeCapsRTC_UTC(caps, binary)))
>          goto out;
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 27180e850..13c6c85d8 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -653,7 +653,7 @@ virQEMUCapsFindBinary(const char *format,
>  
>      ret = virFindFileInPath(binary);
>      VIR_FREE(binary);
> -    if (ret && virFileIsExecutable(ret))
> +    if (ret)
>          goto out;
>  
>      VIR_FREE(ret);
> 

This whole function can be simplified. Just look at the diff I squashed in.

Michal

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