volume: moved range check to handle_setvol()

Converted the range checks in volume_level_change() to assertions.
Changed all volume types to "unsigned", expect for those which must be
able to indicate error (-1).
This commit is contained in:
Max Kellermann
2009-07-06 21:52:10 +02:00
parent 90472526e0
commit d3b5574d7a
5 changed files with 21 additions and 19 deletions

View File

@@ -1061,6 +1061,11 @@ handle_setvol(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if (!check_int(client, &level, argv[1], need_integer))
return COMMAND_RETURN_ERROR;
if (level < 0 || level > 100) {
command_error(client, ACK_ERROR_ARG, "Invalid volume value");
return COMMAND_RETURN_ERROR;
}
success = volume_level_change(level);
if (!success) {
command_error(client, ACK_ERROR_SYSTEM,