From 354c4690d23ffa827be4b3ee841a626efd2583b8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 29 Nov 2021 23:52:30 +0100 Subject: [PATCH] LibCore: Use LibCore syscall wrappers in get_password() --- Userland/Libraries/LibCore/GetPassword.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibCore/GetPassword.cpp b/Userland/Libraries/LibCore/GetPassword.cpp index ac923ad681..74b3b5dd29 100644 --- a/Userland/Libraries/LibCore/GetPassword.cpp +++ b/Userland/Libraries/LibCore/GetPassword.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -15,17 +16,13 @@ namespace Core { ErrorOr get_password(StringView prompt) { - if (write(STDOUT_FILENO, prompt.characters_without_null_termination(), prompt.length()) < 0) - return Error::from_errno(errno); + TRY(Core::System::write(STDOUT_FILENO, prompt.bytes())); - termios original {}; - if (tcgetattr(STDIN_FILENO, &original) < 0) - return Error::from_errno(errno); + auto original = TRY(Core::System::tcgetattr(STDIN_FILENO)); termios no_echo = original; no_echo.c_lflag &= ~ECHO; - if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &no_echo) < 0) - return Error::from_errno(errno); + TRY(Core::System::tcsetattr(STDIN_FILENO, TCSAFLUSH, no_echo)); char* password = nullptr; size_t n = 0;