commit a06ca3f74892062294f3752ab15a9e5d7778a106 from: Stefan Sperling date: Sat Oct 15 18:41:40 2022 UTC check for unlink(2) errors with the == -1 idiom, rather than != 0 ok op@ commit - a32780aad7a4bc8539de9e7fd39b371f2fe8c346 commit + a06ca3f74892062294f3752ab15a9e5d7778a106 blob - ec8a575ccccc0191c9140e4914ca6dd642338b9c blob + 6e1e9e139a552a6791b66e9ba6a53bbf2d8ef886 --- lib/reference.c +++ lib/reference.c @@ -1320,7 +1320,7 @@ done: free(path_refs); free(path); if (tmppath) { - if (unlink(tmppath) != 0 && err == NULL) + if (unlink(tmppath) == -1 && err == NULL) err = got_error_from_errno2("unlink", tmppath); free(tmppath); } @@ -1501,7 +1501,7 @@ delete_loose_ref(struct got_reference *ref, struct got /* XXX: check if old content matches our expectations? */ - if (unlink(path) != 0) + if (unlink(path) == -1) err = got_error_from_errno2("unlink", path); done: if (ref->lf == NULL && lf) blob - 30e991da06f030404cbce64de63293d385ff1ac8 blob + d0e5af7c33c6ca8a4ba2e9dc621a494ed26dda57 --- lib/worktree.c +++ lib/worktree.c @@ -4135,12 +4135,12 @@ schedule_for_deletion(void *arg, unsigned char status, size_t root_len; if (dirfd != -1) { - if (unlinkat(dirfd, de_name, 0) != 0) { + if (unlinkat(dirfd, de_name, 0) == -1) { err = got_error_from_errno2("unlinkat", ondisk_path); goto done; } - } else if (unlink(ondisk_path) != 0) { + } else if (unlink(ondisk_path) == -1) { err = got_error_from_errno2("unlink", ondisk_path); goto done; }