Remove return value of Log_session::write

Fixes #3749
This commit is contained in:
Norman Feske
2020-05-05 13:51:05 +02:00
parent bbc21cf063
commit a9f0e47ea3
12 changed files with 22 additions and 39 deletions

View File

@ -25,8 +25,7 @@ struct Genode::Log_session_client : Rpc_client<Log_session>
explicit Log_session_client(Log_session_capability session) explicit Log_session_client(Log_session_capability session)
: Rpc_client<Log_session>(session) { } : Rpc_client<Log_session>(session) { }
size_t write(String const &string) override { void write(String const &string) override { call<Rpc_write>(string); }
return call<Rpc_write>(string); }
}; };
#endif /* _INCLUDE__LOG_SESSION__CLIENT_H_ */ #endif /* _INCLUDE__LOG_SESSION__CLIENT_H_ */

View File

@ -50,17 +50,15 @@ struct Genode::Log_session : Session
/** /**
* Output null-terminated string * Output null-terminated string
*
* \return number of written characters
*/ */
virtual size_t write(String const &string) = 0; virtual void write(String const &string) = 0;
/********************* /*********************
** RPC declaration ** ** RPC declaration **
*********************/ *********************/
GENODE_RPC(Rpc_write, size_t, write, String const &); GENODE_RPC(Rpc_write, void, write, String const &);
GENODE_RPC_INTERFACE(Rpc_write); GENODE_RPC_INTERFACE(Rpc_write);
}; };

View File

@ -49,15 +49,15 @@ namespace Genode {
** Log session ** ** Log session **
*****************/ *****************/
size_t write(String const &string_buf) override void write(String const &string_buf) override
{ {
if (!(string_buf.valid_string())) { if (!(string_buf.valid_string())) {
error("corrupted string"); error("corrupted string");
return 0; return;
} }
char const *string = string_buf.string(); char const * const string = string_buf.string();
size_t len = strlen(string); size_t const len = strlen(string);
unsigned from_i = 0; unsigned from_i = 0;
for (unsigned i = 0; i < len; i++) { for (unsigned i = 0; i < len; i++) {
@ -70,8 +70,6 @@ namespace Genode {
/* if last character of string was not a line break, add one */ /* if last character of string was not a line break, add one */
if (from_i < len) if (from_i < len)
log(_label, Cstring(string + from_i)); log(_label, Cstring(string + from_i));
return len;
} }
}; };
} }

View File

@ -40,7 +40,7 @@ namespace {
Back_end(Parent &parent) Back_end(Parent &parent)
: _client(reinterpret_cap_cast<Log_session>(_cap(parent))) { } : _client(reinterpret_cap_cast<Log_session>(_cap(parent))) { }
void write(char const *string) { (void)_client.write(string); } void write(char const *string) { _client.write(string); }
}; };
} }

View File

@ -302,15 +302,14 @@ class Nitlog::Session_component : public Rpc_object<Log_session>
** Log session interface ** ** Log session interface **
***************************/ ***************************/
size_t write(String const &log_text) override void write(String const &log_text) override
{ {
if (!log_text.valid_string()) { if (!log_text.valid_string()) {
error("corrupted string"); error("corrupted string");
return 0; return;
} }
_log_window.write(_color, _label.string(), log_text.string(), _id); _log_window.write(_color, _label.string(), log_text.string(), _id);
return strlen(log_text.string());
} }
}; };

View File

@ -46,9 +46,9 @@ class Depot_deploy::Log_session_component : public Rpc_object<Log_session>
_child(child) _child(child)
{ } { }
size_t write(String const &line) override void write(String const &line) override
{ {
return _child.log_session_write(line, _label); _child.log_session_write(line, _label);
} }
}; };

View File

@ -173,9 +173,9 @@ struct Log::Session_component : Genode::Rpc_object<Log_session>
_read(); _read(); _read(); _read();
} }
Genode::size_t write(String const &string_buf) void write(String const &string_buf) override
{ {
if (!(string_buf.valid_string())) { return 0; } if (!(string_buf.valid_string())) { return; }
strncpy(_buf, string_buf.string(), sizeof(_buf)); strncpy(_buf, string_buf.string(), sizeof(_buf));
size_t len = strlen(_buf); size_t len = strlen(_buf);
@ -185,8 +185,6 @@ struct Log::Session_component : Genode::Rpc_object<Log_session>
Genode::log("RPC with \"", Genode::Cstring(_buf), "\""); Genode::log("RPC with \"", Genode::Cstring(_buf), "\"");
_select(); _select();
return len;
} }
}; };

