From 17e5ba70b17f2751d1e6f640527b150df8c4e2ab Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 1 May 2021 12:01:54 +0200 Subject: [PATCH] LibC: Make sure that parse_pwddb_entry doesn't write to stderr Library functions shouldn't write to stdout/stderr as that might not be expected by the caller. --- Userland/Libraries/LibC/pwd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibC/pwd.cpp b/Userland/Libraries/LibC/pwd.cpp index d135acab09d..39552a95765 100644 --- a/Userland/Libraries/LibC/pwd.cpp +++ b/Userland/Libraries/LibC/pwd.cpp @@ -80,7 +80,7 @@ static bool parse_pwddb_entry(const String& line) { auto parts = line.split_view(':', true); if (parts.size() != 7) { - fprintf(stderr, "getpwent(): Malformed entry on line %u\n", s_line_number); + dbgln("getpwent(): Malformed entry on line {}", s_line_number); return false; } @@ -94,12 +94,12 @@ static bool parse_pwddb_entry(const String& line) auto uid = uid_string.to_uint(); if (!uid.has_value()) { - fprintf(stderr, "getpwent(): Malformed UID on line %u\n", s_line_number); + dbgln("getpwent(): Malformed UID on line {}", s_line_number); return false; } auto gid = gid_string.to_uint(); if (!gid.has_value()) { - fprintf(stderr, "getpwent(): Malformed GID on line %u\n", s_line_number); + dbgln("getpwent(): Malformed GID on line {}", s_line_number); return false; } @@ -124,7 +124,7 @@ struct passwd* getpwent() return nullptr; if (ferror(s_stream)) { - fprintf(stderr, "getpwent(): Read error: %s\n", strerror(ferror(s_stream))); + dbgln("getpwent(): Read error: {}", strerror(ferror(s_stream))); return nullptr; }