mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:07:44 +00:00
LibCore: Using printf() inside CIODevices will now call CIODevice::printf().
Well this was confusing. Obviously this code should never be calling outside to ::printf() anyway, so just use dbgprintf() instead.
This commit is contained in:
parent
090e14d42c
commit
dbf7878998
2 changed files with 8 additions and 6 deletions
|
@ -118,7 +118,7 @@ ByteBuffer CIODevice::read_line(int max_size)
|
||||||
return { };
|
return { };
|
||||||
if (m_eof) {
|
if (m_eof) {
|
||||||
if (m_buffered_data.size() > max_size) {
|
if (m_buffered_data.size() > max_size) {
|
||||||
printf("CIODevice::read_line: At EOF but there's more than max_size(%d) buffered\n", max_size);
|
dbgprintf("CIODevice::read_line: At EOF but there's more than max_size(%d) buffered\n", max_size);
|
||||||
return { };
|
return { };
|
||||||
}
|
}
|
||||||
auto buffer = ByteBuffer::copy(m_buffered_data.data(), m_buffered_data.size());
|
auto buffer = ByteBuffer::copy(m_buffered_data.data(), m_buffered_data.size());
|
||||||
|
@ -203,7 +203,9 @@ int CIODevice::printf(const char* format, ...)
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
// FIXME: We're not propagating write() failures to client here!
|
// FIXME: We're not propagating write() failures to client here!
|
||||||
int ret = printf_internal([this] (char*&, char ch) {
|
int ret = printf_internal([this] (char*&, char ch) {
|
||||||
write((const byte*)&ch, 1);
|
int rc = write((const byte*)&ch, 1);
|
||||||
|
if (rc < 0)
|
||||||
|
dbgprintf("CIODevice::printf: write: %s\n", strerror(errno));
|
||||||
}, nullptr, format, ap);
|
}, nullptr, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -47,15 +47,15 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
||||||
m_destination_address = address;
|
m_destination_address = address;
|
||||||
m_destination_port = port;
|
m_destination_port = port;
|
||||||
|
|
||||||
printf("Connecting to %s...", address.to_string().characters());
|
dbgprintf("Connecting to %s...", address.to_string().characters());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
int rc = ::connect(fd(), (struct sockaddr*)&addr, sizeof(addr));
|
int rc = ::connect(fd(), (struct sockaddr*)&addr, sizeof(addr));
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (errno == EINPROGRESS) {
|
if (errno == EINPROGRESS) {
|
||||||
printf("in progress.\n");
|
dbgprintf("in progress.\n");
|
||||||
m_notifier = make<CNotifier>(fd(), CNotifier::Event::Write);
|
m_notifier = make<CNotifier>(fd(), CNotifier::Event::Write);
|
||||||
m_notifier->on_ready_to_write = [this] {
|
m_notifier->on_ready_to_write = [this] {
|
||||||
printf("%s{%p} connected!\n", class_name(), this);
|
dbgprintf("%s{%p} connected!\n", class_name(), this);
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
m_notifier->set_event_mask(CNotifier::Event::None);
|
m_notifier->set_event_mask(CNotifier::Event::None);
|
||||||
if (on_connected)
|
if (on_connected)
|
||||||
|
@ -66,7 +66,7 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
||||||
perror("connect");
|
perror("connect");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("ok!\n");
|
dbgprintf("ok!\n");
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue