mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibC: Oops x2, we can't use "bool" in stdlib.h either
This commit is contained in:
parent
b1fc5d9143
commit
9d681beaf0
3 changed files with 8 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__attribute__((warn_unused_result)) bool __generate_unique_filename(char* pattern);
|
||||
__attribute__((warn_unused_result)) int __generate_unique_filename(char* pattern);
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue