[PATCH 4/9] nodedev: Use access instead of stat

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

 



The use of 'stat' in nodeDeviceVportCreateDelete is only to check
if the file exists or not, it's a bit overkill, and safe to replace
with the wrapper of access(2) (virFileExists).
---
 src/node_device/node_device_driver.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 73b824f..51e8115 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -28,7 +28,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <time.h>
-#include <sys/stat.h>
 
 #include "virerror.h"
 #include "datatypes.h"
@@ -422,7 +421,6 @@ nodeDeviceVportCreateDelete(const int parent_host,
     int retval = 0;
     char *operation_path = NULL, *vport_name = NULL;
     const char *operation_file = NULL;
-    struct stat st;
 
     switch (operation) {
     case VPORT_CREATE:
@@ -450,7 +448,7 @@ nodeDeviceVportCreateDelete(const int parent_host,
         goto cleanup;
     }
 
-    if (stat(operation_path, &st) != 0) {
+    if (!virFileExists(operation_path)) {
         VIR_FREE(operation_path);
         if (virAsprintf(&operation_path,
                         "%shost%d%s",
@@ -462,7 +460,7 @@ nodeDeviceVportCreateDelete(const int parent_host,
             goto cleanup;
         }
 
-        if (stat(operation_path, &st) != 0) {
+        if (!virFileExists(operation_path)) {
             VIR_ERROR(_("No vport operation path found for host%d"),
                       parent_host);
             retval = -1;
-- 
1.7.7.6

--
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]