chiark / gitweb /
condition: unify condition logic in one file
[elogind.git] / src / shared / util.c
index d33f349d816d9a667b236e420609c6e519d2de37..39ce46adb4dd19c10d5522f0c61e6271c5ff0426 100644 (file)
@@ -6987,14 +6987,14 @@ int is_symlink(const char *path) {
 
 int is_dir(const char* path, bool follow) {
         struct stat st;
+        int r;
 
-        if (follow) {
-                if (stat(path, &st) < 0)
-                        return -errno;
-        } else {
-                if (lstat(path, &st) < 0)
-                        return -errno;
-        }
+        if (follow)
+                r = stat(path, &st);
+        else
+                r = lstat(path, &st);
+        if (r < 0)
+                return -errno;
 
         return !!S_ISDIR(st.st_mode);
 }