aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-08-14 19:00:02 +0200
committerMax Kellermann <max@duempel.org>2015-08-14 19:00:02 +0200
commitd053797340ae16b16186fe31d60bb12979ba9b81 (patch)
tree6bd922a06bc5e749a98eb52803d78dc9b2c8f9d3
parentc8d0f947d2270a52183c653a641bca5b7321f915 (diff)
downloadmpd-d053797340ae16b16186fe31d60bb12979ba9b81.tar.gz
mpd-d053797340ae16b16186fe31d60bb12979ba9b81.tar.xz
mpd-d053797340ae16b16186fe31d60bb12979ba9b81.zip
protocol/Result: move command_list_num to class Response
Diffstat (limited to '')
-rw-r--r--src/client/Response.cxx4
-rw-r--r--src/client/Response.hxx9
-rw-r--r--src/command/AllCommands.cxx5
-rw-r--r--src/protocol/Result.cxx1
-rw-r--r--src/protocol/Result.hxx1
-rw-r--r--test/test_protocol.cxx2
6 files changed, 12 insertions, 10 deletions
diff --git a/src/client/Response.cxx b/src/client/Response.cxx
index c7b25e84c..9af3c74ed 100644
--- a/src/client/Response.cxx
+++ b/src/client/Response.cxx
@@ -65,8 +65,8 @@ Response::Error(enum ack code, const char *msg)
void
Response::FormatError(enum ack code, const char *fmt, ...)
{
- Format("ACK [%i@%i] {%s} ",
- (int)code, command_list_num, current_command);
+ Format("ACK [%i@%u] {%s} ",
+ (int)code, list_index, current_command);
va_list args;
va_start(args, fmt);
diff --git a/src/client/Response.hxx b/src/client/Response.hxx
index ba53298c8..044bdf307 100644
--- a/src/client/Response.hxx
+++ b/src/client/Response.hxx
@@ -31,8 +31,15 @@ class Client;
class Response {
Client &client;
+ /**
+ * This command's index in the command list. Used to generate
+ * error messages.
+ */
+ const unsigned list_index;
+
public:
- explicit Response(Client &_client):client(_client) {}
+ Response(Client &_client, unsigned _list_index)
+ :client(_client), list_index(_list_index) {}
Response(const Response &) = delete;
Response &operator=(const Response &) = delete;
diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx
index aa60736f3..f98018f88 100644
--- a/src/command/AllCommands.cxx
+++ b/src/command/AllCommands.cxx
@@ -363,11 +363,9 @@ command_checked_lookup(Response &r, unsigned permission,
CommandResult
command_process(Client &client, unsigned num, char *line)
{
- Response r(client);
+ Response r(client, num);
Error error;
- command_list_num = num;
-
/* get the command name (first word on the line) */
/* we have to set current_command because Response::Error()
expects it to be set */
@@ -427,7 +425,6 @@ command_process(Client &client, unsigned num, char *line)
: CommandResult::ERROR;
current_command = nullptr;
- command_list_num = 0;
return ret;
}
diff --git a/src/protocol/Result.cxx b/src/protocol/Result.cxx
index a8a1c2d46..7d8dfb759 100644
--- a/src/protocol/Result.cxx
+++ b/src/protocol/Result.cxx
@@ -22,7 +22,6 @@
#include "client/Client.hxx"
const char *current_command;
-int command_list_num;
void
command_success(Client &client)
diff --git a/src/protocol/Result.hxx b/src/protocol/Result.hxx
index f45e91190..7dcb969e1 100644
--- a/src/protocol/Result.hxx
+++ b/src/protocol/Result.hxx
@@ -25,7 +25,6 @@
class Client;
extern const char *current_command;
-extern int command_list_num;
void
command_success(Client &client);
diff --git a/test/test_protocol.cxx b/test/test_protocol.cxx
index 457083aee..e683fe2cb 100644
--- a/test/test_protocol.cxx
+++ b/test/test_protocol.cxx
@@ -37,7 +37,7 @@ void
ArgParserTest::TestRange()
{
Client &client = *(Client *)nullptr;
- Response r(client);
+ Response r(client, 0);
RangeArg range;