aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-08-11 22:57:06 +0200
committerMax Kellermann <max@duempel.org>2015-08-11 22:58:04 +0200
commite118e958f7f9b87054679ebf6102d6923abbba81 (patch)
tree65368eea1cc1e172b223a770f9352f9a88ac3830 /src/command
parentee61dfe08742b76b1c637a038dd5b3a6b244ece7 (diff)
downloadmpd-e118e958f7f9b87054679ebf6102d6923abbba81.tar.gz
mpd-e118e958f7f9b87054679ebf6102d6923abbba81.tar.xz
mpd-e118e958f7f9b87054679ebf6102d6923abbba81.zip
protocol/ArgParser: add overload with max_value parameter
Diffstat (limited to '')
-rw-r--r--src/command/OtherCommands.cxx14
-rw-r--r--src/command/QueueCommands.cxx16
2 files changed, 4 insertions, 26 deletions
diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx
index 4fc7e56f6..816764a5d 100644
--- a/src/command/OtherCommands.cxx
+++ b/src/command/OtherCommands.cxx
@@ -309,14 +309,9 @@ CommandResult
handle_setvol(Client &client, Request args)
{
unsigned level;
- if (!ParseCommandArg(client, level, args.front()))
+ if (!ParseCommandArg(client, level, args.front(), 100))
return CommandResult::ERROR;
- if (level > 100) {
- command_error(client, ACK_ERROR_ARG, "Invalid volume value");
- return CommandResult::ERROR;
- }
-
if (!volume_level_change(client.partition.outputs, level)) {
command_error(client, ACK_ERROR_SYSTEM,
"problems setting volume");
@@ -330,14 +325,9 @@ CommandResult
handle_volume(Client &client, Request args)
{
int relative;
- if (!ParseCommandArg(client, relative, args.front()))
+ if (!ParseCommandArg(client, relative, args.front(), -100, 100))
return CommandResult::ERROR;
- if (relative < -100 || relative > 100) {
- command_error(client, ACK_ERROR_ARG, "Invalid volume value");
- return CommandResult::ERROR;
- }
-
const int old_volume = volume_level_get(client.partition.outputs);
if (old_volume < 0) {
command_error(client, ACK_ERROR_SYSTEM, "No mixer");
diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx
index 634510cc8..9a64ceb25 100644
--- a/src/command/QueueCommands.cxx
+++ b/src/command/QueueCommands.cxx
@@ -314,15 +314,9 @@ handle_prio(Client &client, Request args)
{
const char *const priority_string = args.shift();
unsigned priority;
- if (!ParseCommandArg(client, priority, priority_string))
+ if (!ParseCommandArg(client, priority, priority_string, 0xff))
return CommandResult::ERROR;
- if (priority > 0xff) {
- command_error(client, ACK_ERROR_ARG,
- "Priority out of range: %s", priority_string);
- return CommandResult::ERROR;
- }
-
for (const char *i : args) {
RangeArg range;
if (!ParseCommandArg(client, range, i))
@@ -344,15 +338,9 @@ handle_prioid(Client &client, Request args)
{
const char *const priority_string = args.shift();
unsigned priority;
- if (!ParseCommandArg(client, priority, priority_string))
+ if (!ParseCommandArg(client, priority, priority_string, 0xff))
return CommandResult::ERROR;
- if (priority > 0xff) {
- command_error(client, ACK_ERROR_ARG,
- "Priority out of range: %s", priority_string);
- return CommandResult::ERROR;
- }
-
for (const char *i : args) {
unsigned song_id;
if (!ParseCommandArg(client, song_id, i))