diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-07-05 23:18:43 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-07-05 23:18:43 +0200 |
commit | b0b7d209fa978ff4a6b9c8cc5a8e4a3207cdd63f (patch) | |
tree | c1cc7a030287b847da03b0bcc5687a7ac3553242 | |
parent | 5fe14d15635d62becb90a7c4277b89e8981b983c (diff) |
Fix race-condition things
-rw-r--r-- | cbs.h | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -222,21 +222,17 @@ fexists(const char *f) int fmdcmp(const char *lhs, const char *rhs) { - int errnol, errnor; + int retl, retr; struct stat sbl, sbr; - stat(lhs, &sbl); errnol = errno; - errno = 0; - stat(rhs, &sbr); errnor = errno; - - assert(errnol == 0 || errnol == ENOENT); - assert(errnor == 0 || errnor == ENOENT); + retl = stat(lhs, &sbl); + retr = stat(rhs, &sbr); - if (errnol == ENOENT && errnor == ENOENT) + if (retl == -1 && retr == -1) return 0; - if (errnol == ENOENT) + if (retl == -1) return -1; - if (errnor == ENOENT) + if (retr == -1) return +1; return sbl.st_mtim.tv_sec == sbr.st_mtim.tv_sec |