client/Process, command/all: add noexcept

Clarify that those can't throw, preparing for the next commit.
This commit is contained in:
Max Kellermann 2019-08-20 20:27:15 +02:00
parent 2bf26a2ff8
commit 9bff5f9e36
4 changed files with 15 additions and 13 deletions

View File

@ -35,6 +35,6 @@ extern size_t client_max_command_list_size;
extern size_t client_max_output_buffer_size;
CommandResult
client_process_line(Client &client, char *line);
client_process_line(Client &client, char *line) noexcept;
#endif

View File

@ -30,7 +30,7 @@
static CommandResult
client_process_command_list(Client &client, bool list_ok,
std::list<std::string> &&list)
std::list<std::string> &&list) noexcept
{
CommandResult ret = CommandResult::OK;
unsigned num = 0;
@ -51,7 +51,7 @@ client_process_command_list(Client &client, bool list_ok,
}
CommandResult
client_process_line(Client &client, char *line)
client_process_line(Client &client, char *line) noexcept
{
CommandResult ret;

View File

@ -206,9 +206,10 @@ static constexpr struct command commands[] = {
static constexpr unsigned num_commands = ARRAY_SIZE(commands);
gcc_pure
static bool
command_available(gcc_unused const Partition &partition,
gcc_unused const struct command *cmd)
gcc_unused const struct command *cmd) noexcept
{
#ifdef ENABLE_SQLITE
if (StringIsEqual(cmd->cmd, "sticker"))
@ -235,7 +236,7 @@ command_available(gcc_unused const Partition &partition,
static CommandResult
PrintAvailableCommands(Response &r, const Partition &partition,
unsigned permission)
unsigned permission) noexcept
{
for (unsigned i = 0; i < num_commands; ++i) {
const struct command *cmd = &commands[i];
@ -249,7 +250,7 @@ PrintAvailableCommands(Response &r, const Partition &partition,
}
static CommandResult
PrintUnavailableCommands(Response &r, unsigned permission)
PrintUnavailableCommands(Response &r, unsigned permission) noexcept
{
for (unsigned i = 0; i < num_commands; ++i) {
const struct command *cmd = &commands[i];
@ -276,7 +277,7 @@ handle_not_commands(Client &client, gcc_unused Request request, Response &r)
}
void
command_init()
command_init() noexcept
{
#ifndef NDEBUG
/* ensure that the command list is sorted */
@ -285,8 +286,9 @@ command_init()
#endif
}
gcc_pure
static const struct command *
command_lookup(const char *name)
command_lookup(const char *name) noexcept
{
unsigned a = 0, b = num_commands, i;
@ -308,7 +310,7 @@ command_lookup(const char *name)
static bool
command_check_request(const struct command *cmd, Response &r,
unsigned permission, Request args)
unsigned permission, Request args) noexcept
{
if (cmd->permission != (permission & cmd->permission)) {
r.FormatError(ACK_ERROR_PERMISSION,
@ -342,7 +344,7 @@ command_check_request(const struct command *cmd, Response &r,
static const struct command *
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);
if (cmd == nullptr) {
@ -360,7 +362,7 @@ command_checked_lookup(Response &r, unsigned permission,
}
CommandResult
command_process(Client &client, unsigned num, char *line)
command_process(Client &client, unsigned num, char *line) noexcept
try {
Response r(client, num);

View File

@ -25,9 +25,9 @@
class Client;
void
command_init();
command_init() noexcept;
CommandResult
command_process(Client &client, unsigned num, char *line);
command_process(Client &client, unsigned num, char *line) noexcept;
#endif