[gnome-commander] src/plugin_manager.cc: use return val of chdir



commit c330a60e245a379aad530d9a82ebeb3e764b8667
Author: Mamoru TASAKA <mtasaka fedoraproject org>
Date:   Fri Apr 28 18:47:54 2017 +0900

    src/plugin_manager.cc: use return val of chdir
    
    src/plugin_manager.cc:158:11: error: ignoring return value of 'int chdir(const char*)', declared with 
attribute warn_unused_result [-Werror=unused-result]
    src/plugin_manager.cc:199:15: error: ignoring return value of 'int chdir(const char*)', declared with 
attribute warn_unused_result [-Werror=unused-result]

 src/plugin_manager.cc |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/plugin_manager.cc b/src/plugin_manager.cc
index 5f5f35c..974c97c 100644
--- a/src/plugin_manager.cc
+++ b/src/plugin_manager.cc
@@ -155,7 +155,11 @@ static void scan_plugins_in_dir (const gchar *dpath)
     }
 
     prev_dir = getcwd (buff, sizeof(buff));
-    chdir (dpath);
+    if (chdir (dpath))
+    {
+        g_warning ("Could not change directory to %s: %s", dpath, strerror (errno));
+        return;
+    }
 
     while ((ent = readdir (dir)) != NULL)
     {
@@ -196,7 +200,13 @@ static void scan_plugins_in_dir (const gchar *dpath)
     closedir (dir);
 
     if (prev_dir)
-        chdir (prev_dir);
+    {
+        if (chdir (prev_dir))
+        {
+            g_warning ("Could not change directory back to %s: %s", prev_dir, strerror (errno));
+            return;
+        }
+    }
 }
 
 


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