chiark / gitweb /
errno is positive
[elogind.git] / src / shared / util.c
index 49d2a0dacec74ea5b0ec9e0d72c775a47d5b1701..5827f6c7a14dfa3afbebc0e0befd601d5f6ca277 100644 (file)
@@ -234,6 +234,17 @@ void close_many(const int fds[], unsigned n_fd) {
                 close_nointr_nofail(fds[i]);
 }
 
+int unlink_noerrno(const char *path) {
+        PROTECT_ERRNO;
+        int r;
+
+        r = unlink(path);
+        if (r < 0)
+                return -errno;
+
+        return 0;
+}
+
 int parse_boolean(const char *v) {
         assert(v);
 
@@ -5248,7 +5259,7 @@ int get_home_dir(char **_h) {
         errno = 0;
         p = getpwuid(u);
         if (!p)
-                return errno ? -errno : -ESRCH;
+                return errno > 0 ? -errno : -ESRCH;
 
         if (!path_is_absolute(p->pw_dir))
                 return -EINVAL;