summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-09 14:25:35 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-09 21:25:10 +0200
commit16105091ba5cb8e9d81eabcb499e70b1907ffc08 (patch)
tree5d9ef14887d3b83c353c23ff5e53320e502cf9c7 /Userland
parentf1ce43bdbfa75bf6a9ff95fb5caa713cbdcc4200 (diff)
downloadserenity-16105091ba5cb8e9d81eabcb499e70b1907ffc08.zip
LibC: Remove a bunch of pointless `rc` temporaries in stdio.cpp
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibC/stdio.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/Userland/Libraries/LibC/stdio.cpp b/Userland/Libraries/LibC/stdio.cpp
index ae3371df01..e9b8e5631c 100644
--- a/Userland/Libraries/LibC/stdio.cpp
+++ b/Userland/Libraries/LibC/stdio.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020, Sergey Bugaev <bugaevc@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -1174,8 +1174,7 @@ FILE* popen(const char* command, const char* type)
int pipe_fds[2];
- int rc = pipe(pipe_fds);
- if (rc < 0) {
+ if (pipe(pipe_fds) < 0) {
ScopedValueRollback rollback(errno);
perror("pipe");
return nullptr;
@@ -1190,16 +1189,14 @@ FILE* popen(const char* command, const char* type)
return nullptr;
} else if (child_pid == 0) {
if (*type == 'r') {
- int rc = dup2(pipe_fds[1], STDOUT_FILENO);
- if (rc < 0) {
+ if (dup2(pipe_fds[1], STDOUT_FILENO) < 0) {
perror("dup2");
exit(1);
}
close(pipe_fds[0]);
close(pipe_fds[1]);
} else if (*type == 'w') {
- int rc = dup2(pipe_fds[0], STDIN_FILENO);
- if (rc < 0) {
+ if (dup2(pipe_fds[0], STDIN_FILENO) < 0) {
perror("dup2");
exit(1);
}
@@ -1207,8 +1204,7 @@ FILE* popen(const char* command, const char* type)
close(pipe_fds[1]);
}
- int rc = execl("/bin/sh", "sh", "-c", command, nullptr);
- if (rc < 0)
+ if (execl("/bin/sh", "sh", "-c", command, nullptr) < 0)
perror("execl");
exit(1);
}
@@ -1232,19 +1228,17 @@ int pclose(FILE* stream)
VERIFY(stream->popen_child() != 0);
int wstatus = 0;
- int rc = waitpid(stream->popen_child(), &wstatus, 0);
- if (rc < 0)
- return rc;
+ if (waitpid(stream->popen_child(), &wstatus, 0) < 0)
+ return -1;
return wstatus;
}
int remove(const char* pathname)
{
- int rc = unlink(pathname);
- if (rc < 0 && errno == EISDIR)
+ if (unlink(pathname) < 0 && errno == EISDIR)
return rmdir(pathname);
- return rc;
+ return 0;
}
int scanf(const char* fmt, ...)