summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-08-20 20:27:15 +0200
committerMax Kellermann <max@musicpd.org>2019-08-20 20:28:15 +0200
commit9bff5f9e36a02d40f660d39f52bd9c4b63caa1a5 (patch)
tree2a1b27e1cdf4198287c085042fef3e9a08198cfc
parent2bf26a2ff8ad65848b051151c40c6a34a600cf2c (diff)
client/Process, command/all: add `noexcept`
Clarify that those can't throw, preparing for the next commit.
-rw-r--r--src/client/ClientInternal.hxx2
-rw-r--r--src/client/ClientProcess.cxx4
-rw-r--r--src/command/AllCommands.cxx18
-rw-r--r--src/command/AllCommands.hxx4
4 files changed, 15 insertions, 13 deletions
diff --git a/src/client/ClientInternal.hxx b/src/client/ClientInternal.hxx
index 87a1f403b..37b5925f2 100644
--- a/src/client/ClientInternal.hxx
+++ b/src/client/ClientInternal.hxx
@@ -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
diff --git a/src/client/ClientProcess.cxx b/src/client/ClientProcess.cxx
index 547aa8c71..eeb72d35a 100644
--- a/src/client/ClientProcess.cxx
+++ b/src/client/ClientProcess.cxx
@@ -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;
diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx
index 90d616098..a9fac6919 100644
--- a/src/command/AllCommands.cxx
+++ b/src/command/AllCommands.cxx
@@ -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);
diff --git a/src/command/AllCommands.hxx b/src/command/AllCommands.hxx
index 3a0220e55..0e685c118 100644
--- a/src/command/AllCommands.hxx
+++ b/src/command/AllCommands.hxx
@@ -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