playlist: moved "repeat" and "random" value checks to command.c
Client's input values should be validated by the command implementation, and the core libraries shouldn't talk to the client directly if possible. Thus, setPlaylistRepeatStatus() and setPlaylistRandomStatus() don't get the file descriptor, and cannot fail (return void).
This commit is contained in:
@@ -773,7 +773,15 @@ static int handleRepeat(int fd, mpd_unused int *permission,
|
||||
|
||||
if (check_int(fd, &status, argv[1], need_integer) < 0)
|
||||
return -1;
|
||||
return setPlaylistRepeatStatus(fd, status);
|
||||
|
||||
if (status != 0 && status != 1) {
|
||||
commandError(fd, ACK_ERROR_ARG,
|
||||
"\"%i\" is not 0 or 1", status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
setPlaylistRepeatStatus(status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int handleRandom(int fd, mpd_unused int *permission,
|
||||
@@ -783,7 +791,15 @@ static int handleRandom(int fd, mpd_unused int *permission,
|
||||
|
||||
if (check_int(fd, &status, argv[1], need_integer) < 0)
|
||||
return -1;
|
||||
return setPlaylistRandomStatus(fd, status);
|
||||
|
||||
if (status != 0 && status != 1) {
|
||||
commandError(fd, ACK_ERROR_ARG,
|
||||
"\"%i\" is not 0 or 1", status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
setPlaylistRandomStatus(status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int handleStats(int fd, mpd_unused int *permission,
|
||||
|
Reference in New Issue
Block a user