Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 47e280e

Browse files
committed
Cleanup errno in all the place the error is "consumed"
1 parent 2b02a40 commit 47e280e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

nobuild.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ int path_is_dir(Cstr path)
966966
struct stat statbuf = {0};
967967
if (stat(path, &statbuf) < 0) {
968968
if (errno == ENOENT) {
969+
errno = 0;
969970
return 0;
970971
}
971972

@@ -1024,6 +1025,7 @@ void path_mkdirs(Cstr_Array path)
10241025

10251026
if (mkdir(result, 0755) < 0) {
10261027
if (errno == EEXIST) {
1028+
errno = 0;
10271029
WARN("directory %s already exists", result);
10281030
} else {
10291031
PANIC("could not create directory %s: %s", result, strerror(errno));
@@ -1044,6 +1046,7 @@ void path_rm(Cstr path)
10441046

10451047
if (rmdir(path) < 0) {
10461048
if (errno == ENOENT) {
1049+
errno = 0;
10471050
WARN("directory %s does not exist", path);
10481051
} else {
10491052
PANIC("could not remove directory %s: %s", path, strerror(errno));
@@ -1052,6 +1055,7 @@ void path_rm(Cstr path)
10521055
} else {
10531056
if (unlink(path) < 0) {
10541057
if (errno == ENOENT) {
1058+
errno = 0;
10551059
WARN("file %s does not exist", path);
10561060
} else {
10571061
PANIC("could not remove file %s: %s", path, strerror(errno));

0 commit comments

Comments
 (0)