1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

LibC: Replace fprintf(stderr) with warnln()

This commit is contained in:
Linus Groh 2021-05-31 14:39:36 +01:00
parent 028a337a6d
commit 1b81b63663
3 changed files with 11 additions and 16 deletions

View file

@ -77,7 +77,7 @@ static bool parse_grpdb_entry(const String& line)
{ {
auto parts = line.split_view(':', true); auto parts = line.split_view(':', true);
if (parts.size() != 4) { if (parts.size() != 4) {
fprintf(stderr, "getgrent(): Malformed entry on line %u: '%s' has %zu parts\n", s_line_number, line.characters(), parts.size()); warnln("getgrent(): Malformed entry on line {}: '{}' has {} parts", s_line_number, line, parts.size());
return false; return false;
} }
@ -89,7 +89,7 @@ static bool parse_grpdb_entry(const String& line)
auto gid = gid_string.to_uint(); auto gid = gid_string.to_uint();
if (!gid.has_value()) { if (!gid.has_value()) {
fprintf(stderr, "getgrent(): Malformed GID on line %u\n", s_line_number); warnln("getgrent(): Malformed GID on line {}", s_line_number);
return false; return false;
} }
@ -119,7 +119,7 @@ struct group* getgrent()
return nullptr; return nullptr;
if (ferror(s_stream)) { if (ferror(s_stream)) {
fprintf(stderr, "getgrent(): Read error: %s\n", strerror(ferror(s_stream))); warnln("getgrent(): Read error: {}", strerror(ferror(s_stream)));
return nullptr; return nullptr;
} }

View file

@ -433,14 +433,14 @@ static bool fill_getserv_buffers(const char* line, ssize_t read)
// Services file entries should always at least contain // Services file entries should always at least contain
// name and port/protocol, separated by tabs. // name and port/protocol, separated by tabs.
if (split_line.size() < 2) { if (split_line.size() < 2) {
fprintf(stderr, "getservent(): malformed services file\n"); warnln("getservent(): malformed services file");
return false; return false;
} }
__getserv_name_buffer = split_line[0]; __getserv_name_buffer = split_line[0];
auto port_protocol_split = String(split_line[1]).split('/'); auto port_protocol_split = String(split_line[1]).split('/');
if (port_protocol_split.size() < 2) { if (port_protocol_split.size() < 2) {
fprintf(stderr, "getservent(): malformed services file\n"); warnln("getservent(): malformed services file");
return false; return false;
} }
auto number = port_protocol_split[0].to_int(); auto number = port_protocol_split[0].to_int();
@ -615,7 +615,7 @@ static bool fill_getproto_buffers(const char* line, ssize_t read)
// This indicates an incorrect file format. Protocols file entries should // This indicates an incorrect file format. Protocols file entries should
// always have at least a name and a protocol. // always have at least a name and a protocol.
if (split_line.size() < 2) { if (split_line.size() < 2) {
fprintf(stderr, "getprotoent(): malformed protocols file\n"); warnln("getprotoent(): malformed protocols file");
return false; return false;
} }
__getproto_name_buffer = split_line[0]; __getproto_name_buffer = split_line[0];

View file

@ -9,7 +9,6 @@
#include <AK/String.h> #include <AK/String.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <assert.h> #include <assert.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <termcap.h> #include <termcap.h>
@ -21,8 +20,7 @@ char* BC;
int tgetent([[maybe_unused]] char* bp, [[maybe_unused]] const char* name) int tgetent([[maybe_unused]] char* bp, [[maybe_unused]] const char* name)
{ {
if constexpr (TERMCAP_DEBUG) warnln_if(TERMCAP_DEBUG, "tgetent: bp={:p}, name='{}'", bp, name);
fprintf(stderr, "tgetent: bp=%p, name='%s'\n", bp, name);
PC = '\0'; PC = '\0';
BC = const_cast<char*>("\033[D"); BC = const_cast<char*>("\033[D");
UP = const_cast<char*>("\033[A"); UP = const_cast<char*>("\033[A");
@ -80,8 +78,7 @@ static void ensure_caps()
char* tgetstr(const char* id, char** area) char* tgetstr(const char* id, char** area)
{ {
ensure_caps(); ensure_caps();
if constexpr (TERMCAP_DEBUG) warnln_if(TERMCAP_DEBUG, "tgetstr: id='{}'", id);
fprintf(stderr, "tgetstr: id='%s'\n", id);
auto it = caps->find(id); auto it = caps->find(id);
if (it != caps->end()) { if (it != caps->end()) {
char* ret = *area; char* ret = *area;
@ -90,7 +87,7 @@ char* tgetstr(const char* id, char** area)
*area += strlen(val) + 1; *area += strlen(val) + 1;
return ret; return ret;
} }
fprintf(stderr, "tgetstr: missing cap id='%s'\n", id); warnln_if(TERMCAP_DEBUG, "tgetstr: missing cap id='{}'", id);
return nullptr; return nullptr;
} }
@ -98,8 +95,7 @@ char* tgetstr(const char* id, char** area)
int tgetflag([[maybe_unused]] const char* id) int tgetflag([[maybe_unused]] const char* id)
{ {
if constexpr (TERMCAP_DEBUG) warnln_if(TERMCAP_DEBUG, "tgetflag: '{}'", id);
fprintf(stderr, "tgetflag: '%s'\n", id);
auto it = caps->find(id); auto it = caps->find(id);
if (it != caps->end()) if (it != caps->end())
return 1; return 1;
@ -108,8 +104,7 @@ int tgetflag([[maybe_unused]] const char* id)
int tgetnum(const char* id) int tgetnum(const char* id)
{ {
if constexpr (TERMCAP_DEBUG) warnln_if(TERMCAP_DEBUG, "tgetnum: '{}'", id);
fprintf(stderr, "tgetnum: '%s'\n", id);
auto it = caps->find(id); auto it = caps->find(id);
if (it != caps->end()) if (it != caps->end())
return atoi((*it).value); return atoi((*it).value);