X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.c;h=5827f6c7a14dfa3afbebc0e0befd601d5f6ca277;hb=bcb161b0230f;hp=49d2a0dacec74ea5b0ec9e0d72c775a47d5b1701;hpb=ab7d9b674e8eb1388dff4d44def1b661892832e6;p=elogind.git diff --git a/src/shared/util.c b/src/shared/util.c index 49d2a0dac..5827f6c7a 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -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;