View File

@ -61,7 +61,7 @@ struct Dummy::Log_service
log("closing session with label ", _label); log("closing session with label ", _label);
} }
size_t write(String const &string) override void write(String const &string) override
{ {
/* strip known line delimiter from incoming message */ /* strip known line delimiter from incoming message */
unsigned n = 0; unsigned n = 0;
@ -71,8 +71,6 @@ struct Dummy::Log_service
typedef Genode::String<100> Message; typedef Genode::String<100> Message;
Message const message("[", _label, "] ", Cstring(string.string(), n)); Message const message("[", _label, "] ", Cstring(string.string(), n));
log(message); log(message);
return strlen(string.string());
} }
}; };

View File

@ -76,13 +76,13 @@ class Fs_log::Session_component : public Genode::Rpc_object<Genode::Log_session>
** Log session ** ** Log session **
*****************/ *****************/
Genode::size_t write(Log_session::String const &msg) override void write(Log_session::String const &msg) override
{ {
using namespace Genode; using namespace Genode;
if (!msg.valid_string()) { if (!msg.valid_string()) {
Genode::error("received corrupted string"); Genode::error("received corrupted string");
return 0; return;
} }
size_t msg_len = strlen(msg.string()); size_t msg_len = strlen(msg.string());
@ -123,7 +123,6 @@ class Fs_log::Session_component : public Genode::Rpc_object<Genode::Log_session>
memcpy(buf, msg.string(), msg_len); memcpy(buf, msg.string(), msg_len);
source.submit_packet(packet); source.submit_packet(packet);
return msg_len;
} }
}; };

View File

@ -52,11 +52,11 @@ namespace Genode {
* The following function's code is a modified variant of the one in: * The following function's code is a modified variant of the one in:
* 'base/src/core/include/log_session_component.h' * 'base/src/core/include/log_session_component.h'
*/ */
size_t write(String const &string_buf) override void write(String const &string_buf) override
{ {
if (!(string_buf.valid_string())) { if (!(string_buf.valid_string())) {
Genode::error("corrupted string"); Genode::error("corrupted string");
return 0; return;
} }
char const *string = string_buf.string(); char const *string = string_buf.string();
@ -73,7 +73,7 @@ namespace Genode {
enum { ESC = 27 }; enum { ESC = 27 };
if ((string[0] == ESC) && (len == 5) && (string[4] == '\n')) { if ((string[0] == ESC) && (len == 5) && (string[4] == '\n')) {
_terminal.write(string, len - 1); _terminal.write(string, len - 1);
return len; return;
} }
_terminal.write(_label, strlen(_label)); _terminal.write(_label, strlen(_label));
@ -85,8 +85,6 @@ namespace Genode {
/* carriage-return as expected by hardware terminals on newline */ /* carriage-return as expected by hardware terminals on newline */
_terminal.write("\r", 1); _terminal.write("\r", 1);
return len;
} }
}; };

View File

@ -138,7 +138,7 @@ class Test::Log_session_component : public Rpc_object<Log_session>
_label(label), _handler(handler) _label(label), _handler(handler)
{ } { }
size_t write(String const &string) override void write(String const &string) override
{ {
/* strip known line delimiter from incoming message */ /* strip known line delimiter from incoming message */
unsigned n = 0; unsigned n = 0;
@ -153,8 +153,6 @@ class Test::Log_session_component : public Rpc_object<Log_session>
_handler.handle_log_message(message); _handler.handle_log_message(message);
log(message, " (", result, ")"); log(message, " (", result, ")");
return strlen(string.string());
} }
}; };

View File

@ -31,13 +31,11 @@ struct Test::Log_session_component : Session_object<Log_session>
template <typename... ARGS> template <typename... ARGS>
Log_session_component(ARGS &&... args) : Session_object(args...) { } Log_session_component(ARGS &&... args) : Session_object(args...) { }
size_t write(String const &msg) override void write(String const &msg) override
{ {
/* omit line break and zero termination supplied by 'msg' */ /* omit line break and zero termination supplied by 'msg' */
if (msg.size() > 1) if (msg.size() > 1)
log("local LOG service: ", Cstring(msg.string(), msg.size() - 2)); log("local LOG service: ", Cstring(msg.string(), msg.size() - 2));
return 0;
} }
}; };