Commit 9bff5f9e authored by Max Kellermann's avatar Max Kellermann

client/Process, command/all: add `noexcept`

Clarify that those can't throw, preparing for the next commit.
parent 2bf26a2f
...@@ -35,6 +35,6 @@ extern size_t client_max_command_list_size; ...@@ -35,6 +35,6 @@ extern size_t client_max_command_list_size;
extern size_t client_max_output_buffer_size; extern size_t client_max_output_buffer_size;
CommandResult CommandResult
client_process_line(Client &client, char *line); client_process_line(Client &client, char *line) noexcept;
#endif #endif
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
static CommandResult static CommandResult
client_process_command_list(Client &client, bool list_ok, client_process_command_list(Client &client, bool list_ok,
std::list<std::string> &&list) std::list<std::string> &&list) noexcept
{ {
CommandResult ret = CommandResult::OK; CommandResult ret = CommandResult::OK;
unsigned num = 0; unsigned num = 0;
...@@ -51,7 +51,7 @@ client_process_command_list(Client &client, bool list_ok, ...@@ -51,7 +51,7 @@ client_process_command_list(Client &client, bool list_ok,
} }
CommandResult CommandResult
client_process_line(Client &client, char *line) client_process_line(Client &client, char *line) noexcept
{ {
CommandResult ret; CommandResult ret;
......
...@@ -206,9 +206,10 @@ static constexpr struct command commands[] = { ...@@ -206,9 +206,10 @@ static constexpr struct command commands[] = {
static constexpr unsigned num_commands = ARRAY_SIZE(commands); static constexpr unsigned num_commands = ARRAY_SIZE(commands);
gcc_pure
static bool static bool
command_available(gcc_unused const Partition &partition, command_available(gcc_unused const Partition &partition,
gcc_unused const struct command *cmd) gcc_unused const struct command *cmd) noexcept
{ {
#ifdef ENABLE_SQLITE #ifdef ENABLE_SQLITE
if (StringIsEqual(cmd->cmd, "sticker")) if (StringIsEqual(cmd->cmd, "sticker"))
...@@ -235,7 +236,7 @@ command_available(gcc_unused const Partition &partition, ...@@ -235,7 +236,7 @@ command_available(gcc_unused const Partition &partition,
static CommandResult static CommandResult
PrintAvailableCommands(Response &r, const Partition &partition, PrintAvailableCommands(Response &r, const Partition &partition,
unsigned permission) unsigned permission) noexcept
{ {
for (unsigned i = 0; i < num_commands; ++i) { for (unsigned i = 0; i < num_commands; ++i) {
const struct command *cmd = &commands[i]; const struct command *cmd = &commands[i];
...@@ -249,7 +250,7 @@ PrintAvailableCommands(Response &r, const Partition &partition, ...@@ -249,7 +250,7 @@ PrintAvailableCommands(Response &r, const Partition &partition,
} }
static CommandResult static CommandResult
PrintUnavailableCommands(Response &r, unsigned permission) PrintUnavailableCommands(Response &r, unsigned permission) noexcept
{ {
for (unsigned i = 0; i < num_commands; ++i) { for (unsigned i = 0; i < num_commands; ++i) {
const struct command *cmd = &commands[i]; const struct command *cmd = &commands[i];
...@@ -276,7 +277,7 @@ handle_not_commands(Client &client, gcc_unused Request request, Response &r) ...@@ -276,7 +277,7 @@ handle_not_commands(Client &client, gcc_unused Request request, Response &r)
} }
void void
command_init() command_init() noexcept
{ {
#ifndef NDEBUG #ifndef NDEBUG
/* ensure that the command list is sorted */ /* ensure that the command list is sorted */
...@@ -285,8 +286,9 @@ command_init() ...@@ -285,8 +286,9 @@ command_init()
#endif #endif
} }
gcc_pure
static const struct command * static const struct command *
command_lookup(const char *name) command_lookup(const char *name) noexcept
{ {
unsigned a = 0, b = num_commands, i; unsigned a = 0, b = num_commands, i;
...@@ -308,7 +310,7 @@ command_lookup(const char *name) ...@@ -308,7 +310,7 @@ command_lookup(const char *name)
static bool static bool
command_check_request(const struct command *cmd, Response &r, command_check_request(const struct command *cmd, Response &r,
unsigned permission, Request args) unsigned permission, Request args) noexcept
{ {
if (cmd->permission != (permission & cmd->permission)) { if (cmd->permission != (permission & cmd->permission)) {
r.FormatError(ACK_ERROR_PERMISSION, r.FormatError(ACK_ERROR_PERMISSION,
...@@ -342,7 +344,7 @@ command_check_request(const struct command *cmd, Response &r, ...@@ -342,7 +344,7 @@ command_check_request(const struct command *cmd, Response &r,
static const struct command * static const struct command *
command_checked_lookup(Response &r, unsigned permission, command_checked_lookup(Response &r, unsigned permission,
const char *cmd_name, Request args) const char *cmd_name, Request args) noexcept
{ {
const struct command *cmd = command_lookup(cmd_name); const struct command *cmd = command_lookup(cmd_name);
if (cmd == nullptr) { if (cmd == nullptr) {
...@@ -360,7 +362,7 @@ command_checked_lookup(Response &r, unsigned permission, ...@@ -360,7 +362,7 @@ command_checked_lookup(Response &r, unsigned permission,
} }
CommandResult CommandResult
command_process(Client &client, unsigned num, char *line) command_process(Client &client, unsigned num, char *line) noexcept
try { try {
Response r(client, num); Response r(client, num);
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
class Client; class Client;
void void
command_init(); command_init() noexcept;
CommandResult CommandResult
command_process(Client &client, unsigned num, char *line); command_process(Client &client, unsigned num, char *line) noexcept;
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment