diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2020-01-20 15:18:54 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-01-20 13:26:06 +0100 |
commit | d5426fcc888df700ff356009bb685a5b397f4361 (patch) | |
tree | 15086bcefa85a4b800d3b00c51642e2f1dda11b5 /Kernel/Process.cpp | |
parent | 9bc6157998dc56cb397a352f64ba2270066f986e (diff) | |
download | serenity-d5426fcc888df700ff356009bb685a5b397f4361.zip |
Kernel: Misc tweaks
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r-- | Kernel/Process.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 11a6c9845b..505000832c 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1722,8 +1722,6 @@ int Process::sys$access(const char* user_path, size_t path_length, int mode) int Process::sys$fcntl(int fd, int cmd, u32 arg) { REQUIRE_PROMISE(stdio); - (void)cmd; - (void)arg; #ifdef DEBUG_IO dbgprintf("sys$fcntl: fd=%d, cmd=%d, arg=%u\n", fd, cmd, arg); #endif @@ -1981,14 +1979,11 @@ int Process::sys$open(const Syscall::SC_open_params* user_params) int Process::alloc_fd(int first_candidate_fd) { - int fd = -EMFILE; for (int i = first_candidate_fd; i < (int)m_max_open_file_descriptors; ++i) { - if (!m_fds[i]) { - fd = i; - break; - } + if (!m_fds[i]) + return i; } - return fd; + return -EMFILE; } int Process::sys$pipe(int pipefd[2], int flags) @@ -2497,7 +2492,7 @@ int Process::sys$dup(int old_fd) auto description = file_description(old_fd); if (!description) return -EBADF; - int new_fd = alloc_fd(0); + int new_fd = alloc_fd(); if (new_fd < 0) return new_fd; m_fds[new_fd].set(*description); |