From 9d681beaf089daa32543020abadb7ef5e126b75e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 26 Dec 2019 10:30:34 +0100 Subject: [PATCH] LibC: Oops x2, we can't use "bool" in stdlib.h either --- Libraries/LibC/stdio.cpp | 2 +- Libraries/LibC/stdlib.cpp | 12 ++++++------ Libraries/LibC/stdlib.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Libraries/LibC/stdio.cpp b/Libraries/LibC/stdio.cpp index 574b770e70c..926ad4d1c1b 100644 --- a/Libraries/LibC/stdio.cpp +++ b/Libraries/LibC/stdio.cpp @@ -636,7 +636,7 @@ void funlockfile(FILE* filehandle) FILE* tmpfile() { char tmp_path[] = "/tmp/XXXXXX"; - if (!__generate_unique_filename(tmp_path)) + if (__generate_unique_filename(tmp_path) < 0) return nullptr; int fd = open(tmp_path, O_CREAT | O_EXCL | O_RDWR, S_IWUSR | S_IRUSR); diff --git a/Libraries/LibC/stdlib.cpp b/Libraries/LibC/stdlib.cpp index 69239b3c15f..661c65a72b2 100644 --- a/Libraries/LibC/stdlib.cpp +++ b/Libraries/LibC/stdlib.cpp @@ -104,13 +104,13 @@ static inline T strtol_impl(const char* nptr, char** endptr, int base) return num; } -[[nodiscard]] bool __generate_unique_filename(char* pattern) +[[nodiscard]] int __generate_unique_filename(char* pattern) { int length = strlen(pattern); if (length < 6 || !String(pattern).ends_with("XXXXXX")) { errno = EINVAL; - return false; + return -1; } int start = length - 6; @@ -123,10 +123,10 @@ static inline T strtol_impl(const char* nptr, char** endptr, int base) struct stat st; int rc = lstat(pattern, &st); if (rc < 0 && errno == ENOENT) - return true; + return 0; } errno = EEXIST; - return false; + return -1; } extern "C" { @@ -533,7 +533,7 @@ int system(const char* command) char* mktemp(char* pattern) { - if (!__generate_unique_filename(pattern)) + if (__generate_unique_filename(pattern) < 0) pattern[0] = '\0'; return pattern; @@ -552,7 +552,7 @@ int mkstemp(char* pattern) char* mkdtemp(char* pattern) { - if (!__generate_unique_filename(pattern)) + if (__generate_unique_filename(pattern) < 0) return nullptr; if (mkdir(pattern, 0700) < 0) diff --git a/Libraries/LibC/stdlib.h b/Libraries/LibC/stdlib.h index 7bd91960d0a..91272ebcf78 100644 --- a/Libraries/LibC/stdlib.h +++ b/Libraries/LibC/stdlib.h @@ -4,7 +4,7 @@ #include #include -__attribute__((warn_unused_result)) bool __generate_unique_filename(char* pattern); +__attribute__((warn_unused_result)) int __generate_unique_filename(char* pattern); __BEGIN_DECLS