[PATCH] utils: drop useless g_file_test() call

Mikhail Efremov sem at altlinux.org
Wed Apr 12 16:32:34 UTC 2017


canonicalize_file_name() returns NULL if file doesn't exist,
so no need to check file existence with g_file_test().
---
 src/libqmi-glib/qmi-utils.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libqmi-glib/qmi-utils.c b/src/libqmi-glib/qmi-utils.c
index 29e5f22..5d399a6 100644
--- a/src/libqmi-glib/qmi-utils.c
+++ b/src/libqmi-glib/qmi-utils.c
@@ -743,8 +743,10 @@ __qmi_utils_get_driver (const gchar *cdc_wdm_path)
         path = canonicalize_file_name (tmp);
         g_free (tmp);
 
-        if (g_file_test (path, G_FILE_TEST_EXISTS))
-            driver = g_path_get_basename (path);
+        if (!path)
+            continue;
+
+        driver = g_path_get_basename (path);
         g_free (path);
     }
 
-- 
2.10.2



More information about the libqmi-devel mailing list